Skip to content

Commit

Permalink
Add support to toggle no-scripting switch with keyboard shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jan 12, 2024
1 parent c03c23d commit 9364448
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platform/chromium/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
"toggle-cosmetic-filtering": {
"description": "__MSG_toggleCosmeticFiltering__"
},
"toggle-javascript": {
"description": "__MSG_toggleJavascript__"
}
},
"content_scripts": [
Expand Down
4 changes: 4 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,10 @@
"message": "Toggle cosmetic filtering",
"description": "Label for keyboard shortcut used to toggle cosmetic filtering"
},
"toggleJavascript": {
"message": "Toggle JavaScript",
"description": "Label for keyboard shortcut used to toggle no-scripting switch"
},
"relaxBlockingMode": {
"message": "Relax blocking mode",
"description": "Label for keyboard shortcut used to relax blocking mode"
Expand Down
8 changes: 8 additions & 0 deletions src/js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ vAPI.commands.onCommand.addListener(async command => {
// Tab-specific commands
const tab = await vAPI.tabs.getCurrent();
if ( tab instanceof Object === false ) { return; }

switch ( command ) {
case 'launch-element-picker':
case 'launch-element-zapper': {
Expand Down Expand Up @@ -168,6 +169,13 @@ vAPI.commands.onCommand.addListener(async command => {
hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
});
break;
case 'toggle-javascript':
µb.toggleHostnameSwitch({
name: 'no-scripting',
hostname: hostnameFromURI(µb.normalizeTabURL(tab.id, tab.url)),
});
vAPI.tabs.reload(tab.id);
break;
default:
break;
}
Expand Down

0 comments on commit 9364448

Please sign in to comment.