-
Notifications
You must be signed in to change notification settings - Fork 2
/
gasmask.js
40 lines (34 loc) · 922 Bytes
/
gasmask.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
var apps = [
{ "name": "wandertab",
"id": "fobdcmnamenjmkffajcbljjpgiolooeh"
},
{ "name": "animatedtab",
"id": "kenhfdoiondldpcoajdbackbnmehgahl"
},
],
counter = 0,
i, randomApp;
function getAllCallback(list) {
var random = getRandomInt(0, apps.length);
randomApp = apps[random];
if(counter === 0 ) {
chrome.management.setEnabled(apps[0].id, false);
chrome.management.setEnabled(apps[1].id, false);
for( i in list ) {
if (list[i].id === randomApp.id) {
chrome.management.setEnabled(list[i].id, true);
counter += 1;
break;
}
}
}else {
counter = 0;
}
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
chrome.tabs.onCreated.addListener(function(tab) {
console.log('Tab created... getting list of apps.');
chrome.management.getAll(getAllCallback);
});