aboutsummaryrefslogtreecommitdiff
path: root/firefox/extensions/org-protocol.user.js
blob: 196a473124440dc1e21fc64a1c483b2198a90e5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);