AdguardTeam / AdguardBrowserExtension

AdGuard browser extension
https://adguard.com/
GNU General Public License v3.0
3.11k stars 332 forks source link

#%# modifier is failed on Firefox. #1376

Closed lancelot-moon closed 5 years ago

lancelot-moon commented 5 years ago

@AdamWr made some #%# and #$# rules in AG Annoyances filter for the below page's paywall.

Try to visit the page: https://tw.news.appledaily.com/international/realtime/20190411/1548615/

With AG Browser Extension v3.0.13 (AG Annoyances filter enabled) on Chrome, I can read news on the page.

With AG Browser Extension v3.0.13 (AG Annoyances filter enabled) on Firefox, I can't read news on the page. There is a warning to ask me to login. I tried to manually add those rules in the user filter of AG Browser Extension for Firefox v3.0.13. But the rules didn't work.

Why is the difference? A bug in AG Browser Extension for Firefox?

ameshkov commented 5 years ago

What exactly are the rules?

AdamWr commented 5 years ago

Probably problem is with AG_setConstant in this rule in Firefox: appledaily.com#%#AG_setConstant('paywall', 'noopFunc');

This one works fine in Firefox: appledaily.com#%#//scriptlet("set-constant", "paywall", "noopFunc")

lancelot-moon commented 5 years ago

Need to add them all for its paywall:

appledaily.com.tw##.adblock_splash
||img.appledaily.com.tw/pay/js/minisite/paywall.js
appledaily.com#%#(function(){var b=window.setTimeout;window.setTimeout=function(a,c){if(!/omo_currentuser[\s\S]*?div\.contentblock-block|isOMOureadEnable[\s\S]*?omo_currentuser\.isLoggedIn/.test(a.toString()))return b(a,c)};})();
appledaily.com#%#AG_setConstant('paywall', 'noopFunc');
appledaily.com#$#.ndAritcle_headPic,.ndArticle_margin,.mediabox,#playerVideo,.articulum { display: block!important; }
!+ NOT_PLATFORM(ext_safari)
||img.appledaily.com.tw/pay/js/paywall.*.js

I'm not sure if the news website will update paywall scripts again next week. I suggest to try now.

Please enable AG Annoyances filter or even manually add those rules into the user filter of AG Browser Extension v3.0.13. Click any news on that website. ex: Taiwan website: https://tw.news.appledaily.com/international/realtime/20190411/1548615/

Hong Kong website: https://hk.video.appledaily.com/actionnews/international/20190420/20660328/20198351

You'll find #%# modifier works on Chrome but fails on Firefox. Remember to use desktop mode if using Firefox on Android. Or simply try desktop browsers on PC.

lancelot-moon commented 5 years ago

@AdamWr

The rule also doesn't work on Firefox for its Hong Kong website. Hong Kong page: https://hk.video.appledaily.com/actionnews/international/20190420/20660328/20198351

appledaily.com#%#(function(){var b=window.setTimeout;window.setTimeout=function(a,c){if(!/omo_currentuser[\s\S]*?div\.contentblock-block|isOMOureadEnable[\s\S]*?omo_currentuser\.isLoggedIn/.test(a.toString()))return b(a,c)};})();

scriptlet?? Does AG Browser Extension v3.0.13 start to support it?

Advanced rule syntax are so complex. May you add other alternate rules for Firefox? Thanks, AdamWr.

ameshkov commented 5 years ago

These rules work okay for me in FF

ameshkov commented 5 years ago

Does AG Browser Extension v3.0.13 start to support it?

It does support scriptlets, but it's experimental so we don't use them in the filters yet.

lancelot-moon commented 5 years ago

Firefox for Android (desktop mode) + AG Annoyances filter. Ask to login.

