You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
2 years ago
|
// todo настроить сборщик и для этого файла. Перевести на ts
|
||
|
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
|
||
|
}
|
||
|
|
||
|
}
|
||
|
);
|
||
|
|
||
|
chrome.storage.sync.get(['need-clean-notification'], function (result) {
|
||
|
// console.log('Value currently is ' + result['need-clean-notification'])
|
||
|
/**
|
||
|
* todo Добавить обсервер на чиски node с уведомлениями, если опция включена
|
||
|
*/
|
||
|
})
|