1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-28 21:57:12 +02: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"
},
"manifest_version": 3,
"minimum_chrome_version": "118.0",
"minimum_chrome_version": "119.0",
"name": "__MSG_extName__",
"options_page": "dashboard.html",
"optional_host_permissions": [

View File

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

View File

@ -20,11 +20,9 @@
*/
/* jshint esversion:11 */
/* eslint-disable indent */
/* global cloneInto */
'use strict';
// ruleset: $rulesetId$
/******************************************************************************/
@ -40,7 +38,7 @@
// Start of code to inject
const uBOL_$scriptletName$ = function() {
const scriptletGlobals = {}; // jshint ignore: line
const scriptletGlobals = {}; // eslint-disable-line
const argsList = self.$argsList$;
@ -57,7 +55,19 @@ function $scriptletName$(){}
/******************************************************************************/
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) { }
const hnpartslen = hnParts.length;
if ( hnpartslen === 0 ) { return; }