diff --git a/background.js b/background.js index 700a539..5e6969f 100644 --- a/background.js +++ b/background.js @@ -528,7 +528,7 @@ function checkTab(id, isBeforeNav, isRepeat) { let rollover = gOptions[`rollover${set}`]; let conjMode = gOptions[`conjMode${set}`]; let days = gOptions[`days${set}`]; - let blockURL = gOptions[`blockURL${set}`]; + let blockURLs = gOptions[`blockURLs${set}`]; let applyFilter = gOptions[`applyFilter${set}`]; let filterName = gOptions[`filterName${set}`]; let filterMute = gOptions[`filterMute${set}`]; @@ -605,7 +605,7 @@ function checkTab(id, isBeforeNav, isRepeat) { log(`lockdown: ${lockdown}`); log(`withinTimePeriods: ${withinTimePeriods}`); log(`afterTimeLimit: ${afterTimeLimit}`); - log(`blockURL: ${blockURL}`); + log(`blockURLs: ${blockURLs}`); if (blockRE) { let res = blockRE.exec(pageURL); if (res) { @@ -644,11 +644,16 @@ function checkTab(id, isBeforeNav, isRepeat) { } else { gTabs[id].keyword = keyword; + let blockUrlsList = blockURLs.split("\n"); + let positionOfBlockUrlToRedirectOn = Math.floor(Math.random() * (blockUrlsList.length)); + + let blockURL = blockUrlsList[positionOfBlockUrlToRedirectOn]; + // Get final URL for block page blockURL = getLocalizedURL(blockURL) - .replace(/\$K/g, keyword ? keyword : "") - .replace(/\$S/g, set) - .replace(/\$U/g, pageURLWithHash); + .replace(/\$K/g, keyword ? keyword : "") + .replace(/\$S/g, set) + .replace(/\$U/g, pageURLWithHash); // Redirect page browser.tabs.update(id, { url: blockURL }); diff --git a/common.js b/common.js index fa03205..06c8117 100644 --- a/common.js +++ b/common.js @@ -37,7 +37,7 @@ const PER_SET_OPTIONS = { rollover: { type: "boolean", def: false, id: "rollover" }, conjMode: { type: "boolean", def: false, id: "conjMode" }, days: { type: "array", def: [false, true, true, true, true, true, false], id: "day" }, - blockURL: { type: "string", def: DEFAULT_BLOCK_URL, id: "blockURL" }, + blockURLs: { type: "string", def: DEFAULT_BLOCK_URL, id: "blockURLs" }, applyFilter: { type: "boolean", def: false, id: "applyFilter" }, filterName: { type: "string", def: "grayscale", id: "filterName" }, filterMute: { type: "boolean", def: false, id: "filterMute" }, @@ -316,8 +316,12 @@ function checkPosNegIntFormat(value) { // Check blocking page URL format // -function checkBlockURLFormat(url) { - return INTERNAL_BLOCK_URL.test(url) || getParsedURL(url).page; +function checkBlockURLsFormat(url) { + let listOfUrls = url.split("\n"); + for(let i = 0; i < listOfUrls.length; ++i) + if(!INTERNAL_BLOCK_URL.test(listOfUrls[i]) && !getParsedURL(listOfUrls[i]).page) + return false; + return true; } // Convert times to minute periods diff --git a/options.css b/options.css index 953bb1d..a9b3a01 100644 --- a/options.css +++ b/options.css @@ -87,6 +87,28 @@ body { width: 408px; } +.whatToShowInsteadOfBlocked { + display: flex; + padding-top: 7px; + padding-bottom: 7px; +} + +.listOfSites { + float: left; + padding-right: 5%; +} + +.predefinedOptionsList { + display: flex; + flex-direction: column; +} + +.predefinedOption { + display: flex; + justify-content: space-between; + padding: 3px; +} + #form-container { display: flex; justify-content: center; diff --git a/options.html b/options.html index 86cc719..9db5f3f 100644 --- a/options.html +++ b/options.html @@ -135,18 +135,40 @@ In this section, specify how you want to block these sites.
-
-
@@ -533,7 +555,7 @@
Please enter the number of minutes in the correct format (as a positive whole number).
Please enter the URL for the blocking page in the correct format (as a fully specified URL).