Skip to content

Commit

Permalink
Add ability to exclude URLs from browser button
Browse files Browse the repository at this point in the history
  • Loading branch information
dmac committed Mar 28, 2012
1 parent 2d92b45 commit 801a20f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions background_page.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
return { isEnabledForUrl: isEnabled }; return { isEnabledForUrl: isEnabled };
} }


function addExcludedUrl(url) {

This comment has been minimized.

Copy link
@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.

This comment has been minimized.

Copy link
@dmac

dmac Apr 5, 2012

Author Owner

Done in 91f7b21.

var excludedUrls = settings.get("excludedUrls");
excludedUrls += "\n" + url;
settings.set("excludedUrls", excludedUrls);
}

function saveHelpDialogSettings(request) { function saveHelpDialogSettings(request) {
settings.set("helpDialog_showAdvancedCommands", request.showAdvancedCommands); settings.set("helpDialog_showAdvancedCommands", request.showAdvancedCommands);
} }
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
} }
], ],
"browser_action": { "browser_action": {
"default_icon": "icons/icon48disabled.png" "default_icon": "icons/icon48disabled.png",
"popup": "popup.html"
} }
} }
27 changes: 27 additions & 0 deletions popup.html
Original file line number Original file line Diff line number Diff line change
@@ -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.