forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.js
More file actions
36 lines (30 loc) · 1.32 KB
/
block.js
File metadata and controls
36 lines (30 loc) · 1.32 KB
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';
var storage = new LocalStorage();
var blockSiteUrl;
var restrictionList = [];
document.addEventListener('DOMContentLoaded', function () {
var url = new URL(document.URL);
blockSiteUrl = url.searchParams.get("url");
document.getElementById('site').innerText = extractHostname(blockSiteUrl);
storage.getValue(STORAGE_RESTRICTION_LIST, function (items) {
restrictionList = items;
if (restrictionList === undefined)
restrictionList = [];
var currentItem = restrictionList.find(x => isDomainEquals(x.domain, blockSiteUrl));
if (currentItem !== undefined){
document.getElementById('limit').innerText = convertShortSummaryTimeToString(currentItem.time);
}
});
document.getElementById('deffererBtn').addEventListener('click', function () {
chrome.runtime.getBackgroundPage(function (bg) {
let defList = bg.deferredRestrictionsList;
if (defList == undefined)
defList = [];
defList.push({ site: blockSiteUrl, dateOfDeferred: new Date().getTime()});
bg.deferredRestrictionsList = defList;
chrome.tabs.query({ currentWindow: true, active: true }, function(tab) {
chrome.tabs.update(tab.id, { url: blockSiteUrl });
});
});
});
});