Fix type in variable name

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2570
This commit is contained in:
Raymond Hill 2023-03-30 20:46:44 -04:00
parent a7c479083f
commit b5d78a07bf
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 12 additions and 8 deletions

View File

@ -23,7 +23,7 @@
*/ */
// Externally added to the private namespace in which scriptlets execute. // Externally added to the private namespace in which scriptlets execute.
/* global sriptletGlobals */ /* global scriptletGlobals */
'use strict'; 'use strict';
@ -42,15 +42,15 @@ builtinScriptlets.push({
fn: safeSelf, fn: safeSelf,
}); });
function safeSelf() { function safeSelf() {
if ( sriptletGlobals.has('safeSelf') ) { if ( scriptletGlobals.has('safeSelf') ) {
return sriptletGlobals.get('safeSelf'); return scriptletGlobals.get('safeSelf');
} }
const safe = { const safe = {
'RegExp': self.RegExp, 'RegExp': self.RegExp,
'RegExp_test': self.RegExp.prototype.test, 'RegExp_test': self.RegExp.prototype.test,
'RegExp_exec': self.RegExp.prototype.exec, 'RegExp_exec': self.RegExp.prototype.exec,
}; };
sriptletGlobals.set('safeSelf', safe); scriptletGlobals.set('safeSelf', safe);
return safe; return safe;
} }
@ -110,10 +110,14 @@ builtinScriptlets.push({
// Issues to mind before changing anything: // Issues to mind before changing anything:
// https://github.com/uBlockOrigin/uBlock-issues/issues/2154 // https://github.com/uBlockOrigin/uBlock-issues/issues/2154
function abortCurrentScript( function abortCurrentScript(
target = '', arg1 = '',
needle = '', arg2 = '',
context = '' arg3 = ''
) { ) {
const details = typeof arg1 !== 'object'
? { target: arg1, needle: arg2, context: arg3 }
: arg1;
const { target, needle, context } = details;
if ( typeof target !== 'string' ) { return; } if ( typeof target !== 'string' ) { return; }
if ( target === '' ) { return; } if ( target === '' ) { return; }
const reNeedle = patternToRegex(needle); const reNeedle = patternToRegex(needle);

View File

@ -393,7 +393,7 @@ scriptletFilteringEngine.retrieve = function(request, options = {}) {
µb.hiddenSettings.debugScriptlets ? 'debugger;' : ';', µb.hiddenSettings.debugScriptlets ? 'debugger;' : ';',
'', '',
// For use by scriptlets to share local data among themselves // For use by scriptlets to share local data among themselves
'const sriptletGlobals = new Map();', 'const scriptletGlobals = new Map();',
'', '',
cacheDetails.code, cacheDetails.code,
'', '',