summaryrefslogtreecommitdiffstats
path: root/src/js/scriptlets
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
commit55a5d29a66503248916f249ad2a1d8b37cde5a03 (patch)
treea3beb6a90dd3bdaaf67ecb05d42152a494aff946 /src/js/scriptlets
parentAdding upstream version 1.55.0+dfsg. (diff)
downloadublock-origin-upstream/1.57.0+dfsg.tar.xz
ublock-origin-upstream/1.57.0+dfsg.zip
Adding upstream version 1.57.0+dfsg.upstream/1.57.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/js/scriptlets')
-rw-r--r--src/js/scriptlets/epicker.js45
-rw-r--r--src/js/scriptlets/scriptlet-loglevel-1.js49
-rw-r--r--src/js/scriptlets/scriptlet-loglevel-2.js49
-rw-r--r--src/js/scriptlets/should-inject-contentscript.js2
4 files changed, 126 insertions, 19 deletions
diff --git a/src/js/scriptlets/epicker.js b/src/js/scriptlets/epicker.js
index 80489e8..41b0b76 100644
--- a/src/js/scriptlets/epicker.js
+++ b/src/js/scriptlets/epicker.js
@@ -619,6 +619,21 @@ const filterToDOMInterface = (( ) => {
const reCaret = '(?:[^%.0-9a-z_-]|$)';
const rePseudoElements = /:(?::?after|:?before|:[a-z-]+)$/;
+ const matchElemToRegex = (elem, re) => {
+ const srcProp = netFilter1stSources[elem.localName];
+ let src = elem[srcProp];
+ if ( src instanceof SVGAnimatedString ) {
+ src = src.baseVal;
+ }
+ if ( typeof src === 'string' && /^https?:\/\//.test(src) ) {
+ if ( re.test(src) ) { return srcProp; }
+ }
+ src = elem.currentSrc;
+ if ( typeof src === 'string' && /^https?:\/\//.test(src) ) {
+ if ( re.test(src) ) { return srcProp; }
+ }
+ };
+
// Net filters: we need to lookup manually -- translating into a foolproof
// CSS selector is just not possible.
//
@@ -672,28 +687,21 @@ const filterToDOMInterface = (( ) => {
// Lookup by tag names.
// https://github.com/uBlockOrigin/uBlock-issues/issues/2260
// Maybe get to the actual URL indirectly.
+ //
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/3142
+ // Don't try to match against non-network URIs.
const elems = document.querySelectorAll(
Object.keys(netFilter1stSources).join()
);
for ( const elem of elems ) {
- const srcProp = netFilter1stSources[elem.localName];
- let src = elem[srcProp];
- if ( src instanceof SVGAnimatedString ) {
- src = src.baseVal;
- }
- if (
- typeof src === 'string' &&
- reFilter.test(src) ||
- typeof elem.currentSrc === 'string' &&
- reFilter.test(elem.currentSrc)
- ) {
- out.push({
- elem,
- src: srcProp,
- opt: filterTypes[elem.localName],
- style: vAPI.hideStyle,
- });
- }
+ const srcProp = matchElemToRegex(elem, reFilter);
+ if ( srcProp === undefined ) { continue; }
+ out.push({
+ elem,
+ src: srcProp,
+ opt: filterTypes[elem.localName],
+ style: vAPI.hideStyle,
+ });
}
// Find matching background image in current set of candidate elements.
@@ -1247,6 +1255,7 @@ const pickerCSSStyle = [
'display: block',
'filter: none',
'height: 100vh',
+ ' height: 100svh',
'left: 0',
'margin: 0',
'max-height: none',
diff --git a/src/js/scriptlets/scriptlet-loglevel-1.js b/src/js/scriptlets/scriptlet-loglevel-1.js
new file mode 100644
index 0000000..bc5f4bb
--- /dev/null
+++ b/src/js/scriptlets/scriptlet-loglevel-1.js
@@ -0,0 +1,49 @@
+/*******************************************************************************
+
+ uBlock Origin - a comprehensive, efficient content blocker
+ Copyright (C) 2024-present Raymond Hill
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see {http://www.gnu.org/licenses/}.
+
+ Home: https://github.com/gorhill/uBlock
+*/
+
+'use strict';
+
+/******************************************************************************/
+
+(( ) => {
+ if ( self.uBO_bcSecret instanceof self.BroadcastChannel === false ) { return; }
+ self.uBO_bcSecret.postMessage('setScriptletLogLevelToOne');
+})();
+
+
+
+
+
+
+
+
+/*******************************************************************************
+
+ DO NOT:
+ - Remove the following code
+ - Add code beyond the following code
+ Reason:
+ - https://github.com/gorhill/uBlock/pull/3721
+ - uBO never uses the return value from injected content scripts
+
+**/
+
+void 0;
diff --git a/src/js/scriptlets/scriptlet-loglevel-2.js b/src/js/scriptlets/scriptlet-loglevel-2.js
new file mode 100644
index 0000000..d8afefd
--- /dev/null
+++ b/src/js/scriptlets/scriptlet-loglevel-2.js
@@ -0,0 +1,49 @@
+/*******************************************************************************
+
+ uBlock Origin - a comprehensive, efficient content blocker
+ Copyright (C) 2024-present Raymond Hill
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see {http://www.gnu.org/licenses/}.
+
+ Home: https://github.com/gorhill/uBlock
+*/
+
+'use strict';
+
+/******************************************************************************/
+
+(( ) => {
+ if ( self.uBO_bcSecret instanceof self.BroadcastChannel === false ) { return; }
+ self.uBO_bcSecret.postMessage('setScriptletLogLevelToTwo');
+})();
+
+
+
+
+
+
+
+
+/*******************************************************************************
+
+ DO NOT:
+ - Remove the following code
+ - Add code beyond the following code
+ Reason:
+ - https://github.com/gorhill/uBlock/pull/3721
+ - uBO never uses the return value from injected content scripts
+
+**/
+
+void 0;
diff --git a/src/js/scriptlets/should-inject-contentscript.js b/src/js/scriptlets/should-inject-contentscript.js
index b9a2658..94d0cd3 100644
--- a/src/js/scriptlets/should-inject-contentscript.js
+++ b/src/js/scriptlets/should-inject-contentscript.js
@@ -29,7 +29,7 @@
(( ) => {
try {
- let status = vAPI.uBO !== true;
+ const status = vAPI.uBO !== true;
if ( status === false && vAPI.bootstrap ) {
self.requestIdleCallback(( ) => vAPI && vAPI.bootstrap());
}