Добавил обработку виртуального поля счета

master
Sipachev Igor 4 years ago
parent 06ada6bd79
commit fff52e9bed
  1. 84
      assets/js/script.js

@ -1,40 +1,44 @@
function insertValueToNode(target, value) {
let nodeList = []
switch (target) {
case 'personal_id':
nodeList = document.querySelectorAll('*[name*="personal_id"]')
break
case 'iban':
nodeList = document.querySelectorAll('*[name*="bankaccount"]')
break
case 'phone':
nodeList = document.querySelectorAll('*[name*="phone"]')
break
case 'first_name':
nodeList = document.querySelectorAll('*[name*="first_name"]')
break
case 'last_name':
nodeList = document.querySelectorAll('*[name*="last_name"]')
break
}
for (const node of nodeList) {
node.value = value
}
}
chrome.runtime.onMessage.addListener(
function(autocompleteDTO, sender, sendResponse) {
switch (autocompleteDTO.action) {
case 'insert':
insertValueToNode(autocompleteDTO.target || null, autocompleteDTO.value || '')
break
case 'clean_notification':
var elementList = document.querySelectorAll('.uk-notify-message');
elementList.forEach(function(elementItem) {
elementItem.remove()
});
break
}
}
);
function insertValueToNode(target, value) {
let nodeList = []
switch (target) {
case 'personal_id':
nodeList = document.querySelectorAll('*[name*="personal_id"]')
break
case 'iban':
nodeList = document.querySelectorAll('.user-bank-account__fake')
for (const node of nodeList) {
node.value = value.substr(2)
}
nodeList = document.querySelectorAll('*[name*="bankaccount"]')
break
case 'phone':
nodeList = document.querySelectorAll('*[name*="phone"]')
break
case 'first_name':
nodeList = document.querySelectorAll('*[name*="first_name"]')
break
case 'last_name':
nodeList = document.querySelectorAll('*[name*="last_name"]')
break
}
for (const node of nodeList) {
node.value = value
}
}
chrome.runtime.onMessage.addListener(
function(autocompleteDTO, sender, sendResponse) {
switch (autocompleteDTO.action) {
case 'insert':
insertValueToNode(autocompleteDTO.target || null, autocompleteDTO.value || '')
break
case 'clean_notification':
var elementList = document.querySelectorAll('.uk-notify-message');
elementList.forEach(function(elementItem) {
elementItem.remove()
});
break
}
}
);

Loading…
Cancel
Save