summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2011-12-11 13:49:02 +0000
committerNick White <git@njw.me.uk>2011-12-11 13:49:02 +0000
commitd878db527ce092b97dcb8f8d29d2e9456f50fdb5 (patch)
tree8c7817e47546a089afdfc6cc8c9a8076f93b9c5e
parent0a02e740fb0ce5cabd0ea5b6f3f6f72c30a66cf7 (diff)
Add options to chromium extension
-rw-r--r--Makefile3
-rw-r--r--TODO4
-rw-r--r--chromium/background.html5
-rw-r--r--chromium/manifest.json1
-rw-r--r--chromium/options.html18
5 files changed, 26 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 5a89735..03a96e4 100644
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,8 @@ crx: $(KEYFILE)
rm -rf chromium-build
mkdir chromium-build
sed 2q < COPYING > chromium-build/COPYING
- cp simplyread.js keybind.js chromium/background.html chromium-build/
+ cp simplyread.js keybind.js chromium-build/
+ cp chromium/background.html chromium/options.html chromium-build/
cat viable.js chromium/viablehook.js > chromium-build/viable.js
rsvg -w 19 -h 19 icon.svg chromium-build/icon.png
rsvg -w 48 -h 48 icon.svg chromium-build/icon48.png
diff --git a/TODO b/TODO
index dec9441..7bc1bcf 100644
--- a/TODO
+++ b/TODO
@@ -11,9 +11,7 @@ make:
gzip things in web/
chromium:
- apparently doesn't work on new versions!
- create option to turn off/on hyperlinks
- create option to turn off/on css
+ change keybind (looks like ctrl-alt-r is now used by chrome, at least on mac)
look at content_security_policy to tighten extension manifest lots
http://code.google.com/chrome/extensions/trunk/manifest.html#content_security_policy
generate appid for use in update xml
diff --git a/chromium/background.html b/chromium/background.html
index ce0042e..6d0847c 100644
--- a/chromium/background.html
+++ b/chromium/background.html
@@ -7,6 +7,9 @@
chrome.extension.onRequest.addListener(onRequest);
chrome.pageAction.onClicked.addListener(function(tab) {
- chrome.tabs.executeScript(tab.id, {code:"simplyread();"});
+ if (!localStorage.prefs)
+ localStorage.prefs = '{"nostyle":false,"nolinks":false}';
+ var prefs = JSON.parse(localStorage.prefs);
+ chrome.tabs.executeScript(tab.id, {code:"simplyread("+prefs.nostyle+","+prefs.nolinks+");"});
});
</script></head></html>
diff --git a/chromium/manifest.json b/chromium/manifest.json
index 996b3e8..a0ff97b 100644
--- a/chromium/manifest.json
+++ b/chromium/manifest.json
@@ -2,6 +2,7 @@
"name": "SimplyRead",
"version": "VERSION",
"background_page": "background.html",
+ "options_page": "options.html",
"permissions": [ "tabs", "<all_urls>" ],
"content_scripts": [{"matches": ["<all_urls>"], "js": ["simplyread.js", "keybind.js", "viable.js"]}],
"page_action": { "default_icon": "icon.png" },
diff --git a/chromium/options.html b/chromium/options.html
new file mode 100644
index 0000000..97d7f46
--- /dev/null
+++ b/chromium/options.html
@@ -0,0 +1,18 @@
+<html><head><script>
+ function save() {
+ var prefs = JSON.parse(localStorage.prefs);
+ prefs.nostyle = document.getElementById("nostyle").checked;
+ prefs.nolinks = document.getElementById("nolinks").checked;
+ localStorage.prefs = JSON.stringify(prefs);
+ }
+
+ window.onload = function() {
+ var prefs = JSON.parse(localStorage.prefs);
+ document.getElementById("nostyle").checked = prefs.nostyle;
+ document.getElementById("nolinks").checked = prefs.nolinks;
+ }
+</script></head><body><form>
+<p><label for="nostyle">Disable default style</label> <input id="nostyle" type="checkbox" onclick="save()"/></p>
+<p><label for="nolinks">Hide links</label> <input id="nolinks" type="checkbox" onclick="save()"/></p>
+</form></body></html>
+