Screenshot: ![image](https://i.imgur.com/v47LlKp.png)

ameshkov commented 5 years ago

Maybe the issue is specific to mobile FF. What about desktop?

lancelot-moon commented 5 years ago

Maybe the issue is specific to mobile FF. What about desktop?

It's the same result for Firefox on PC. The warning of paywall will appear. I had tested on my family's PC. I don't install Firefox on my NB.

How did you test? Test on PC?

ameshkov commented 5 years ago

How did you test? Test on PC?

Yes, I've just added these rules from above to the user filter.

lancelot-moon commented 5 years ago

May you delete the rules from user filter? Simply test with AG Annoyances filter on Chrome and Firefox?

Well, I should not be lazy. I go to add rules in user filter and then reproduce for the screenshot. Wait.

ameshkov commented 5 years ago

Annoyances filter will work after the FF extension update.

As I've said, JS rules require the extension update to start working.

lancelot-moon commented 5 years ago

@ameshkov

You said that #%# modifier can work in the user filter. No, it's still failed with Firefox on PC even if manually adding them in the user filter.

Screenshots: ![image](https://i.imgur.com/MYsB2au.png) ![image](https://i.imgur.com/xL1UHSk.png)

ameshkov commented 5 years ago

Everything works okay in my case. Check the browser console for any unexpected errors.

AdamWr commented 5 years ago

I checked it on desktop with Firefox extension and I added this rule to user filter: appledaily.com#%#AG_setConstant('paywall', 'noopFunc'); it doesn't work and in console I see: ReferenceError: paywall is not defined but with scriptlet it works fine. https://tw.news.appledaily.com/international/realtime/20190411/1548615/


This rule also doesn't work on my end too:

appledaily.com#%#(function(){var b=window.setTimeout;window.setTimeout=function(a,c){if(!/omo_currentuser[\s\S]*?div\.contentblock-block|isOMOureadEnable[\s\S]*?omo_currentuser\.isLoggedIn/.test(a.toString()))return b(a,c)};})();

but this works:

appledaily.com#%#//scriptlet("prevent-setTimeout", "/omo_currentuser[\s\S]*?div\.contentblock-block|isOMOureadEnable[\s\S]*?omo_currentuser\.isLoggedIn/")

https://hk.video.appledaily.com/actionnews/international/20190420/20660328/20198351

lancelot-moon commented 5 years ago

Thank AdamWr for reproducing and proving. I'm not professional for what you wish from console. Hope you can find where the problem is. B/R

AdamWr commented 5 years ago

It seems that problem is caused by AdGuard Annoyances filter. If I disable it then rules added to user filter work fine.

ameshkov commented 5 years ago

Maybe one of the JS rules from there are messing things up?

lancelot-moon commented 5 years ago

I also enabled AdGuard Annoyances filter in my test.

  1. Can the 2 scriptlet rules work for Firefox if adding them into AdGuard Annoyances filter? Or do scriptlet only work in the user filter now?

  2. Why does #%# modifier already work for Chrome in v3.0.13 but need to wait for the next version of AG Browser Extension for Firefox?

ameshkov commented 5 years ago
  1. Can the 2 scriptlet rules work for Firefox if adding them into AdGuard Annoyances filter? Or do scriptlet only work in the user filter now?

Depends on the specific case.

Why does #%# modifier already work for Chrome in v3.0.13 but need to wait for the next version of AG Browser Extension for Firefox?

This is AMO limitation.

AdamWr commented 5 years ago

Maybe one of the JS rules from there are messing things up?

I'm not sure, but it looks like the problem is with added rules for appledaily.com. I mean that if I add exactly the same rules - not work, but it works if I modify them, for example:

appledaily.com#%#AG_setConstant('paywall', 'trueFunc');
appledaily.com#%#(function(){var b=window.setTimeout;window.setTimeout=function(a,c){if(!/mo_currentuser[\s\S]*?div\.contentblock-block|isOMOureadEnable[\s\S]*?omo_currentuser\.isLoggedIn/.test(a.toString()))return b(a,c)};})();
ameshkov commented 5 years ago

Well, that's another reason why we need scriptlets more than ever, JS rules in FF are a mess