Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.2: Click the page action icon to toggle the banner.
Also, record how many of those we have removed across all the wikimedia sites.
- Loading branch information
Showing
3 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
<!DOCTYPE html><html><head><script> | ||
// documents with Wikimedia banners notify us to turn on their page action icon | ||
chrome.extension.onRequest.addListener(function show(req, from, sendResponse) { | ||
chrome.pageAction.show(from.tab.id); | ||
var tab = from.tab, host = hostname(tab.url), title = | ||
'Click to toggle the Wikimedia banner.\n' + | ||
'Removed so far: '+ inc('Σ') +' ('+ inc(host) +' at '+ host +')'; | ||
chrome.pageAction.setTitle({ tabId: tab.id, title: title }); | ||
chrome.pageAction.show(tab.id); // show the page action icon | ||
sendResponse({}); | ||
}); | ||
|
||
// and when the user clicks that icon, have the content script toggle the banner | ||
chrome.pageAction.onClicked.addListener(function toggle(tab) { | ||
chrome.tabs.sendRequest(tab.id, {}, function(response) {}); | ||
}); | ||
|
||
// add 1 to this couter in localStorage | ||
function inc(id) { | ||
return localStorage[id] = 1 + Number(localStorage[id] || 0); | ||
} | ||
|
||
function hostname(url) { | ||
var a = document.createElement('a'); | ||
a.href = url; | ||
return a.hostname; | ||
} | ||
</script></head></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters