aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-09-29 13:21:27 +0200
committerTeddy Wing2018-09-29 13:21:27 +0200
commit2716ded228ba49f21a338c8cc8e092fd468f4609 (patch)
tree9e1fcc11aad6d0f7556ef0d509a34f11ab4d5d3b
downloadduckduckgo-region-filter-toggle-shortcut-2716ded228ba49f21a338c8cc8e092fd468f4609.tar.bz2
Add duckduckgo-region-filter-toggle-shortcut.user.js
A web user script that adds a keyboard shortcut (Ctrl-r) to DuckDuckGo to toggle the region filter. Because it's not a link and is therefore not clickable via Vim extensions.
-rw-r--r--duckduckgo-region-filter-toggle-shortcut.user.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/duckduckgo-region-filter-toggle-shortcut.user.js b/duckduckgo-region-filter-toggle-shortcut.user.js
new file mode 100644
index 0000000..e1a89c0
--- /dev/null
+++ b/duckduckgo-region-filter-toggle-shortcut.user.js
@@ -0,0 +1,29 @@
+// ==UserScript==
+// @name DuckDuckGo Region Filter Toggle Shortcut
+// @description A keyboard shortcut to toggle the region filter
+// @namespace com.teddywing
+// @match https://duckduckgo.com/*
+// ==/UserScript==
+
+// Copyright (c) 2018 Teddy Wing
+//
+// 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 <https://www.gnu.org/licenses/>.
+
+var toggle = document.querySelector('.js-region-filter-switch');
+
+document.addEventListener('keydown', function(e) {
+ if (e.key === 'r' && e.ctrlKey) {
+ toggle.click();
+ }
+});