Code improvements

This commit is contained in:
nobody 2021-08-02 06:27:02 +02:00
parent 945063ef4e
commit 7678a54b1b
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
5 changed files with 9 additions and 14 deletions

View File

@ -49,9 +49,9 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
'code': `window.addEventListener('load', () => {
document.getElementById('domain').value = '${message.url}';
});`,
'runAt': 'document_start'
'runAt': 'document_idle'
});
break;
return MessageResponse.SYNCHRONOUS;
case 'domain:fetch-is-allowlisted':
sendResponse({'value': Boolean(helpers.checkAllowlisted(value))});

View File

@ -204,7 +204,7 @@ helpers.determineActiveTab = function () {
} else {
opt = {'active': true};
chrome.tabs.query(opt, function (tabs) {
chrome.tabs.query(opt, function () {
resolve(tabs[0]);
});
}

View File

@ -146,8 +146,6 @@ targets.setLastVersion = function (type, version) {
return '0.1.1';
} else if (type.startsWith('/angular-ui-select/0.')) {
return '0.20.0';
} else if (type.startsWith('/angular-sanitize/1.')) {
return '1.7.9';
} else if (type.startsWith('/angucomplete-alt/3.')) {
return '3.0.0';
} else if (type.startsWith('/animate.css/3.')) {

View File

@ -395,15 +395,13 @@ popup._filterDuplicates = function (array, key) {
* Ignore empty values of the 'key'
*
*/
let filtered = array
return array
.map((e) => e[key])
.map(function (value, index, newArray) {
return value !== '' ? newArray.indexOf(value) === index && index : index;
})
.filter((e) => array[e])
.map((e) => array[e]);
return filtered;
};
popup._renderLocaleNotice = function () {
@ -445,10 +443,6 @@ popup._onTestingUtilityLinkClicked = function (event) {
popup._injectDomain(tab.id);
});
}
if (event.button === 0) {
window.close();
}
};
popup._onDonationButtonClicked = function () {
@ -510,6 +504,9 @@ popup._injectDomain = function (tabId) {
};
chrome.runtime.sendMessage(message);
setTimeout(function () {
popup._close();
}, 200);
};
popup._onOptionsButtonClicked = function () {

View File

@ -54,8 +54,8 @@ updates._onDocumentLoaded = function () {
['copyRuleSet']: document.getElementById('button-copy-rule-set'),
};
for (let i = 0; i < updateElements.ruleSets.length; i++) {
updateElements.ruleSets[i].addEventListener('change', ruleGenerator.openRuleSet);
for (let ruleSets of updateElements.ruleSets) {
ruleSets.addEventListener('change', ruleGenerator.openRuleSet);
}
updateElements.copyRuleSet.addEventListener('click', ruleGenerator.copyRuleSet);