Skip to content

Commit

Permalink
Skip testing context when none present in acis scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 24, 2022
1 parent 8669893 commit 9d81b7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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));
}
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit 9d81b7c

Please sign in to comment.