-
Notifications
You must be signed in to change notification settings - Fork 0
/
uiScript.js
56 lines (47 loc) · 1.33 KB
/
uiScript.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var soCount = 0;
var amazingCleanUpSound = new Audio("./audio/oxp.wav");
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
/*console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");*/
console.log(request.visitCount);
soCount = request.visitCount;
sendResponse({thankyou: "from UI"});
});
function getSOCount(){
console.log(soCount)
return soCount;
}
function clearCounter(){
chrome.runtime.sendMessage({"clear": true}, function(response){
console.log(response);
if (response.byeee){
return 0;
}
else{
return 1; //this shouldnt happen
}
})
}
chrome.tabs.onCreated.addListener(function(tab){
console.log("tab created");
var maxTabs = 20;
chrome.tabs.query({}, function(tabs){
if (tabs.length > maxTabs) { // should be bigger ,but oh well
var delRand = Math.floor(Math.random()*maxTabs);
chrome.tabs.remove(tabs[delRand].id, function(){
amazingCleanUpSound.play();
alert("Cleaned up a tab! You're Welcome!")
})
}
if(tabs.length == 5)
{alert("Congrats! You have 5 tabs open!");}
if(tabs.length == 20)
{alert("AYYYY 20 TABS");}
if(tabs.length == 50)
{alert("Uh oh... 50")}
if(tabs.length == 100)
{alert("You seem to be really good with your fingers...");}
});
});