Support AdGuard's `[trusted-]set-cookie-reload` scriptlets

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2881
This commit is contained in:
Raymond Hill 2023-10-18 09:48:08 -04:00
parent 5bd40b34cd
commit 9d3acd91b8
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 29 additions and 1 deletions

View File

@ -3395,6 +3395,19 @@ function setCookie(
);
}
// For compatiblity with AdGuard
builtinScriptlets.push({
name: 'set-cookie-reload.js',
fn: setCookieReload,
world: 'ISOLATED',
dependencies: [
'set-cookie.js',
],
});
function setCookieReload(name, value, path, ...args) {
setCookie(name, value, path, 'reload', '1', ...args);
}
/*******************************************************************************
*
* set-local-storage-item.js
@ -3773,6 +3786,20 @@ function trustedSetCookie(
);
}
// For compatiblity with AdGuard
builtinScriptlets.push({
name: 'trusted-set-cookie-reload.js',
requiresTrust: true,
fn: trustedSetCookieReload,
world: 'ISOLATED',
dependencies: [
'trusted-set-cookie.js',
],
});
function trustedSetCookieReload(name, value, offsetExpiresSec, path, ...args) {
trustedSetCookie(name, value, offsetExpiresSec, path, 'reload', '1', ...args);
}
/*******************************************************************************
*
* trusted-set-local-storage-item.js

View File

@ -234,7 +234,8 @@ const lookupScriptlet = function(rawToken, mainMap, isolatedMap) {
while ( dependencies.length !== 0 ) {
const token = dependencies.shift();
if ( targetWorldMap.has(token) ) { continue; }
const details = reng.contentFromName(token, 'fn/javascript');
const details = reng.contentFromName(token, 'fn/javascript') ||
reng.contentFromName(token, 'text/javascript');
if ( details === undefined ) { continue; }
targetWorldMap.set(token, details.js);
if ( Array.isArray(details.dependencies) === false ) { continue; }