Skip to content

Commit

Permalink
Add option to enable/disable auto-load on delaying page
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Feb 5, 2023
1 parent a6189ce commit 75aaf44
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ function openExtensionPage(url) {

// Open page blocked by delaying page
//
function openDelayedPage(id, url, set) {
function openDelayedPage(id, url, set, autoLoad) {
//log("openDelayedPage: " + id + " " + url);

if (!gGotOptions || set < 1 || set > gNumSets) {
Expand All @@ -1308,8 +1308,10 @@ function openDelayedPage(id, url, set) {
gTabs[id].allowedPath = gOptions[`delayFirst${set}`] ? null : parsedURL.path;
gTabs[id].allowedSet = set;

// Redirect page
browser.tabs.update(id, { url: url });
if (autoLoad) {
// Redirect page
browser.tabs.update(id, { url: url });
}
}

// Add site to block set
Expand Down Expand Up @@ -1404,8 +1406,11 @@ function handleMessage(message, sender, sendResponse) {
break;

case "delayed":
// Redirect requested by delaying page
openDelayedPage(sender.tab.id, message.blockedURL, message.blockedSet);
// Delaying page countdown completed
let url = message.blockedURL;
let set = message.blockedSet;
let autoLoad = gOptions[`delayAutoLoad${set}`];
openDelayedPage(sender.tab.id, url, set, autoLoad);
break;

case "loaded":
Expand Down
2 changes: 1 addition & 1 deletion blocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function onCountdownTimer(countdown) {
// Clear countdown timer
window.clearInterval(countdown.interval);

// Request extension allow blocked page and redirect
// Notify extension that delay countdown has completed
let message = {
type: "delayed",
blockedURL: countdown.blockedURL,
Expand Down
1 change: 1 addition & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const PER_SET_OPTIONS = {
showKeyword: { type: "boolean", def: true, id: "showKeyword" },
delayFirst: { type: "boolean", def: true, id: "delayFirst" },
delaySecs: { type: "string", def: "60", id: "delaySecs" },
delayAutoLoad: { type: "boolean", def: true, id: "delayAutoLoad" },
delayCancel: { type: "boolean", def: true, id: "delayCancel" },
reloadSecs: { type: "string", def: "", id: "reloadSecs" },
allowOverride: { type: "boolean", def: false, id: "allowOverride" },
Expand Down
2 changes: 1 addition & 1 deletion delayed.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>The page you're trying to access has been temporarily blocked by <a href="ht
<a id="lbBlockedURLLink" target="_self"><span id="lbBlockedURL"></span></a>
(<span id="lbBlockedSet">Block Set</span>)
<p id="lbKeywordMatched">Keyword matched: <strong><span id="lbKeywordMatch"></span></strong></p>
<p id="lbCountdownText">The page will be loaded in <strong><span id="lbDelaySeconds">0</span></strong> second(s).</p>
<p id="lbCountdownText">The page will be unblocked in <strong><span id="lbDelaySeconds">0</span></strong> second(s).</p>
</div>

<!-- support info -->
Expand Down
2 changes: 1 addition & 1 deletion es/delayed.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>La página a la que intenta acceder ha sido bloqueada temporalmente por <a h
<a id="lbBlockedURLLink" target="_self"><span id="lbBlockedURL"></span></a>
(<span id="lbBlockedSet">Set de Bloqueo</span>)
<p id="lbKeywordMatched">Palabra clave que coincidió: <strong><span id="lbKeywordMatch"></span></strong></p>
<p id="lbCountdownText">La página se cargará en <strong><span id="lbDelaySeconds">0</span></strong> segundo(s).</p>
<p id="lbCountdownText">La página se desbloqueará en <strong><span id="lbDelaySeconds">0</span></strong> segundo(s).</p>
</div>

<!-- support info -->
Expand Down
2 changes: 1 addition & 1 deletion it/delayed.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>La pagina a cui stai tentando di accedere è stata temporaneamente bloccata
<a id="lbBlockedURLLink" target="_self"><span id="lbBlockedURL"></span></a>
(<span id="lbBlockedSet">Lista blocco</span>)
<p id="lbKeywordMatched">Parole chiave corrispondenti: <strong><span id="lbKeywordMatch"></span></strong></p>
<p id="lbCountdownText">La pagina verrà caricata tra <strong><span id="lbDelaySeconds">0</span></strong> secondi.</p>
<p id="lbCountdownText">La pagina verrà sbloccata tra <strong><span id="lbDelaySeconds">0</span></strong> secondi.</p>
</div>

<!-- support info -->
Expand Down
4 changes: 4 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@
<p>
Delay access to sites by <input id="delaySecs1" type="text" size="2"> seconds when delaying page is used
</p>
<p>
<input id="delayAutoLoad1" type="checkbox">
<label for="delayAutoLoad1">Automatically load blocked page when delay countdown reaches zero</label>
</p>
<p>
<input id="delayCancel1" type="checkbox">
<label for="delayCancel1">Cancel delay countdown if delaying page loses focus</label>
Expand Down

0 comments on commit 75aaf44

Please sign in to comment.