diff options
Diffstat (limited to 'chromium')
-rw-r--r-- | chromium/background.html | 12 | ||||
-rwxr-xr-x | chromium/makecrx.sh | 2 | ||||
-rw-r--r-- | chromium/manifest.json | 6 | ||||
-rwxr-xr-x | chromium/viable.js | 13 |
4 files changed, 28 insertions, 5 deletions
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 @@ <html><head><script> - chrome.browserAction.onClicked.addListener(function(tab) { - chrome.tabs.executeScript(null, {code:"simplyread();"}); + function onRequest(request, sender, sendResponse) { + chrome.pageAction.show(sender.tab.id); + sendResponse({}); + }; + + /* called on page load if viable */ + chrome.extension.onRequest.addListener(onRequest); + + chrome.pageAction.onClicked.addListener(function(tab) { + chrome.tabs.executeScript(tab.id, {code:"simplyread();"}); }); </script></head></html> 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", "<all_urls>" ], + "content_scripts": [{"matches": ["<all_urls>"], "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) {}); |