Skip to content

Navigation Menu

Sign in
Sign up

Improve 'trusted-replace-argument' — add new constant values #562

Open
Assignees

Description

Related to AdguardTeam/AdguardFilters#232621

Steps to reproduce:

  1. Add to user rules:
example.org#%#//scriptlet('trusted-replace-argument', 'Promise', '0', 'noopPromiseResolve', 'isDetected')
  1. Navigate to https://example.org/
  2. In browser console run:
(async () => {
 const checkAdblock = () => {
 console.log('Checking for adblock...');
 return new Promise((resolve) => {
 // Set to true by default for demonstration purposes
 const isDetected = true;
 resolve(isDetected);
 });
 };
 const init = async () => {
 const [result] = await Promise.all([
 checkAdblock(),
 ]);
 if (result) {
 console.log('Adblock detected');
 return;
 }
 console.log('Load content');
 }
 await init();
 console.log('Script loaded');
})();

With current solution only Checking for adblock... is printed in console (the same fornoopCallbackFunc, noopFunc, falseFunc).
Expected is:

Checking for adblock...
Load content
Script loaded

So, I think we could add functions which return callback with false/true, something like:

const falseCallbackFunc = (callback) => { callback(false); };
const trueCallbackFunc = (callback) => { callback(true); };

And/Or we could add support for valueWrapper similar like in https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#set-constant

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    AltStyle によって変換されたページ (->オリジナル) /