From 5e58b83688d1953bbae0dd492f51eb4ea7c222d3 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 15 Nov 2010 21:38:13 +0000 Subject: Allow keybinding in chromium --- INSTALL | 15 ++------------- Makefile | 10 +++++----- TODO | 2 -- chromium/manifest.json | 2 +- keybind.js | 11 +++++++++++ 5 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 keybind.js diff --git a/INSTALL b/INSTALL index 834d009..439a7ed 100644 --- a/INSTALL +++ b/INSTALL @@ -9,7 +9,6 @@ page, or build it by running: make xpi - # Chromium SimplyRead also exists as an extension for chromium (and derived @@ -22,18 +21,9 @@ you can get it from the SimplyRead web page, or by running: # Surf To use SimplyRead from surf, and trigger it from ctrl-alt-r, add the -following to script.js - -(function() { - document.addEventListener('keydown', keybind, false); -})(); - -function keybind(e) { - if (e.keyIdentifier == "U+0052" && e.ctrlKey && e.altKey) // ctrl-alt-r - simplyread(); -} -/* copy simplyread.js here */ +contents of keybind.js and simplyread.js to script.js: + cat keybind.js simplyread.js >> $HOME/.surf/script.js # Uzbl @@ -44,7 +34,6 @@ To use this from uzbl, add the following line to the config file: You'll also have to add the statement 'simplyread();' to the bottom of simplyread.js. - # Other browsers; 'bookmarklet' To use this as a 'bookmarklet', create a new bookmark with an address of: diff --git a/Makefile b/Makefile index b5fc205..faa6715 100644 --- a/Makefile +++ b/Makefile @@ -17,18 +17,18 @@ index.html: doap.ttl README webheader.html dist: mkdir -p $(NAME)-$(VERSION) - cp simplyread.js COPYING INSTALL README $(NAME)-$(VERSION) + cp simplyread.js keybind.js COPYING INSTALL README $(NAME)-$(VERSION) tar -c $(NAME)-$(VERSION) | bzip2 -c > $(NAME)-$(VERSION).tar.bz2 gpg -b < $(NAME)-$(VERSION).tar.bz2 > $(NAME)-$(VERSION).tar.bz2.sig rm -rf $(NAME)-$(VERSION) echo $(NAME)-$(VERSION).tar.bz2 $(NAME)-$(VERSION).tar.bz2.sig -xpi: simplyread.js gecko/install.rdf gecko/chrome.manifest gecko/chrome/content/simplyread.xul gecko/chrome/content/icon.svg +xpi: rm -rf $(NAME)-$(VERSION).xpi gecko-build mkdir -p gecko-build/chrome/content cp COPYING gecko/chrome.manifest gecko-build/ cp gecko/chrome/content/simplyread.xul gecko-build/chrome/content/ - cp simplyread.js gecko-build/chrome/content/simplyread.js + cp simplyread.js gecko-build/chrome/content/ rsvg gecko/chrome/content/icon.svg gecko-build/chrome/content/icon.png sed "s/VERSION/$(VERSION)/g" < gecko/install.rdf > gecko-build/install.rdf cd gecko-build; zip -r ../$(NAME)-$(VERSION).xpi . 1>/dev/null @@ -36,10 +36,10 @@ xpi: simplyread.js gecko/install.rdf gecko/chrome.manifest gecko/chrome/content/ rm -rf gecko-build echo $(NAME)-$(VERSION).xpi $(NAME)-$(VERSION).xpi.sig -crx: simplyread.js chromium/icon.svg chromium/manifest.json chromium/background.html +crx: rm -rf chromium-build mkdir chromium-build - cp COPYING simplyread.js chromium/background.html chromium-build/ + cp COPYING simplyread.js keybind.js chromium/background.html chromium-build/ rsvg chromium/icon.svg chromium-build/icon.png sed "s/VERSION/$(VERSION)/g" < chromium/manifest.json > chromium-build/manifest.json sh chromium/makecrx.sh chromium-build chromium/private.pem > $(NAME)-$(VERSION).crx diff --git a/TODO b/TODO index 06eda90..430cf8d 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,2 @@ -add ctrl-alt-r to chromium extension - http://code.google.com/chrome/extensions/events.html make tests for chromium and firefox engines https://developer.mozilla.org/en/Automated_testing_tips_and_tricks diff --git a/chromium/manifest.json b/chromium/manifest.json index 56c51fa..321aff9 100644 --- a/chromium/manifest.json +++ b/chromium/manifest.json @@ -3,6 +3,6 @@ "version": "VERSION", "background_page": "background.html", "permissions": [ "tabs", "*://*/*" ], - "content_scripts": [{"matches": ["*://*/*"], "js": ["simplyread.js"]}], + "content_scripts": [{"matches": ["*://*/*"], "js": ["simplyread.js", "keybind.js"]}], "browser_action": { "default_icon": "icon.png" } } diff --git a/keybind.js b/keybind.js new file mode 100644 index 0000000..ed5ae3a --- /dev/null +++ b/keybind.js @@ -0,0 +1,11 @@ +/* + * See COPYING file for copyright, license and warranty details. + */ +(function() { + document.addEventListener('keydown', keybind, false); +})(); + +function keybind(e) { + if (e.keyIdentifier == "U+0052" && e.ctrlKey && e.altKey) // ctrl-alt-r + simplyread(); +} -- cgit v1.2.3