Skip to content

Commit c749cbf

Browse files
committed
View block page when limit is exceeded
1 parent ce1b5c9 commit c749cbf

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

block.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="utf-8">
66
<title>Access to the site is limited</title>
77
<link href="style/block.css" rel="stylesheet" />
8+
<script src="scripts/block.js"></script>
89
</head>
910

1011
<body>

scripts/background.js

Lines changed: 9 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.isLimitExceeded(activeUrl, tab)){
42-
chrome.tabs.create({ url: chrome.runtime.getURL("block.html") })
41+
if (activity.isLimitExceeded(activeUrl, tab)) {
42+
setBlockPageToCurrent(activeUrl);
4343
}
4444
if (!activity.isInBlackList(activeUrl))
4545
tab.incSummaryTime();
@@ -82,6 +82,13 @@ function backgroundCheck() {
8282
});
8383
}
8484

85+
function setBlockPageToCurrent(activeUrl) {
86+
var blockUrl = chrome.runtime.getURL("block.html") + '?url=' + activeUrl;
87+
chrome.tabs.query({ currentWindow: true, active: true }, function (tab) {
88+
chrome.tabs.update(tab.id, { url: blockUrl });
89+
});
90+
}
91+
8592
function backgroundUpdateStorage() {
8693
if (tabs != undefined && tabs.length > 0)
8794
storage.saveTabs(tabs);

scripts/block.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
document.addEventListener('DOMContentLoaded', function () {
2+
var url = new URL(document.URL);
3+
var blockSiteUrl = url.searchParams.get("url");
4+
document.getElementById('site').innerText = blockSiteUrl;
5+
});

scripts/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function convertTimeToSummaryTime(time) {
5858
var min = timeValue[1];
5959
var resultTimeValue = 0;
6060
if (hour > 0)
61-
resultTimeValue = hour * 60 * 3600;
61+
resultTimeValue = hour * 3600;
6262
resultTimeValue += min * 60;
6363

6464
return resultTimeValue;

style/block.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ body{
1616

1717
.current-site{
1818
font-weight: 500;
19+
color: rgb(202, 48, 48);
1920
}

style/settings.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ input[type="button"]:hover {
318318

319319
.restriction-item{
320320
width: 380px;
321+
font-weight: 600;
321322
}
322323

323324
.notify.warning{

0 commit comments

Comments
 (0)