Skip to content

Commit 9364448

Browse files
committed
Add support to toggle no-scripting switch with keyboard shortcut
Related issue: uBlockOrigin/uBlock-issues#692
1 parent c03c23d commit 9364448

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

platform/chromium/manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
},
3131
"toggle-cosmetic-filtering": {
3232
"description": "__MSG_toggleCosmeticFiltering__"
33+
},
34+
"toggle-javascript": {
35+
"description": "__MSG_toggleJavascript__"
3336
}
3437
},
3538
"content_scripts": [

src/_locales/en/messages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,10 @@
12531253
"message": "Toggle cosmetic filtering",
12541254
"description": "Label for keyboard shortcut used to toggle cosmetic filtering"
12551255
},
1256+
"toggleJavascript": {
1257+
"message": "Toggle JavaScript",
1258+
"description": "Label for keyboard shortcut used to toggle no-scripting switch"
1259+
},
12561260
"relaxBlockingMode": {
12571261
"message": "Relax blocking mode",
12581262
"description": "Label for keyboard shortcut used to relax blocking mode"

src/js/commands.js

+8
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ vAPI.commands.onCommand.addListener(async command => {
136136
// Tab-specific commands
137137
const tab = await vAPI.tabs.getCurrent();
138138
if ( tab instanceof Object === false ) { return; }
139+
139140
switch ( command ) {
140141
case 'launch-element-picker':
141142
case 'launch-element-zapper': {
@@ -168,6 +169,13 @@ vAPI.commands.onCommand.addListener(async command => {
168169
hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
169170
});
170171
break;
172+
case 'toggle-javascript':
173+
µb.toggleHostnameSwitch({
174+
name: 'no-scripting',
175+
hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
176+
});
177+
vAPI.tabs.reload(tab.id);
178+
break;
171179
default:
172180
break;
173181
}

0 commit comments

Comments
 (0)