Skip testing context when none present in acis scriptlet

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2154
This commit is contained in:
Raymond Hill 2022-06-24 13:35:20 -04:00
parent 8669893a4d
commit 9d81b7c4d9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 6 additions and 2 deletions

View File

@ -36,6 +36,8 @@
/// alias acs.js
/// alias abort-current-inline-script.js
/// alias acis.js
// Issues to mind before changing anything:
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154
(function() {
const target = '{{1}}';
if ( target === '' || target === '{{1}}' ) { return; }
@ -50,7 +52,7 @@
})();
const context = '{{3}}';
const reContext = (( ) => {
if ( context === '' || context === '{{3}}' ) { return /^$/; }
if ( context === '' || context === '{{3}}' ) { return; }
if ( /^\/.+\/$/.test(context) ) {
return new RegExp(context.slice(1,-1));
}
@ -102,8 +104,10 @@
const validate = ( ) => {
const e = document.currentScript;
if ( e instanceof HTMLScriptElement === false ) { return; }
if ( reContext.test(e.src) === false ) { return; }
if ( e === thisScript ) { return; }
if ( reContext !== undefined && reContext.test(e.src) === false ) {
return;
}
if ( reNeedle.test(getScriptText(e)) === false ) { return; }
throw new ReferenceError(magic);
};