uBlock Origin Scriptlet Injection Tutorial
(March 18, 2021)
is an ad blocker you can get as an extension for web browsers, it's known for being
efficient and customizable with the ability to write custom filtering and blocking rules. A majority of the ad blocking works by filtering out
specific network domains that feed ads, it's easy to add custom domains to the filter list. But there are times where you can't filter out
on the target web page with scriptlet injection
if our code is being injected.
console.log("Hello I'm running via scriptlet injection.");
ExampleScript.js defines what our scriptlets name is which is how we identify it in the uBlock Origin filter later.
Before we can add our scriptlet to a filter we need to add it to uBlock Origin's accessible scripts via
userResourcesLocation, this option lets us provide
your web browser and then click the cog wheel icon.
You can find Advanced Settings by clicking the cog wheel icon beside 'I am an advanced user'.
Scroll down to find the userResourcesLocation option, which should be 'unset' by default. If you already have it set to a custom resource you can
. If you're sharing the
Open a web page and look in the console(F12 in most browsers), you should see the message 'Hello I'm running via scriptlet injection.'
-If you want to target a specific website use it's URL instead of wild card *, for example specificwebsite.com##+js(...).
the solution is to use window DOMContentLoaded or body load events to wait for initialization.
-You can include multiple scripts in a single file, add a few new lines and mark a new file name with '/// NewFileName.js'.
-If using a text pasting site make sure you use the raw text URL.