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:
parent
24756e8340
commit
520f81fcca
@ -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": [
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user