-
Notifications
You must be signed in to change notification settings - Fork 4
/
popup.js
33 lines (31 loc) · 1.25 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Mark the domain of the selected tab as junk.
function markAsJunk() {
chrome.tabs.getSelected(null, function (tab) {
var junkDomains = getLocal('junkDomains');
var domain = trimPath(trimWWW(trimProtocol(tab.url.trim())));
junkDomains.push(domain);
setLocal('junkDomains', junkDomains);
document.getElementById('mark_junk_button').style.display = "none";
var bg = bgPage();
bg.updateIcon(bg.extensionActive(), true);
bg.submitConfigChange();
});
}
window.onload = function() {
chrome.tabs.getSelected(null, function (tab) {
if (!lookupJunkDomain(tab.url) && tab.url.indexOf('.') != -1) {
// Show current domain.
var normalized_url = trimWWW(trimProtocol(tab.url.trim()));
var domain = trimPath(normalized_url)
document.getElementById('current_domain').appendChild(document.createTextNode(domain));
document.getElementById('mark_junk_button').style.display = "block";
// Bind button action.
document.getElementById('mark_junk_button').onclick = markAsJunk;
}
});
// TODO: personal statistics
document.getElementById('stats_link').onclick = function() {
chrome.tabs.create({ url: chrome.extension.getURL('stats.html') });
return false;
};
}