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

Support new set-constant scriptlet values of AdGuard #2615

Closed
piquark6046 opened this issue Apr 27, 2023 · 8 comments
Closed

Support new set-constant scriptlet values of AdGuard #2615

piquark6046 opened this issue Apr 27, 2023 · 8 comments
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@piquark6046
Copy link
Member

piquark6046 commented Apr 27, 2023

Description

The following values are not supported in uBO:

  • noopCallbackFunc
  • throwFunc
  • noopPromiseResolve
  • noopPromiseReject
  • -1
  • yes
  • no

https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#set-constant

uBO version

1.49.0

Browser name and version

Mozilla Firefox Developer Edition 113.0b8

Operating System and version

Ubuntu 23.04

@gorhill
Copy link
Member

gorhill commented Apr 27, 2023

I am not seeing instances of set-constant filters using these values. Can I get a sense of usage stats for these?

@gwarser gwarser added the enhancement New feature or request label Apr 27, 2023
@gorhill
Copy link
Member

gorhill commented May 12, 2023

I want to use a different approach than AdGuard. Instead of introducing new values (noopCallbackFunc, noopPromiseResolve, etc.), I want to introduce new ways to return currently supported values. Examples:

...##+js(set, property, value)
...##+js(set, property, value, asCallback)
...##+js(set, property, value, asResolved)
...##+js(set, property, value, asRejected)
  • The first one behaves as expected: property is set to value
  • The second one would return a function which returns value
  • The third one returns a Promise which resolves to value
  • The fourth one returns a Promise which fails with value

Now I need real world cases where these can be tested.

@piquark6046
Copy link
Member Author

@ameshkov Please take a look.

@ameshkov
Copy link

Good stuff

@gwarser

This comment was marked as outdated.

gorhill added a commit to gorhill/uBlock that referenced this issue May 19, 2023
Related issue:
- uBlockOrigin/uBlock-issues#2615

Expand `set-constant`: 3rd parameter and beyond are tokens which
modify the behavior of `set-contant`. Valid tokens:

- `interactive`, `end`, `2`: set the constant when the event
  `DOMContentInteractive` is fired.
- `complete`, `idle`, `3`: set the constant when the event
  `load` is fired.
- `asFunction`: the constant will be a function returning the
  specified value.
- `asCallback`: the constant will be a function returning a
  function returning the specified value.
- `asResolved`: the constant will be a promise resolving to
  the specified value.
- `asRejected`: the constant will be a promise failing with
  the specified value.

Harden `no-setimeout-if` and `no-setinterval-if` as per feedback
from filter list maintainers.
@uBlock-user uBlock-user added the fixed issue has been addressed label Jun 4, 2023
stephenhawk8054 referenced this issue in uBlockOrigin/uAssets Jul 26, 2023
@stephenhawk8054
Copy link
Member

stephenhawk8054 commented Jul 1, 2024

@gorhill I just realized I don't see the options as (asCallback, asResolved...) in the current code: https://github.com/gorhill/uBlock/blob/master/assets/resources/scriptlets.js . Were they not transferred when switching to vararg approach?

@garry-ut99
Copy link

garry-ut99 commented Jul 1, 2024

Names have been changed in gorhill/uBlock@f407c28 to:

 ..., as, function
 ..., as, callback
 ..., as, resolved
 ..., as, rejected

From commit description :

Related issue: #2783

Missed mentioning the current issue #2615 as related (as the names have been altered).
Btw Wiki also requires update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

7 participants