1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-16 15:33:38 +01:00

[mv3] Fix injection of scriptlets into embedded contexts

This commit is contained in:
Raymond Hill 2024-08-20 08:18:03 -04:00
parent 24756e8340
commit 520f81fcca
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 17 additions and 6 deletions

View File

@ -25,7 +25,7 @@
"128": "img/icon_128.png" "128": "img/icon_128.png"
}, },
"manifest_version": 3, "manifest_version": 3,
"minimum_chrome_version": "118.0", "minimum_chrome_version": "119.0",
"name": "__MSG_extName__", "name": "__MSG_extName__",
"options_page": "dashboard.html", "options_page": "dashboard.html",
"optional_host_permissions": [ "optional_host_permissions": [

View File

@ -473,6 +473,7 @@ function registerScriptlet(context, scriptletDetails) {
// `MAIN` world not yet supported in Firefox // `MAIN` world not yet supported in Firefox
if ( isGecko === false ) { if ( isGecko === false ) {
directive.world = 'MAIN'; directive.world = 'MAIN';
directive.matchOriginAsFallback = true;
} }
// register // register

View File

@ -20,11 +20,9 @@
*/ */
/* jshint esversion:11 */ /* eslint-disable indent */
/* global cloneInto */ /* global cloneInto */
'use strict';
// ruleset: $rulesetId$ // ruleset: $rulesetId$
/******************************************************************************/ /******************************************************************************/
@ -40,7 +38,7 @@
// Start of code to inject // Start of code to inject
const uBOL_$scriptletName$ = function() { const uBOL_$scriptletName$ = function() {
const scriptletGlobals = {}; // jshint ignore: line const scriptletGlobals = {}; // eslint-disable-line
const argsList = self.$argsList$; const argsList = self.$argsList$;
@ -57,7 +55,19 @@ function $scriptletName$(){}
/******************************************************************************/ /******************************************************************************/
const hnParts = []; const hnParts = [];
try { hnParts.push(...document.location.hostname.split('.')); } try {
let origin = document.location.origin;
if ( origin === 'null' ) {
const origins = document.location.ancestorOrigins;
for ( let i = 0; i < origins.length; i++ ) {
origin = origins[i];
if ( origin !== 'null' ) { break; }
}
}
const pos = origin.lastIndexOf('://');
if ( pos === -1 ) { return; }
hnParts.push(...origin.slice(pos+3).split('.'));
}
catch(ex) { } catch(ex) { }
const hnpartslen = hnParts.length; const hnpartslen = hnParts.length;
if ( hnpartslen === 0 ) { return; } if ( hnpartslen === 0 ) { return; }