Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Syntax Deprecated #1

Closed
Grossdm opened this issue Dec 16, 2018 · 16 comments
Closed

Rule Syntax Deprecated #1

Grossdm opened this issue Dec 16, 2018 · 16 comments

Comments

@Grossdm
Copy link

Grossdm commented Dec 16, 2018

Hello,
I noticed that you have a rule that uses ##script:contains(...) syntax.

This is deprecated.

The new syntax is ##^script:has-text(...).

BTW, I found you here after reading your uBlock issue.

@Grossdm
Copy link
Author

Grossdm commented Dec 16, 2018

BTW, I did not know or intend for this issue to be listed on the uBlock issue page.

I apologize if that was impolite.

@medavox
Copy link
Owner

medavox commented Jan 21, 2019

Hi,

thanks very much for the feedback! sorry I didn't see this earlier.

As this list is primarily for personal consumption across all my devices, I'm less concerned with best-practice than usual. Note the lack of info header in the rules files, for instance.

However, after deprecation comes removal, so I appreciate your early warning that this feature will be removed soon.

@medavox
Copy link
Owner

medavox commented Jan 21, 2019

I've just been reading through the documentation to find an alternative way to implement my scrip:contains rules, and came across this:

Please note that with the introduction of HTML filtering, the script:contains(...) syntax is now deprecated and internally converted into an equivalent ##^script:has-text(...) HTML filter.

Although my syntax is deprecated, this means it should still work for me as a Firefox user in the future.

I'll change the relevant rules to reflect the equivalent syntax, but (lacking chrom(e|ium) support as mentioned in the doc page, there's not much else I can do.

@krystian3w
Copy link

Demo to test where works as generic:

##script:contains(blockadblock) or ##^script:has-text(blockadblock)

?

@medavox
Copy link
Owner

medavox commented Apr 22, 2019

Since there are now two javascript libraries with that name, you can try their websites to test if this filter still works:

  1. https://blockadblock.com/ (this is the product I was originally intending to block)
  2. http://sitexw.fr/blockadblock/ (an open-source equivalent)

By the looks of things, this filter no longer does the intended job, because blockadblock.com are embedding the script directly into the page.

I haven't encountered any uses of this script in the wild for a while. Do you have a real site (and not its product page) that is broken by it?

@medavox
Copy link
Owner

medavox commented Apr 22, 2019

Relevant uBO wiki page

@medavox
Copy link
Owner

medavox commented Apr 22, 2019

A possible alternative to this rule is injecting the builtin scriplet for defusing BlockAdblock,

although I'm not sure how to replicate having the rule apply everywhere by default, like with ##^script:has-text.

@krystian3w
Copy link

that is broken by it?

from my knowledge this is no works without domain / tld.

@medavox
Copy link
Owner

medavox commented Apr 23, 2019

Demo to test where works as generic:

##script:contains(blockadblock) or ##^script:has-text(blockadblock)

?

I'm sorry, on reflection I don't think I understand your original query. Could you rephrase that?

@krystian3w
Copy link

krystian3w commented Apr 23, 2019

If no add domain / TLD ("suffix") before this filter, so is ignored/discarded (but Nano Adblocker no mark as invalid with comment "why" - https://github.com/NanoAdblocker/NanoCore#notable-change).

@medavox
Copy link
Owner

medavox commented Apr 23, 2019

Are you telling me that:

Because I've not prefixed this filter rule with a TLD, it's marked as invalid by NanoAdblocker's Filter Linter?

If that's not right, try Google translating from another language. I'm sorry I'm having trouble understanding you! 🤷‍♂️

@krystian3w
Copy link

krystian3w commented Apr 23, 2019

Because I've not prefixed this filter rule with a TLD, it's marked as invalid by NanoAdblocker's Filter Linter?

Yes. Filter doesn't works, I tried with similar site, e.g.: https://dniwolne.eu

dniwolne.eu##script:contains(google_jobrunner)
dniwolne.eu##^script:has-text(google_jobrunner)

Works, but without domain - still see alert:

obraz

Prosimy o wyłączenie programów blokujących reklamy ...

means:

Please disable ad blocking programs ...


So this filter is no used in latest uBO / Nano Adblocker maybe works in 2014-2018 with bugs in old uBO code.

@medavox
Copy link
Owner

medavox commented Apr 23, 2019

OK, now I understand. I'll remove this filter rule now, because it no longer performs its intended purpose.

I didn't prefix it with a TLD in the first place, because I wanted it to work automatically, without me having to manually un-break each site.

Because this is no longer an option (this filter no longer works), I'll just resort to injecting the scriptlet I mentioned above whenever necessary.

@Grossdm
Copy link
Author

Grossdm commented May 20, 2019

Has anyone tried to prefix the rule with *?

I use a filter with the "domain" as this wildcard:

! This hides the add to home screen button
! reddit.com/r/firefox/comments/90z662
*$csp=manifest-src 'none'

That vile button takes up precious real estate on a mobile browser.
I was overjoyed to find this filter suggested on Reddit. Unfortunately I was not able to find a way to donate to the author.

@krystian3w
Copy link

krystian3w commented May 20, 2019

*$csp= ... = so "normal" this is network filter, so can works on all websites.

Other story is create good csp filter:

e.g. bad in EasyList https://github.com/uBlockOrigin/uAssets/blob/df982907c5bcfc0eff8bed58096d423bb146954b/filters/unbreak.txt#L2372

@Grossdm
Copy link
Author

Grossdm commented May 20, 2019

@krystian3w,
Could you please explain your suggestion further?
I did look at the commit that you referenced, but I didn't learn anything.
I did notice that every csp filter was for script-src, while the filter that I posted was for manifest-src.
Did you have any thoughts on how to improve my filter? I welcome any suggestions you may have.

Thanks, Doug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants