mirror of https://github.com/gorhill/uBlock.git
Skip testing context when none present in acis scriptlet
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2154
This commit is contained in:
parent
8669893a4d
commit
9d81b7c4d9
|
@ -36,6 +36,8 @@
|
||||||
/// alias acs.js
|
/// alias acs.js
|
||||||
/// alias abort-current-inline-script.js
|
/// alias abort-current-inline-script.js
|
||||||
/// alias acis.js
|
/// alias acis.js
|
||||||
|
// Issues to mind before changing anything:
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
|
||||||
(function() {
|
(function() {
|
||||||
const target = '{{1}}';
|
const target = '{{1}}';
|
||||||
if ( target === '' || target === '{{1}}' ) { return; }
|
if ( target === '' || target === '{{1}}' ) { return; }
|
||||||
|
@ -50,7 +52,7 @@
|
||||||
})();
|
})();
|
||||||
const context = '{{3}}';
|
const context = '{{3}}';
|
||||||
const reContext = (( ) => {
|
const reContext = (( ) => {
|
||||||
if ( context === '' || context === '{{3}}' ) { return /^$/; }
|
if ( context === '' || context === '{{3}}' ) { return; }
|
||||||
if ( /^\/.+\/$/.test(context) ) {
|
if ( /^\/.+\/$/.test(context) ) {
|
||||||
return new RegExp(context.slice(1,-1));
|
return new RegExp(context.slice(1,-1));
|
||||||
}
|
}
|
||||||
|
@ -102,8 +104,10 @@
|
||||||
const validate = ( ) => {
|
const validate = ( ) => {
|
||||||
const e = document.currentScript;
|
const e = document.currentScript;
|
||||||
if ( e instanceof HTMLScriptElement === false ) { return; }
|
if ( e instanceof HTMLScriptElement === false ) { return; }
|
||||||
if ( reContext.test(e.src) === false ) { return; }
|
|
||||||
if ( e === thisScript ) { return; }
|
if ( e === thisScript ) { return; }
|
||||||
|
if ( reContext !== undefined && reContext.test(e.src) === false ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( reNeedle.test(getScriptText(e)) === false ) { return; }
|
if ( reNeedle.test(getScriptText(e)) === false ) { return; }
|
||||||
throw new ReferenceError(magic);
|
throw new ReferenceError(magic);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue