diff options
author | Nick White <git@njw.me.uk> | 2010-11-02 18:33:52 +0000 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2010-11-02 18:33:52 +0000 |
commit | e2c3998350430dd529a82bcb679ac53c5161196a (patch) | |
tree | d59e65d5f26030694c7c87c442c38f7c6103b225 | |
parent | 2cee16336a4ce756cac166adccbb40a41122b6f4 (diff) |
Add working firefox extension
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | gecko/chrome.manifest | 2 | ||||
-rw-r--r-- | gecko/chrome/content/readable.xul | 8 | ||||
-rw-r--r-- | gecko/install.rdf | 24 | ||||
-rwxr-xr-x | readable.js | 18 |
6 files changed, 58 insertions, 8 deletions
@@ -21,5 +21,15 @@ dist: @ln -sf $(NAME)-$(VERSION).tar.bz2.sig latest.tar.bz2.sig @echo $(NAME)-$(VERSION).tar.bz2 $(NAME)-$(VERSION).tar.bz2.sig -.PHONY: dist +xpi: readable.js gecko/install.rdf gecko/chrome.manifest gecko/chrome/content/readable.xul + rm -f readable-$(VERSION).xpi + mkdir -p gecko-build/chrome/content + cp gecko/chrome.manifest gecko-build/ + cp gecko/chrome/content/readable.xul gecko-build/chrome/content/ + cp readable.js gecko-build/chrome/content/readable.js + sed "s/VERSION/$(VERSION)/g" < gecko/install.rdf > gecko-build/install.rdf + cd gecko-build; zip -r ../readable-$(VERSION).xpi . + rm -rf gecko-build + +.PHONY: dist xpi .SUFFIXES: ttl html @@ -1 +1,3 @@ it'd be nice to be able to run tests +chrome extension +ctrl-alt-r as example key combo for all platforms diff --git a/gecko/chrome.manifest b/gecko/chrome.manifest new file mode 100644 index 0000000..fa8891b --- /dev/null +++ b/gecko/chrome.manifest @@ -0,0 +1,2 @@ +content readable chrome/content/ +overlay chrome://browser/content/browser.xul chrome://readable/content/readable.xul diff --git a/gecko/chrome/content/readable.xul b/gecko/chrome/content/readable.xul new file mode 100644 index 0000000..e911b93 --- /dev/null +++ b/gecko/chrome/content/readable.xul @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<overlay id="readable" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + <script src="chrome://readable/content/readable.js" /> + <keyset> + <key id="readable" modifiers="accel alt" key="t" oncommand="alert('hi!')" /> + <key id="readable" modifiers="accel alt" key="r" oncommand="readable()" /> + </keyset> +</overlay> diff --git a/gecko/install.rdf b/gecko/install.rdf new file mode 100644 index 0000000..545f53d --- /dev/null +++ b/gecko/install.rdf @@ -0,0 +1,24 @@ +<?xml version="1.0"?> + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + + <Description about="urn:mozilla:install-manifest"> + <em:id>readable@njw.me.uk</em:id> + <em:version>VERSION</em:version> + <em:type>2</em:type> + + <em:targetApplication> + <Description> + <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> + <em:minVersion>3.0</em:minVersion> + <em:maxVersion>3.6.*</em:maxVersion> + </Description> + </em:targetApplication> + + <em:name>Readable</em:name> + <em:description>Makes webpages more readable. Press Ctrl-Alt-r to toggle readable.</em:description> + <em:creator>Nick White</em:creator> + <em:homepageURL>http://njw.me.uk/software/readable/</em:homepageURL> + </Description> +</RDF> diff --git a/readable.js b/readable.js index 27a6767..a4640c9 100755 --- a/readable.js +++ b/readable.js @@ -4,7 +4,7 @@ * See COPYING file for copyright, license and warranty details. */ -if(original === undefined) var original = false; +if(document.readable_original === undefined) document.readable_original = false; function readable() { @@ -20,17 +20,21 @@ function readable() return n; } - /* if original is set, then the readable version is currently active, - * so switch to the original html */ - if (original) { - document.body.innerHTML = original; + /* if we're running from a browser extension, rather than a page */ + if(document == undefined) + var document = window.content.document; + + /* if readable_original is set, then the readable version is currently active, + * so switch to the readable_original html */ + if (document.readable_original) { + document.body.innerHTML = document.readable_original; for (var i = 0; i < document.styleSheets.length; i++) document.styleSheets[i].disabled = false; - original = false + document.readable_original = false return 0; } - original = document.body.innerHTML; + document.readable_original = document.body.innerHTML; var biggest_num = 0; var biggest_tag; |