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 /readable.js | |
parent | 2cee16336a4ce756cac166adccbb40a41122b6f4 (diff) |
Add working firefox extension
Diffstat (limited to 'readable.js')
-rwxr-xr-x | readable.js | 18 |
1 files changed, 11 insertions, 7 deletions
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; |