diff options
author | Yuchen Pei <id@ypei.org> | 2023-08-26 18:16:09 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-08-26 18:16:09 +1000 |
commit | 9e004a40faba221f9179a96df6cceaeaba2d8c68 (patch) | |
tree | c198240e7c22b50695cdb13e4c70c074efc80521 /firefox | |
parent | b35a2376ce6f17468a3502313f931bdc40b536b8 (diff) |
Firefox x org-protocol
A greasemonkey userscript with keybindings for org-protocol.
A webpage to activate org-protocol in firefox, which requires
network.protocol-handler.expose.org-protocol to be false
Some org-protocol bookmarklet in case the keys don't work
Diffstat (limited to 'firefox')
-rw-r--r-- | firefox/extensions/org-protocol.user.js | 32 | ||||
-rw-r--r-- | firefox/org-protocol-activate.html | 1 | ||||
-rw-r--r-- | firefox/policies.json | 32 | ||||
-rw-r--r-- | firefox/user.js | 3 |
4 files changed, 55 insertions, 13 deletions
diff --git a/firefox/extensions/org-protocol.user.js b/firefox/extensions/org-protocol.user.js new file mode 100644 index 0000000..196a473 --- /dev/null +++ b/firefox/extensions/org-protocol.user.js @@ -0,0 +1,32 @@ +// ==UserScript== +// @name org-protocol +// @version 2 +// @grant none +// ==/UserScript== +window.addEventListener("keydown", function (event) { + if (event.defaultPrevented) { + return; // Do nothing if the event was already processed + } + + if (event.key === "l" && event.ctrlKey) { + event.preventDefault(); + location.href = 'org-protocol://store-link?url=' + + encodeURIComponent(location.href) + + '&title=' + document.title; + } + + if (event.key === ";" && event.ctrlKey) { + event.preventDefault(); + location.href = 'org-protocol://capture?template=t' + + '&url=' + encodeURIComponent(window.location.href) + + '&title=' + document.title + + '&body=' + window.getSelection(); + } + + if (event.key === "'" && event.ctrlKey) { + event.preventDefault(); + location.href = 'org-protocol://grok?url=' + + encodeURIComponent(location.href); + } + +}, true); diff --git a/firefox/org-protocol-activate.html b/firefox/org-protocol-activate.html new file mode 100644 index 0000000..c4b7135 --- /dev/null +++ b/firefox/org-protocol-activate.html @@ -0,0 +1 @@ +<a href="org-protocol:/whatever">activate</a> diff --git a/firefox/policies.json b/firefox/policies.json index a6a7726..7a473c7 100644 --- a/firefox/policies.json +++ b/firefox/policies.json @@ -84,17 +84,6 @@ } }, "SearchEngines": { - "Add": [ - { - "Name": "Startpage", - "URLTemplate": "https://www.startpage.com/sp/search?query={searchTerms}", - "Method": "GET", - "IconURL": "https://www.startpage.com/sp/cdn/favicons/favicon--dark.ico", - "Alias": "@startpage", - "Description": "Startpage", - "SuggestURLTemplate": "https://www.startpage.com/sp/search?query={searchTerms}" - } - ], "Remove": [ "Amazon.co.uk", "Amazon.com.au", @@ -105,6 +94,25 @@ "Twitter", "Yahoo" ] - } + }, + "NoDefaultBookmarks": true, + "DisplayBookmarksToolbar": "always", + "Bookmarks": [ + { + "Title": "org-store-link", + "URL": "javascript:location.href='org-protocol://store-link?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);;", + "Placement": "toolbar" + }, + { + "Title": "org-capture-todo", + "URL": "javascript:location.href='org-protocol://capture?template=t'+'&url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection());", + "Placement": "toolbar" + }, + { + "Title": "org-grok", + "URL": "javascript:location.href = 'org-protocol://grok?url=' + encodeURIComponent(location.href);", + "Placement": "toolbar" + } + ] } } diff --git a/firefox/user.js b/firefox/user.js index f6f1530..f8e5879 100644 --- a/firefox/user.js +++ b/firefox/user.js @@ -1055,8 +1055,9 @@ user_pref("xpinstall.whitelist.required", false); // org-protocol user_pref("network.protocol-handler.app.org-protocol", "emacsclient -n"); -user_pref("network.protocol-handler.expose.org-protocol", true); +user_pref("network.protocol-handler.expose.org-protocol", false); user_pref("network.protocol-handler.external.org-protocol", true); +user_pref("devtools.editor.keymap", "emacs"); /* END: internal custom pref to test for syntax errors ***/ |