From bf340e9f5ed22058877af1878c85c16de1dd8904 Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 21 May 2011 12:54:14 +0100 Subject: Make chromium extension a page action --- Makefile | 6 ++++-- TODO | 47 ++++++++++++++++++++++++++++++++++++----------- chromium/background.html | 12 ++++++++++-- chromium/makecrx.sh | 2 ++ chromium/manifest.json | 6 +++--- chromium/viable.js | 13 +++++++++++++ simplyread.js | 6 ++---- 7 files changed, 70 insertions(+), 22 deletions(-) create mode 100755 chromium/viable.js diff --git a/Makefile b/Makefile index 4d2ca16..b3b3659 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ NAME = simplyread VERSION = 0.4 +WEBSITE = http://njw.me.uk/software/$(NAME)/ +KEYFILE = private.pem all: web/chromium-updates.xml web/index.html dist xpi crx @@ -45,10 +47,10 @@ xpi: crx: rm -rf chromium-build mkdir chromium-build - cp COPYING simplyread.js keybind.js chromium/background.html chromium-build/ + cp COPYING simplyread.js keybind.js chromium/viable.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 > web/$(NAME)-$(VERSION).crx + sh chromium/makecrx.sh chromium-build $(KEYFILE) > web/$(NAME)-$(VERSION).crx rm -r chromium-build gpg -b < web/$(NAME)-$(VERSION).crx > web/$(NAME)-$(VERSION).crx.sig echo web/$(NAME)-$(VERSION).crx web/$(NAME)-$(VERSION).crx.sig diff --git a/TODO b/TODO index 7c912a7..0a1fc0b 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,36 @@ -current tests - test the keyboard shortcut, by sending an event; - e=document.createEvent(... - e.initEvent(... - e.keyCode = ... - document.body.dispatchEvent(e) - window.close directly after logging to the console - -make tests for chromium and firefox engines - https://developer.mozilla.org/en/Automated_testing_tips_and_tricks - https://developer.mozilla.org/en/Mozmill_Tests/Addon_tests +finish update support. this means use tool http://www.softlights.net/projects/mxtools/uhura.html to sign mozilla thing, and test both mozilla and chrome things actually work + +core: + it would be nice to do hyphenation. http://code.google.com/p/hyphenator/ is nice, but heavyish (around 2000 LOC). most of that is just unneeded config options etc, though, the core looks reasonable; see hyphenate and hyphenateWord functions. note that it's lgpl. + +chromium: + page action doesn't work from icon on file:// (though from keybind it works fine) + fix makecrx.sh to work with 9base utils + look further into permissions; see if we can scale back + so we don't get warnings; after all, no network or disk + activity happens at all. if not, ask on a 'google group' or + similar (may be able to post over nntp..) + http://code.google.com/chrome/extensions/manifest.html + http://code.google.com/chrome/extensions/permission_warnings.html + +gecko: + test with firefox 4.0, and update version info + +build: + set website from makefile variable / sed everywhere + build to current directory, not web + +web: + change 'download simplyread' button to 'simplyread 0.4 source' + +test: + current tests + test the keyboard shortcut, by sending an event; + e=document.createEvent(... + e.initEvent(... + e.keyCode = ... + document.body.dispatchEvent(e) + window.close directly after logging to the console + make tests for chromium and firefox engines + https://developer.mozilla.org/en/Automated_testing_tips_and_tricks + https://developer.mozilla.org/en/Mozmill_Tests/Addon_tests diff --git a/chromium/background.html b/chromium/background.html index 5343f46..7850bd2 100644 --- a/chromium/background.html +++ b/chromium/background.html @@ -1,5 +1,13 @@ diff --git a/chromium/makecrx.sh b/chromium/makecrx.sh index ca97835..b0b8f2e 100755 --- a/chromium/makecrx.sh +++ b/chromium/makecrx.sh @@ -5,6 +5,8 @@ # Based on bash script at: # http://code.google.com/chrome/extensions/crx.html # Licensed under the BSD license +# +# NOTE: does not yet work perfectly with 9base tools test $# -ne 2 && echo "Usage: $0 dir pem" && exit 1 diff --git a/chromium/manifest.json b/chromium/manifest.json index 6b28f29..ceb7179 100644 --- a/chromium/manifest.json +++ b/chromium/manifest.json @@ -2,8 +2,8 @@ "name": "SimplyRead", "version": "VERSION", "background_page": "background.html", - "permissions": [ "tabs", "*://*/*" ], - "content_scripts": [{"matches": ["*://*/*"], "js": ["simplyread.js", "keybind.js"]}], - "browser_action": { "default_icon": "icon.png" }, + "permissions": [ "tabs", "" ], + "content_scripts": [{"matches": [""], "js": ["simplyread.js", "keybind.js", "viable.js"]}], + "page_action": { "default_icon": "icon.png" }, "update_url": "http://njw.me.uk/software/simplyread/chromium-updates.xml" } diff --git a/chromium/viable.js b/chromium/viable.js new file mode 100755 index 0000000..09acb36 --- /dev/null +++ b/chromium/viable.js @@ -0,0 +1,13 @@ +/* + * SimplyRead - makes webpages more readable + * + * See COPYING file for copyright, license and warranty details. + */ + +function viable() { + var doc; + doc = (document.body === undefined) + ? window.content.document : document; + return doc.getElementsByTagName("p").length; +} +if(viable()) chrome.extension.sendRequest({}, function(response) {}); diff --git a/simplyread.js b/simplyread.js index c7b56b5..832b3c2 100755 --- a/simplyread.js +++ b/simplyread.js @@ -21,10 +21,8 @@ function simplyread() } var doc; - if(document.body === undefined) - doc = window.content.document; - else - doc = document; + doc = (document.body === undefined) + ? window.content.document : document; /* if simplyread_original is set, then the simplyread version is currently active, * so switch to the simplyread_original html */ -- cgit v1.2.3