-
Notifications
You must be signed in to change notification settings - Fork 27
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
Improve "set-constant" scriptlet #65
Comments
|
Using |
A brief comment on this: set-constant now creates configurable property, and in this case, it is possible to "chain" property calls. This does solve the immediate issue but makes it possible for page scripts to override this property on its own. We should keep an eye on what websites do with this. |
I'm not sure if it's related to this problem, but it seems that using Example code: var test = {};
delete window.test;
var test = {
number: 999,
boolean: true
}; Test page - https://adamwr.github.io/test-page/delete.html There is a |
It bothers me that this task takes that much time to solve, there are already quite a lot of places in the filters where we need this behavior. If it does not fit into the current @slavaleleka @maximtop guys, what do you think about that? |
Values can be used instead of setters and getters if we do not need any checks when someone tries to change this "constant". |
From @ameshkov: (19 Aug 2020)
↪️ The bold part is a no-no for me. Too risky and problematic over time, even for the follow-up of its own commits over time … Especially for large websites that can easily afford to quickly counter. 😕 |
For info/context, it would have been useful to me recently: ✌️ Read more (updated) …In this case, to have:
instead of: ! TODO: Change AG_defineProperty to scriptlet when this issue will be fixed - https://github.com/AdguardTeam/Scriptlets/issues/65
tf1.fr#%#AG_defineProperty('tv.freewheel.SDK.Util.pingURLWithForm', { get: function() { return function() {return true;}; } });
tf1.fr#%#AG_defineProperty('tv.freewheel.SDK.Util.pingURLWithImage', { get: function() { return function() {return true;}; } });
tf1.fr#%#AG_defineProperty('tv.freewheel.SDK.Util.pingURLWithScript', { get: function() { return function() {return true;}; } });
tf1.fr#%#AG_defineProperty('tv.freewheel.SDK.Util.pingURLWithXMLHTTPRequest', { get: function() { return function() {return true;}; } });
tf1.fr#%#AG_defineProperty('tv.freewheel.SDK.Util.sendAdRequestWithXMLHTTPRequest', { get: function() { return function() {return true;}; } });
ℹ️ Also, I'm facing a similar situation for one of my future PRs. | EDIT: this one. |
Merge in ADGUARD-FILTERS/scriptlets from fix/AG-149 to release/v1.6 Squashed commit of the following: commit ff551dc Merge: fe099c9 9d4d229 Author: Stanislav A <s.atroschenko@adguard.com> Date: Tue Mar 15 15:50:54 2022 +0300 Merge branch 'release/v1.6' into fix/AG-149 commit fe099c9 Author: Stanislav A <s.atroschenko@adguard.com> Date: Tue Mar 15 12:48:24 2022 +0300 rename test function commit da26b67 Author: Stanislav A <s.atroschenko@adguard.com> Date: Mon Mar 14 15:19:36 2022 +0300 add configurable & new tests commit 4dd1bfd Author: Stanislav A <s.atroschenko@adguard.com> Date: Fri Mar 11 11:44:43 2022 +0300 add comments & fix typo commit 6529828 Author: Stanislav A <s.atroschenko@adguard.com> Date: Tue Mar 8 21:07:08 2022 +0300 improve set-constant scriptlet commit eb73fa1 Author: Stanislav A <s.atroschenko@adguard.com> Date: Sun Feb 20 22:40:57 2022 +0300 improve set-cosntant scriptlet
* commit 'c06a8e539488e1ebfcf72c85a39a0ef5b9c028bb': (32 commits) AG-13382 update docs, validate noopjson push updated dist to github while release build. AG-13356 remove tagcommander redirect AG-11959 add readme info about testing ad debugging AG-12716 add artifacts to scriptlets builds AG-12487 improve set-constant scriptlet #65 AG-149 improve prevent-xhr scriptlet #199 AG-13007 improve googletagservices-gpt redirect #193 AG-12767 add wcslog redirect #94 AG-3906 improve ati-smarttag redirect #200 AG-13141 improve json-prune scriptlet #171 AG-11879 fix yandex metrika on avito #198 AG-12973 improve metrika-yandex-tag redirect #189 AG-12550 add prebid-ads redirect #190 AG-12558 remove no-floc scriptlet AG-12869 add noopjson redirect. AG-12796 #195 Revert "revert tests and fix converter again" revert tests and fix converter again add conversion test for wildcard tld AG-12636 add prevent-element-src-loading scriptlet #180 AG-12328 ...
…2 to master * commit '84180cec7974246d60fea77c7cb8029dd4f12ac8': Update build after merge Fix test 2 Fix test Update readme fix lint Add tests Redirect: metrika-yandex-tag
For example, if there is a script like this:
and we want to set
test.number
to0
andtest.boolean
tofalse
using scriptlets like:#%#//scriptlet("set-constant", "test.number", "0")
#%#//scriptlet("set-constant", "test.boolean", "false")
then only one of these scriptlets work actually.
Expected behavior - both scriptlets should work.
Test page - https://adamwr.github.io/test-page/index.html
Rules:
adamwr.github.io#%#//scriptlet("set-constant", "test.number", "0")
adamwr.github.io#%#//scriptlet("set-constant", "test.boolean", "false")
Screenshot
The text was updated successfully, but these errors were encountered: