[Question/Suggestion?] Filter a certain inline script only
marcussacana opened this issue · 9 comments
I'm not very good with adblock filter syntaxes, but I have a certain site with a custom anti-adblock script in the html.
To open the site, we can block all inline scripts, but in that site we must run certain scripts blocks to the site work, And I didn't found a way to select what I want block.
If isn't there a way, why not make the nano defender block all inline scripts, then read all scripts code, filter what we don't need, and inject it in the page?
I noticied even when I block the inline scripts, I can inject a script using extensions like Custom JS For Websites
Also, maybe will be cool do a simlple match and replace in the script, then we can negate simple detections.
Nano Defender has the ability to block and modify specific inline scripts with a.beforeScript
. Note that Nano Defender cannot be programmed with adblock filter syntax, it is JavaScript only. Check the source code for more information: https://github.com/jspenguin2017/uBlockProtector/blob/d3d9603cc4c776a488521ccf952e56c56e93bcbd/src/content/core.js#L300
Note that it is been a while since I needed a.beforeScript
, and it is likely that there are easier ways to fix your issue. I recommend you to simply report the issue you are facing and have a filters maintainer to take a look. You can find the Quick Issue Reporter by clicking the extension icon of Nano Defender.
@jspenguin2017 I don't wanna create a new issue only for this same case, so i'm trying ask here,
I research the documentation but I don't found any comments about how to use the beforeScript,
I take a look and the most near filter that I found is the ##script:inject
"most near" because looks like the inject function is defined in the same file...?
But when I tried write ##script:beforeScript
but looks like is wrong (the syntax highlight stop when I try)
Just open an issue here about the anti-adblock on that site/sites, we are happy to help you https://github.com/uBlockOrigin/uAssets
I know, I wanted learn... but forget, I will create the issue
--edit
Created, I hate fill forms, is one of reason that I wanted learn, and ocasionally I found more sites with similar problems
I'm not clear exactly what you want, but this might be helpful.
To "abort" an inline script: https://github.com/gorhill/uBlock/wiki/Resources-Library#acisjs-
To remove an inline script from the page source before it is loaded: https://github.com/gorhill/uBlock/wiki/Inline-script-tag-filtering
I see, that's cool, thanks.
how to use the beforeScript
You need to rebuild Nano Defender yourself if you wish to use a.beforeScript
. Note that you are expected to be familiar with Chromium extensions development process if you wish to do this.
But as I mentioned before, it is very likely that you can fix the problem without a.beforeScript
.
I know, I wanted learn...
Take a look at the documentation:
https://github.com/NanoAdblocker/NanoDoc/blob/master/en/Index.MD
And the source code:
https://github.com/NanoAdblocker/NanoCore2
https://github.com/gorhill/uBlock
If you are committed to learn, these are the best places to start.
I hate fill forms
I hate filling forms too, but if you use the Quick Issue Reporter, you can submit a report with as little as 5 clicks (2 clicks to open + 3 clicks to submit).
is one of reason that I wanted learn
Learning how to fix the issues yourself would likely take longer than simply reporting the issues, even filling the forms without Quick Issue Reporter.
This is not to discourage you to learn something new, but if your only goal is to avoid filling lengthy forms, then I highly recommend you to try the Quick Issue Reporter.
I see, then is a disabled feature by default, Well, I know a little about write browser extension,
Well, maybe create the issue can be more fast than rebuild everything, but how I explain, when I saw a site blocking me because of Adblocker I enter in rage, and I want defuse the shit and nothing more, One day, when I used simple adblockers that don't block in-line scripts, only to defuse an anti-adblocker in one site I created a local proxy server that change the html content of the site requests, Instead of just disable the adblock, I lost 2 days writing that shit, it's just like me haha;
But well, thank you; I think that example that you left to me in the other issue will help me in others sites too.
then is a disabled feature by default
a.beforeScript
is enabled in Nano Defender by default. But you need to rebuild Nano Defender to customize it. But as I said, more likely than not, you will not need a.beforeScript
. The abort-*
script snippets are usually enough. And as you saw, your issue (uBlockOrigin/uAssets#7402) was fixed without a.beforeScript
.