-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
36 lines (35 loc) · 1.18 KB
/
background.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
'use strict';
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'developer.chrome.com'},
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
chrome.runtime.onMessage.addListener(
function(request) {
chrome.browserAction.setIcon({
path: request.newIconPath
});
}
);
chrome.windows.onCreated.addListener(function() {
var date = new Date();
let houres = 24 - date.getHours() - 1;
let minutes = 60 - date.getMinutes();
let timeTo = houres*60 + minutes;
chrome.alarms.create("Start", { delayInMinutes:timeTo});
chrome.browserAction.setIcon({
path:"icons/"+date.toLocaleDateString('fa-IR').split('/')[2]+".png"
});
});
chrome.alarms.onAlarm.addListener(function(alarm){
var date = new Date();
chrome.browserAction.setIcon({
path:"icons/"+date.toLocaleDateString('fa-IR').split('/')[2]+".png"
});
});