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 AdGuard set-constant value aliases 'emptyArr' and 'emptyObj' #2411

Closed
8 tasks done
CuervoCarlos opened this issue Dec 15, 2022 · 2 comments
Closed
8 tasks done
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@CuervoCarlos
Copy link

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

AdGuard scriptlets implement different literal value using 'emptyArr' and 'emptyObj' instead of '[]' and '{}' in uBO. Please consider implementing those aliases since uBO is the only out-of-the-box privacy filter featuring scriptlets (and the other being EasyPrivacy which does not manipulate Javascript).

References:
AdG set-constant
uBO set-constant

A specific URL where the issue occurs.

mirrormedia.mg

Steps to Reproduce

Rule *##+js(set, window.test, emptyArr) is not resolved.
Rule *##+js(set, window.test, emptyObj) is not resolved.

Expected behavior

Example AdG grammar:
mirrormedia.mg##+js(set-constant, dataLayer, emptyArr)

should work the same as uBO grammar:
mirrormedia.mg##+js(set-constant, dataLayer, [])

Actual behavior

Rule mirrormedia.mg##+js(set-constant, dataLayer, emptyArr) is not resolved; nothing happens in the logger.

uBO version

1.45.2

Browser name and version

Firefox 102.0

Operating System and version

Windows 10

@gorhill
Copy link
Member

gorhill commented Dec 15, 2022

The filter in original "AdGuard Tracking Protection" list is:

mirrormedia.mg#%#//scriptlet("set-constant", "dataLayer", "emptyArr")

This means it's improperly converted to uBO's syntax. The conversion should be fixed in AdGuard's converter, it's already done for empty string (ref).

@CuervoCarlos CuervoCarlos closed this as not planned Won't fix, can't repro, duplicate, stale Dec 16, 2022
adguard pushed a commit to AdguardTeam/Scriptlets that referenced this issue Dec 16, 2022
fix by @gorhill
uBlockOrigin/uBlock-issues#2411

* commit '993c7648279c7c6c7eb7ee8f3ef92724fe584651':
  add related issue link to changelog
  update changelog
  add few simple tests
  fix converter comments
  fix readme
  Fix converter for uBO's `[]`/`{}` in `set-constant` scriptlet
adguard pushed a commit to AdguardTeam/FiltersCompiler that referenced this issue Dec 19, 2022
related: uBlockOrigin/uBlock-issues#2411

Squashed commit of the following:

commit a77002f
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Dec 16 21:55:31 2022 +0200

    update changelog

commit 786830f
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Dec 16 21:54:48 2022 +0200

    fix changelog style

commit da136a6
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Dec 16 21:52:48 2022 +0200

    update scriptlets to v1.7.14, tsurlfilter to v1.0.64

commit 5a4676b
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Dec 16 21:51:42 2022 +0200

    add few scrpitlets conversion tests
@superlex
Copy link

superlex commented Nov 16, 2023

@gorhill
I assume the same goes for set-local-storage-item / set-session-storage-item .

This is the result of

example.org#%#//scriptlet('set-local-storage-item', 'ag_obj', 'emptyObj')
example.org#%#//scriptlet('set-local-storage-item', 'ag_arr', 'emptyArr')
example.org#%#//scriptlet('set-local-storage-item', 'ag_str', '')
example.org##+js(set-local-storage-item, u_obj, {})
example.org##+js(set-local-storage-item, u_arr, [])
example.org##+js(set-local-storage-item, u_str, '')
dd

References:
https://github.com/gorhill/uBlock/wiki/Resources-Library#set-local-storage-itemjs-
https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#set-local-storage-item
https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#set-session-storage-item

PS:
Let me know if you prefer I open a new issue and/or you need additional information.

gorhill added a commit to gorhill/uBlock that referenced this issue Nov 17, 2023
@gwarser gwarser added enhancement New feature or request fixed issue has been addressed labels Nov 17, 2023
@gwarser gwarser closed this as completed Nov 17, 2023
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

4 participants