mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-26 04:12:50 +01:00
parent
fea92ac110
commit
3668445679
@ -203,17 +203,28 @@ function safeSelf() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
builtinScriptlets.push({
|
builtinScriptlets.push({
|
||||||
name: 'get-exception-token.fn',
|
name: 'get-random-token.fn',
|
||||||
fn: getExceptionToken,
|
fn: getRandomToken,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
'safe-self.fn',
|
'safe-self.fn',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
function getExceptionToken() {
|
function getRandomToken() {
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const token =
|
return safe.String_fromCharCode(Date.now() % 26 + 97) +
|
||||||
safe.String_fromCharCode(Date.now() % 26 + 97) +
|
|
||||||
safe.Math_floor(safe.Math_random() * 982451653 + 982451653).toString(36);
|
safe.Math_floor(safe.Math_random() * 982451653 + 982451653).toString(36);
|
||||||
|
}
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
builtinScriptlets.push({
|
||||||
|
name: 'get-exception-token.fn',
|
||||||
|
fn: getExceptionToken,
|
||||||
|
dependencies: [
|
||||||
|
'get-random-token.fn',
|
||||||
|
],
|
||||||
|
});
|
||||||
|
function getExceptionToken() {
|
||||||
|
const token = getRandomToken();
|
||||||
const oe = self.onerror;
|
const oe = self.onerror;
|
||||||
self.onerror = function(msg, ...args) {
|
self.onerror = function(msg, ...args) {
|
||||||
if ( typeof msg === 'string' && msg.includes(token) ) { return true; }
|
if ( typeof msg === 'string' && msg.includes(token) ) { return true; }
|
||||||
@ -701,6 +712,7 @@ builtinScriptlets.push({
|
|||||||
name: 'replace-node-text.fn',
|
name: 'replace-node-text.fn',
|
||||||
fn: replaceNodeTextFn,
|
fn: replaceNodeTextFn,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
|
'get-random-token.fn',
|
||||||
'run-at.fn',
|
'run-at.fn',
|
||||||
'safe-self.fn',
|
'safe-self.fn',
|
||||||
],
|
],
|
||||||
@ -736,7 +748,7 @@ function replaceNodeTextFn(
|
|||||||
if ( tt instanceof Object ) {
|
if ( tt instanceof Object ) {
|
||||||
if ( typeof tt.getPropertyType === 'function' ) {
|
if ( typeof tt.getPropertyType === 'function' ) {
|
||||||
if ( tt.getPropertyType('script', 'textContent') === 'TrustedScript' ) {
|
if ( tt.getPropertyType('script', 'textContent') === 'TrustedScript' ) {
|
||||||
return tt.createPolicy('uBO', out);
|
return tt.createPolicy(getRandomToken(), out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user