-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventpage.js
33 lines (30 loc) · 954 Bytes
/
eventpage.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
var urls = [
'facebook.com',
'instagram.com',
'reddit.com'
]
function makePayment(){
chrome.storage.sync.get({pastPayments: []}, function(value){
var allPayments = value.pastPayments;
var now = new Date(Date.now()).toLocaleString();
allPayments.push([5, now]);
chrome.storage.sync.set({pastPayments: allPayments});
});
}
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.status === 'complete'){
for (var i = 0; i < urls.length; i++) {
if(tab.url.includes(urls[i])){
console.log('BOOO! YOU ARE ON ' + urls[i]);
chrome.storage.sync.get({viewCount: 0}, function(value){
var newCount = value.viewCount + 1;
chrome.storage.sync.set({viewCount: newCount});
if(newCount % 2 === 0){
makePayment();
}
})
break;
}
}
}
});