-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Shortcuts for Toggling Large Media & Remote Font Blocking (Pull Request Included) #3295
Open
9 tasks done
Comments
From bae7a24b8eac28dd559afec2c4a3dd4facee98cd Mon Sep 17 00:00:00 2001
From: Mohammad Matini <mohammad.matini@outlook.com>
Date: Tue, 9 Jul 2024 10:28:00 +0300
Subject: [PATCH 1/2] Add support to toggle large media blocking switch with
keyboard shortcut
---
platform/chromium/manifest.json | 3 +++
platform/firefox/manifest.json | 3 +++
platform/opera/manifest.json | 3 +++
src/_locales/en/messages.json | 4 ++++
src/js/commands.js | 10 ++++++++++
5 files changed, 23 insertions(+)
diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json
index 637b26764..091c6a387 100644
--- a/platform/chromium/manifest.json
+++ b/platform/chromium/manifest.json
@@ -33,6 +33,9 @@
},
"toggle-javascript": {
"description": "__MSG_toggleJavascript__"
+ },
+ "toggle-large-media": {
+ "description": "__MSG_toggleLargeMedia__"
}
},
"content_scripts": [
diff --git a/platform/firefox/manifest.json b/platform/firefox/manifest.json
index bd347e5ee..d31e8fa81 100644
--- a/platform/firefox/manifest.json
+++ b/platform/firefox/manifest.json
@@ -46,6 +46,9 @@
},
"toggle-javascript": {
"description": "__MSG_toggleJavascript__"
+ },
+ "toggle-large-media": {
+ "description": "__MSG_toggleLargeMedia__"
}
},
"content_scripts": [
diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json
index 196c17172..4b7099056 100644
--- a/platform/opera/manifest.json
+++ b/platform/opera/manifest.json
@@ -33,6 +33,9 @@
},
"toggle-javascript": {
"description": "__MSG_toggleJavascript__"
+ },
+ "toggle-large-media": {
+ "description": "__MSG_toggleLargeMedia__"
}
},
"content_scripts": [
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 92fb26065..97834ebca 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -1269,6 +1269,10 @@
"message": "Toggle JavaScript",
"description": "Label for keyboard shortcut used to toggle no-scripting switch"
},
+ "toggleLargeMedia": {
+ "message": "Toggle Large Media",
+ "description": "Label for keyboard shortcut used to toggle large media blocking switch"
+ },
"relaxBlockingMode": {
"message": "Relax blocking mode",
"description": "Label for keyboard shortcut used to relax blocking mode"
diff --git a/src/js/commands.js b/src/js/commands.js
index 2f29b23d9..30e07d2ac 100644
--- a/src/js/commands.js
+++ b/src/js/commands.js
@@ -178,6 +178,16 @@ vAPI.commands.onCommand.addListener(async command => {
});
vAPI.tabs.reload(tab.id);
break;
+ case 'toggle-large-media':
+ µb.toggleHostnameSwitch({
+ name: 'no-large-media',
+ hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
+ });
+ vAPI.tabs.executeScript(tab.id, {
+ file: '/js/scriptlets/load-large-media-all.js',
+ allFrames: true,
+ });
+ break;
default:
break;
}
--
2.39.4
|
From a45ef71f934db5b330225df5859276b0ca8bd420 Mon Sep 17 00:00:00 2001
From: Mohammad Matini <mohammad.matini@outlook.com>
Date: Tue, 9 Jul 2024 10:29:51 +0300
Subject: [PATCH 2/2] Add support to toggle remote font blocking switch with
keyboard shortcut
---
platform/chromium/manifest.json | 3 +++
platform/firefox/manifest.json | 3 +++
platform/opera/manifest.json | 3 +++
src/_locales/en/messages.json | 4 ++++
src/js/commands.js | 7 +++++++
5 files changed, 20 insertions(+)
diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json
index 091c6a387..99c5ae504 100644
--- a/platform/chromium/manifest.json
+++ b/platform/chromium/manifest.json
@@ -36,6 +36,9 @@
},
"toggle-large-media": {
"description": "__MSG_toggleLargeMedia__"
+ },
+ "toggle-remote-fonts": {
+ "description": "__MSG_toggleRemoteFonts__"
}
},
"content_scripts": [
diff --git a/platform/firefox/manifest.json b/platform/firefox/manifest.json
index d31e8fa81..2435a2fae 100644
--- a/platform/firefox/manifest.json
+++ b/platform/firefox/manifest.json
@@ -49,6 +49,9 @@
},
"toggle-large-media": {
"description": "__MSG_toggleLargeMedia__"
+ },
+ "toggle-remote-fonts": {
+ "description": "__MSG_toggleRemoteFonts__"
}
},
"content_scripts": [
diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json
index 4b7099056..c5293eb49 100644
--- a/platform/opera/manifest.json
+++ b/platform/opera/manifest.json
@@ -36,6 +36,9 @@
},
"toggle-large-media": {
"description": "__MSG_toggleLargeMedia__"
+ },
+ "toggle-remote-fonts": {
+ "description": "__MSG_toggleRemoteFonts__"
}
},
"content_scripts": [
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 97834ebca..c5d9d8a4d 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -1273,6 +1273,10 @@
"message": "Toggle Large Media",
"description": "Label for keyboard shortcut used to toggle large media blocking switch"
},
+ "toggleRemoteFonts": {
+ "message": "Toggle Remote Fonts",
+ "description": "Label for keyboard shortcut used to toggle remote font blocking switch"
+ },
"relaxBlockingMode": {
"message": "Relax blocking mode",
"description": "Label for keyboard shortcut used to relax blocking mode"
diff --git a/src/js/commands.js b/src/js/commands.js
index 30e07d2ac..3c80a4187 100644
--- a/src/js/commands.js
+++ b/src/js/commands.js
@@ -188,6 +188,13 @@ vAPI.commands.onCommand.addListener(async command => {
allFrames: true,
});
break;
+ case 'toggle-remote-fonts':
+ µb.toggleHostnameSwitch({
+ name: 'no-remote-fonts',
+ hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
+ });
+ vAPI.tabs.reload(tab.id);
+ break;
default:
break;
}
--
2.39.4
|
I tested my implementation on the Firefox version mentioned above only. |
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
I tried to reproduce the issue when...
Description
I use large media and remote font blocking by default (my data plans are frequently capped), but I find myself needing to use the mouse dozens of times a day to unblock large media on the current page. I forked the repo and added shortcuts for those two commands, in the vein of the JavaScript toggling one.
I will be using this myself personally. But since it doesn't seem to add much overhead, I thought I might present it here for possible inclusion in the main uBlock repo (pull requests there seem to be closed for non-contributors). I would rather install the upstream signed extension than having to maintain my own patches and builds.
Version with shortcuts implemented: https://github.com/mohammad-matini/uBlock
I will also include the two commits as patches in the comments here, if that's easier to handle.
Thank you for your great work on uBlock Origin.
A specific URL where the issue occurs.
Irrelevant.
Steps to Reproduce
Expected behavior
One shortcut, images, and other large media, loaded.
One shortcut, remote fonts allowed and page reloaded.
Actual behavior
Have to use the mouse and click multiple times to switch large media on.
Have to use the mouse and click multiple times to switch remote fonts on,
then reload the page manually.
uBO version
1.58.1b12
Browser name and version
Firefox 115.12.0esr
Operating System and version
Slackware 15.0
The text was updated successfully, but these errors were encountered: