Skip to content
Browse files

Much better

  • Loading branch information...
1 parent 66952f5 commit 3982e32e4f0a7e250e1553ed49052092a3acdaac @ggreer committed May 18, 2012
Showing with 23 additions and 39 deletions.
  1. +14 −12 background.js
  2. +3 −5 options.html
  3. +6 −22 options.js
View
26 background.js
@@ -1,17 +1,19 @@
-var active_urls = [];
-
function check_url(tab_id, change_info, tab) {
- var i;
- for (i = 0; i < active_urls.length; i++) {
- if(tab.url === active_urls[i]) {
- chrome.pageAction.show(tab_id);
- break;
+ var active_urls = JSON.parse(localStorage.urls);
+ var i;
+
+ chrome.pageAction.hide(tab_id);
+
+ for (i = 0; i < active_urls.length; i++) {
+ if(tab.url === active_urls[i]) {
+ chrome.pageAction.show(tab_id);
+ break;
+ }
+ }
+
+ if(tab.url === "https://reach-bb.k1k.me/waterfall") {
+ chrome.pageAction.show(tab_id);
}
- }
- chrome.pageAction.hide(tab_id);
- if(tab.url === "https://reach-bb.k1k.me/waterfall") {
- chrome.pageAction.show(tab_id);
- }
}
chrome.tabs.onUpdated.addListener(check_url);
View
8 options.html
@@ -1,12 +1,10 @@
<html>
<head>
-<title>Options</title>
+ <title>Options</title>
</head>
<script type="text/javascript" src="options.js"></script>
<body>
- <div id="url_list">
- <input class="url" type="text" />
- </div>
-<button id="save">Save</button>
+ <textarea id="url_list"></textarea>
+ <button id="save">Save</button>
</body>
</html>
View
28 options.js
@@ -1,36 +1,20 @@
function restore() {
var i;
- var url_input;
- var url_list_node;
- var urls = [];
+ var url_list_node = document.getElementById("url_list");
+ var urls;
if (localStorage.urls) {
urls = JSON.parse(localStorage.urls);
}
- url_list_node = document.getElementById("url_list");
-
- for (i=0; i<urls.length; i++) {
- url_input = document.createElement("input");
- url_input.value = urls[i];
- url_input.setAttribute("class", "url");
- url_input.setAttribute("type", "text");
- url_list_node.insertBefore(url_input);
- console.log("loaded", urls[i]);
- }
+ url_list_node.value = urls.join("\n");
}
function save() {
- var i;
- var url;
- var url_elements = document.getElementsByClassName("url");
- var urls = [];
-
- for (i=0; i<url_elements.length; i++) {
- urls.push(url_elements[i].value);
- console.log("stored", url_elements[i].value);
- }
+ var url_list_node = document.getElementById("url_list");
+ var urls = url_list_node.value.split("\n");
+ console.log("saving", urls);
localStorage.urls = JSON.stringify(urls);
}

0 comments on commit 3982e32

Please sign in to comment.
Something went wrong with that request. Please try again.