summaryrefslogtreecommitdiff
path: root/chromium
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2011-05-21 12:54:14 +0100
committerNick White <git@njw.me.uk>2011-05-21 12:54:14 +0100
commitbf340e9f5ed22058877af1878c85c16de1dd8904 (patch)
treefb1f1cd1ba6d4331645df8ce455b67e91e3ca3ae /chromium
parent4cdb10438dad3fd4b9ecc8ef96538f4219b42e5e (diff)
Make chromium extension a page action
Diffstat (limited to 'chromium')
-rw-r--r--chromium/background.html12
-rwxr-xr-xchromium/makecrx.sh2
-rw-r--r--chromium/manifest.json6
-rwxr-xr-xchromium/viable.js13
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) {});