summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--TODO2
-rw-r--r--gecko/chrome.manifest2
-rw-r--r--gecko/chrome/content/readable.xul8
-rw-r--r--gecko/install.rdf24
-rwxr-xr-xreadable.js18
6 files changed, 58 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index f29dfb1..7ae052b 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/TODO b/TODO
index 6c57edd..02479ae 100644
--- a/TODO
+++ b/TODO
@@ -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;