2023-06-02 21:04:15 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
2023-12-04 17:10:34 +00:00
|
|
|
uBlock Origin Lite - a comprehensive, MV3-compliant content blocker
|
2023-06-02 21:04:15 +00:00
|
|
|
Copyright (C) 2014-present Raymond Hill
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
|
|
|
|
|
|
|
|
Home: https://github.com/gorhill/uBlock
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// ruleset: $rulesetId$
|
|
|
|
|
|
|
|
|
|
// Important!
|
|
|
|
|
// Isolate from global scope
|
|
|
|
|
|
2023-08-11 17:22:25 +00:00
|
|
|
// Start of local scope
|
2025-12-04 17:57:25 +00:00
|
|
|
(function uBOL_scriptlets() {
|
2023-06-02 21:04:15 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
self.$scriptletCode$
|
2023-08-11 17:22:25 +00:00
|
|
|
|
2025-03-07 22:04:02 +00:00
|
|
|
/******************************************************************************/
|
2023-06-02 21:04:15 +00:00
|
|
|
|
2025-03-07 22:04:02 +00:00
|
|
|
const scriptletGlobals = {}; // eslint-disable-line
|
2023-06-02 21:04:15 +00:00
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $scriptletFunctions$ = self.$scriptletFunctions$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $scriptletArgs$ = self.$scriptletArgs$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $scriptletArglists$ = self.$scriptletArglists$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $scriptletArglistRefs$ = self.$scriptletArglistRefs$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $scriptletHostnames$ = self.$scriptletHostnames$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
2025-12-25 17:34:21 +00:00
|
|
|
const $scriptletFromRegexes$ = self.$scriptletFromRegexes$;
|
|
|
|
|
|
2025-12-05 13:54:34 +00:00
|
|
|
const $hasEntities$ = self.$hasEntities$;
|
|
|
|
|
const $hasAncestors$ = self.$hasAncestors$;
|
2025-12-25 17:34:21 +00:00
|
|
|
const $hasRegexes$ = self.$hasRegexes$;
|
2025-12-04 17:57:25 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2023-06-02 21:04:15 +00:00
|
|
|
|
2025-03-07 22:04:02 +00:00
|
|
|
const entries = (( ) => {
|
|
|
|
|
const docloc = document.location;
|
|
|
|
|
const origins = [ docloc.origin ];
|
|
|
|
|
if ( docloc.ancestorOrigins ) {
|
|
|
|
|
origins.push(...docloc.ancestorOrigins);
|
|
|
|
|
}
|
|
|
|
|
return origins.map((origin, i) => {
|
2025-12-04 17:57:25 +00:00
|
|
|
const beg = origin.indexOf('://');
|
2025-03-07 22:04:02 +00:00
|
|
|
if ( beg === -1 ) { return; }
|
2025-12-04 17:57:25 +00:00
|
|
|
const hn1 = origin.slice(beg+3)
|
|
|
|
|
const end = hn1.indexOf(':');
|
|
|
|
|
const hn2 = end === -1 ? hn1 : hn1.slice(0, end);
|
|
|
|
|
const hnParts = hn2.split('.');
|
|
|
|
|
if ( hn2.length === 0 ) { return; }
|
|
|
|
|
const hns = [];
|
|
|
|
|
for ( let i = 0; i < hnParts.length; i++ ) {
|
|
|
|
|
hns.push(`${hnParts.slice(i).join('.')}`);
|
|
|
|
|
}
|
|
|
|
|
const ens = [];
|
|
|
|
|
if ( $hasEntities$ ) {
|
|
|
|
|
const n = hnParts.length - 1;
|
|
|
|
|
for ( let i = 0; i < n; i++ ) {
|
|
|
|
|
for ( let j = n; j > i; j-- ) {
|
|
|
|
|
ens.push(`${hnParts.slice(i,j).join('.')}.*`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ens.sort((a, b) => {
|
|
|
|
|
const d = b.length - a.length;
|
|
|
|
|
if ( d !== 0 ) { return d; }
|
|
|
|
|
return a > b ? -1 : 1;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return { hns, ens, i };
|
2025-03-07 22:04:02 +00:00
|
|
|
}).filter(a => a !== undefined);
|
|
|
|
|
})();
|
|
|
|
|
if ( entries.length === 0 ) { return; }
|
|
|
|
|
|
2025-12-04 17:57:25 +00:00
|
|
|
const collectArglistRefIndices = (out, hn, r) => {
|
|
|
|
|
let l = 0, i = 0, d = 0;
|
|
|
|
|
let candidate = '';
|
|
|
|
|
while ( l < r ) {
|
|
|
|
|
i = l + r >>> 1;
|
|
|
|
|
candidate = $scriptletHostnames$[i];
|
|
|
|
|
d = hn.length - candidate.length;
|
|
|
|
|
if ( d === 0 ) {
|
|
|
|
|
if ( hn === candidate ) {
|
|
|
|
|
out.add(i); break;
|
|
|
|
|
}
|
|
|
|
|
d = hn < candidate ? -1 : 1;
|
|
|
|
|
}
|
|
|
|
|
if ( d < 0 ) {
|
|
|
|
|
r = i;
|
|
|
|
|
} else {
|
|
|
|
|
l = i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const indicesFromHostname = (out, hnDetails, suffix = '') => {
|
|
|
|
|
if ( hnDetails.hns.length === 0 ) { return; }
|
|
|
|
|
let r = $scriptletHostnames$.length;
|
|
|
|
|
for ( const hn of hnDetails.hns ) {
|
|
|
|
|
r = collectArglistRefIndices(out, `${hn}${suffix}`, r);
|
|
|
|
|
}
|
|
|
|
|
if ( $hasEntities$ ) {
|
|
|
|
|
let r = $scriptletHostnames$.length;
|
|
|
|
|
for ( const en of hnDetails.ens ) {
|
|
|
|
|
r = collectArglistRefIndices(out, `${en}${suffix}`, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-03-07 22:04:02 +00:00
|
|
|
|
2025-12-04 17:57:25 +00:00
|
|
|
const todoIndices = new Set();
|
|
|
|
|
indicesFromHostname(todoIndices, entries[0]);
|
|
|
|
|
if ( $hasAncestors$ ) {
|
2025-03-07 22:04:02 +00:00
|
|
|
for ( const entry of entries ) {
|
|
|
|
|
if ( entry.i === 0 ) { continue; }
|
2025-12-04 17:57:25 +00:00
|
|
|
indicesFromHostname(todoIndices, entry, '>>');
|
2023-06-02 21:04:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-04 17:57:25 +00:00
|
|
|
$scriptletHostnames$.length = 0;
|
2023-06-02 21:04:15 +00:00
|
|
|
|
2025-12-04 17:57:25 +00:00
|
|
|
// Collect arglist references
|
|
|
|
|
const todo = new Set();
|
2025-12-25 17:34:21 +00:00
|
|
|
if ( todoIndices.size !== 0 ) {
|
2025-12-04 17:57:25 +00:00
|
|
|
const arglistRefs = $scriptletArglistRefs$.split(';');
|
|
|
|
|
for ( const i of todoIndices ) {
|
|
|
|
|
for ( const ref of JSON.parse(`[${arglistRefs[i]}]`) ) {
|
|
|
|
|
todo.add(ref);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-25 17:34:21 +00:00
|
|
|
if ( $hasRegexes$ ) {
|
|
|
|
|
const { hns } = entries[0];
|
2025-12-27 14:45:25 +00:00
|
|
|
for ( let i = 0, n = $scriptletFromRegexes$.length; i < n; i += 3 ) {
|
|
|
|
|
const needle = $scriptletFromRegexes$[i+0];
|
|
|
|
|
let regex;
|
2025-12-25 17:34:21 +00:00
|
|
|
for ( const hn of hns ) {
|
2025-12-27 14:45:25 +00:00
|
|
|
if ( hn.includes(needle) === false ) { continue; }
|
|
|
|
|
if ( regex === undefined ) {
|
|
|
|
|
regex = new RegExp($scriptletFromRegexes$[i+1]);
|
|
|
|
|
}
|
2025-12-25 17:34:21 +00:00
|
|
|
if ( regex.test(hn) === false ) { continue; }
|
2025-12-27 14:45:25 +00:00
|
|
|
for ( const ref of JSON.parse(`[${$scriptletFromRegexes$[i+2]}]`) ) {
|
2025-12-25 17:34:21 +00:00
|
|
|
todo.add(ref);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( todo.size === 0 ) { return; }
|
2025-12-04 17:57:25 +00:00
|
|
|
|
|
|
|
|
// Execute scriplets
|
|
|
|
|
{
|
|
|
|
|
const arglists = $scriptletArglists$.split(';');
|
2025-12-05 13:54:34 +00:00
|
|
|
const args = $scriptletArgs$;
|
2025-12-04 17:57:25 +00:00
|
|
|
for ( const ref of todo ) {
|
|
|
|
|
if ( ref < 0 ) { continue; }
|
|
|
|
|
if ( todo.has(~ref) ) { continue; }
|
|
|
|
|
const arglist = JSON.parse(`[${arglists[ref]}]`);
|
|
|
|
|
const fn = $scriptletFunctions$[arglist[0]];
|
|
|
|
|
try { fn(...arglist.slice(1).map(a => args[a])); }
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
2023-06-02 21:04:15 +00:00
|
|
|
}
|
2023-08-11 17:22:25 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// End of local scope
|
2023-06-02 21:04:15 +00:00
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
void 0;
|