Skip to content

Commit ce1b5c9

Browse files
hai-altx-softStigmatoz
authored andcommitted
Fix delete restriction site
1 parent 94603a1 commit ce1b5c9

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

scripts/activity.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ class Activity {
3434
else return false;
3535
}
3636

37-
checkRestrictionIfAny(domain, tab){
37+
isLimitExceeded(domain, tab){
3838
if (setting_restriction_list !== undefined && setting_restriction_list.length > 0){
3939
var item = setting_restriction_list.find(o => o.domain === domain);
4040
if (item !== undefined){
4141
var today = new Date().toLocaleDateString();
4242
var todayTimeUse = tab.days.find(x => x.date == today).summary;
43-
if (todayTimeUse > item.time){
44-
43+
if (todayTimeUse >= item.time){
44+
return true;
4545
}
4646
}
4747
}
48-
else return false;
48+
return false;
4949
}
5050

5151
isNewUrl(domain) {

scripts/background.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function backgroundCheck() {
3838
activity.setCurrentActiveTab(tab.url);
3939
chrome.idle.queryState(parseInt(setting_interval_inactivity), function (state) {
4040
if (state === 'active') {
41-
if (activity.checkRestrictionIfAny(activeUrl, tab)){
42-
41+
if (activity.isLimitExceeded(activeUrl, tab)){
42+
chrome.tabs.create({ url: chrome.runtime.getURL("block.html") })
4343
}
4444
if (!activity.isInBlackList(activeUrl))
4545
tab.incSummaryTime();

scripts/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function convertTimeToSummaryTime(time) {
5656
var timeValue = time.split(':');
5757
var hour = timeValue[0];
5858
var min = timeValue[1];
59-
var resultTimeValue;
59+
var resultTimeValue = 0;
6060
if (hour > 0)
6161
resultTimeValue = hour * 60 * 3600;
6262
resultTimeValue += min * 60;

scripts/settings.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ function deleteBlackSite(e) {
211211

212212
function deleteRestrictionSite(e) {
213213
var targetElement = e.path[1];
214-
restrictionList.splice(restrictionList.indexOf(targetElement.innerText), 1);
214+
var itemValue = targetElement.querySelector("[name='domain']").value;
215+
var item = restrictionList.find(x => x.domain == itemValue);
216+
restrictionList.splice(restrictionList.indexOf(item), 1);
215217
document.getElementById('restrictionsList').removeChild(targetElement);
216218
updateRestrictionList();
217219
}

scripts/webact.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ document.addEventListener('DOMContentLoaded', function () {
2727
getDataFromStorageByDays();
2828
});
2929
document.getElementById('settings').addEventListener('click', function () {
30-
chrome.tabs.create({ url: chrome.runtime.getURL("block.html") })
31-
32-
// if (chrome.runtime.openOptionsPage) {
33-
// chrome.runtime.openOptionsPage();
34-
// } else {
35-
// window.open(chrome.runtime.getURL('block.html'));
36-
// }
30+
if (chrome.runtime.openOptionsPage) {
31+
chrome.runtime.openOptionsPage();
32+
} else {
33+
window.open(chrome.runtime.getURL('options.html'));
34+
}
3735
});
3836
});
3937

0 commit comments

Comments
 (0)