Block external Javascript for custom sites

Besides scripts on (sub)domain of site.
master
magnolia1234 2020-06-01 18:00:51 +02:00
parent 45308b8606
commit d337ae2cf0
3 changed files with 8 additions and 3 deletions

View File

@ -304,7 +304,7 @@ Remember to check the [previous requests](https://bitbucket.org/magnolia1234/byp
Add your own custom site (also for testing).
Check 'Options'-link in popup-menu and go to custom sites.
By default sites' cookies are removed after page loads (to bypass article limit).
Also you can enable Googlebot user-agent or disable Javascript for (sub)domain(s).
Also you can enable Googlebot user-agent or disable Javascript for (sub)domain(s)/external sources.
### Troubleshooting
* This extension works best alongside [uBlock Origin](https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm).

View File

@ -401,6 +401,11 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
});
}
// block external javascript for custom sites (optional)
if (matchUrlDomain([block_js_custom], header_referer) && details.url.match(/(\.js$|\.js\?)/) && isSiteEnabled({url: header_referer})) {
return { cancel: true };
}
// check for blocked regular expression: domain enabled, match regex, block on an internal or external regex
var blockedDomains = Object.keys(blockedRegexes);

View File

@ -16,8 +16,8 @@
<body>
<h2>Custom Sites</h2>
<div style="width:90%;">
To add new site, enter a unique title/domain (without www.) and select options for googlebot/block
javascript (only on (sub)domain). Then, enable your new site in <a href="options.html" style="color:black">options</a> (cookies will be removed by default).
To add new site, enter a unique title/domain (without www.) and select options for googlebot/block javascript.
Then enable your new site in <a href="options.html" style="color:black">options</a> (cookies will be removed by default).
<br/><br/>
</div>
<div id='add_site'></div>