Permalink
Browse files

Add ability to exclude URLs from browser button

  • Loading branch information...
1 parent 2d92b45 commit 801a20fb28cbd13b057668d495cfe54c645c651b @dmac committed Mar 28, 2012
Showing with 35 additions and 1 deletion.
  1. +6 −0 background_page.html
  2. +2 −1 manifest.json
  3. +27 −0 popup.html
View
@@ -113,6 +113,12 @@
return { isEnabledForUrl: isEnabled };
}
+ function addExcludedUrl(url) {
@philc

philc Apr 5, 2012

It's worth adding a comment explaining that this will be used by the popup. Either here or in the UI, you should check for empty string (with the current UI you can exclude an empty URL) and you should trim whitespace around the URL.

+ var excludedUrls = settings.get("excludedUrls");
+ excludedUrls += "\n" + url;
+ settings.set("excludedUrls", excludedUrls);
+ }
+
function saveHelpDialogSettings(request) {
settings.set("helpDialog_showAdvancedCommands", request.showAdvancedCommands);
}
View
@@ -31,6 +31,7 @@
}
],
"browser_action": {
- "default_icon": "icons/icon48disabled.png"
+ "default_icon": "icons/icon48disabled.png",
+ "popup": "popup.html"
}
}
View
@@ -0,0 +1,27 @@
+<style>
+ #vimiumPopup { width: 300px; }
+ #popupInput { width: 200px; }
+ #popupButton { margin-left: 10px; }
+</style>
+
+<div id="vimiumPopup">
+ <input id="popupInput" type="text" />
+ <input id="popupButton" type="button" value="Exclude URL" />
+</div>
+
+<script type="text/javascript">
+ function onLoad() {
+ chrome.tabs.getSelected(null, function(tab) {
+ document.getElementById("popupInput").value = tab.url;
+ });
+ }
+
+ function onExcludeUrl(e) {
+ var url = document.getElementById("popupInput").value;
+ chrome.extension.getBackgroundPage().addExcludedUrl(url);
+ }
+
+ window.addEventListener("load", onLoad, false);
+ document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false);
+</script>
+

0 comments on commit 801a20f

Please sign in to comment.