mirror of
https://github.com/iamadamdev/bypass-paywalls-chrome
synced 2025-05-02 21:34:25 +02:00
Avoid injecting script to unrelated sites (#665)
* Avoid injecting script to unrelated sites * unnecessary comment
This commit is contained in:
parent
ad1afe9b63
commit
e33f019c1f
@ -348,13 +348,18 @@ extensionApi.webRequest.onBeforeSendHeaders.addListener(function (details) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tabId !== -1) {
|
if (tabId !== -1) {
|
||||||
// run contentScript inside tab
|
extensionApi.tabs.get(tabId, function (currentTab) {
|
||||||
extensionApi.tabs.executeScript(tabId, {
|
// Validate url of current tab to avoid injecting script to unrelated sites
|
||||||
file: 'src/js/contentScript.js',
|
if (currentTab && isSiteEnabled(currentTab)) {
|
||||||
runAt: 'document_start'
|
// run contentScript inside tab
|
||||||
}, function (res) {
|
extensionApi.tabs.executeScript(tabId, {
|
||||||
if (extensionApi.runtime.lastError || res[0]) {
|
file: 'src/js/contentScript.js',
|
||||||
|
runAt: 'document_start'
|
||||||
|
}, function (res) {
|
||||||
|
if (extensionApi.runtime.lastError || res[0]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user