Limit contentScript on external content

This commit is contained in:
magnolia1234 2020-05-24 20:56:32 +02:00
parent 9fff9956fe
commit 24e62269ba

View file

@ -477,6 +477,8 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
if (tabId !== -1) {
ext_api.tabs.get(tabId, function (currentTab) {
if (isSiteEnabled(currentTab)) {
// run contentScript inside tab
ext_api.tabs.executeScript(tabId, {
file: 'contentScript.js',
@ -487,6 +489,8 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
});
}
});
}
return { requestHeaders: requestHeaders };
}, {
@ -556,7 +560,7 @@ function matchDomain(domains, hostname) {
}
function urlHost(url) {
if (url.startsWith('http')) {
if (url && url.startsWith('http')) {
try {
return new URL(url).hostname;
} catch (e) {