mirror of https://github.com/gorhill/uBlock.git
Fix/improve scriptlets
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2678 - https://github.com/uBlockOrigin/uAssets/issues/18278
This commit is contained in:
parent
996bf0925d
commit
56e1d92dbd
|
@ -1049,23 +1049,11 @@ function evaldataPrune(
|
|||
) {
|
||||
self.eval = new Proxy(self.eval, {
|
||||
apply(target, thisArg, args) {
|
||||
let dataToEval = `${args[0]}`;
|
||||
const match = /^\s*\(\s*(\{.+\})\s*\)\s*$/s.exec(dataToEval);
|
||||
if ( match !== null ) {
|
||||
dataToEval = match[1];
|
||||
}
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(dataToEval);
|
||||
let data = Reflect.apply(target, thisArg, args);
|
||||
if ( typeof data === 'object' ) {
|
||||
let after = JSON.stringify(
|
||||
objectPrune(data, rawPrunePaths, rawNeedlePaths)
|
||||
);
|
||||
args[0] = `(${after})`;
|
||||
data = objectPrune(data, rawPrunePaths, rawNeedlePaths);
|
||||
}
|
||||
} catch(ex) {
|
||||
}
|
||||
return Reflect.apply(target, thisArg, args);
|
||||
return data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2332,7 +2320,7 @@ function hrefSanitizer(
|
|||
};
|
||||
const extractText = (elem, source) => {
|
||||
if ( /^\[.*\]$/.test(source) ) {
|
||||
return elem.getAttribute(source.slice(1,-1).trim()) || '';
|
||||
source = elem.getAttribute(source.slice(1,-1).trim()) || '';
|
||||
}
|
||||
if ( source !== 'text' ) { return ''; }
|
||||
const text = elem.textContent
|
||||
|
|
Loading…
Reference in New Issue