diff --git a/_locales/de/messages.json b/_locales/de/messages.json index 83602b9..43384d1 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -512,6 +512,14 @@ "message": "Geben Sie die Domain ein, die erlaubt werden soll:", "description": "" }, + "inputSessionWhitelistDomain": { + "message": "Geben Sie die URL RegExp ein, die für diese Sitzung erlaubt werden soll:", + "description": "" + }, + "inputSessionWhitelistURL": { + "message": "Geben Sie die Domain ein, die für diese Sitzung erlaubt werden soll:", + "description": "" + }, "settings": { "message": "Einstellungen", "description": "" @@ -585,6 +593,24 @@ "description": "" }, + "sessionWhiteList_description": { + "message": "Domänen oder URLs, die die -API in der aktuellen Sitzung verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt werden.", + "description": "" + }, + "sessionWhiteList_title": { + "message": "Sitzungs-Whitelist", + "description": "" + }, + + "whitelistDomainTemporarily": { + "message": "erlaube Domain übergangsweise", + "description": "" + }, + "whitelistURLTemporarily": { + "message": "erlaube URL übergangsweise", + "description": "" + }, + "inspectImage": { "message": "Bild betrachten", "description": "" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0cce82c..f6237af 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -512,6 +512,14 @@ "message": "Input domain to add to white list:", "description": "" }, + "inputSessionWhitelistDomain": { + "message": "Input URL RegExp to add to the session white list:", + "description": "" + }, + "inputSessionWhitelistURL": { + "message": "Input domain to add to the session white list:", + "description": "" + }, "settings": { "message": "settings", "description": "" @@ -585,6 +593,24 @@ "description": "" }, + "sessionWhiteList_title": { + "message": "Session white list", + "description": "" + }, + "sessionWhiteList_description": { + "message": "Domains or URLs where the -API should not be blocked in the current session. To add multiple entries, separate them by commas.", + "description": "" + }, + + "whitelistDomainTemporarily": { + "message": "whitelist domain temporarily", + "description": "" + }, + "whitelistURLTemporarily": { + "message": "whitelist URL temporarily", + "description": "" + }, + "inspectImage": { "message": "inspect image", "description": "" diff --git a/icons/pageAction-whitelistDomainTemporarily.svg b/icons/pageAction-whitelistDomainTemporarily.svg new file mode 100644 index 0000000..b5ebc34 --- /dev/null +++ b/icons/pageAction-whitelistDomainTemporarily.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + + + + + + www. + + + + + + + + diff --git a/icons/pageAction-whitelistURLTemporarily.svg b/icons/pageAction-whitelistURLTemporarily.svg new file mode 100644 index 0000000..2f0a2b8 --- /dev/null +++ b/icons/pageAction-whitelistURLTemporarily.svg @@ -0,0 +1,90 @@ + + + + + + + + + + image/svg+xml + + + + + + + https: + + + + + + diff --git a/lib/lists.js b/lib/lists.js index bc7b77a..35cd348 100644 --- a/lib/lists.js +++ b/lib/lists.js @@ -48,6 +48,9 @@ }; }); + return addMatchToList(list); + } + function addMatchToList(list){ list.match = function(url){ return this.some(function(entry){ return entry.match(url); @@ -59,6 +62,7 @@ var lists = { white: [], + sessionWhite: [], "ignore": [], black: [] }; @@ -105,6 +109,10 @@ updateStackList(settings.stackList); scope.get = function getList(type){ + if (type === "white"){ + var combined = lists.white.slice().concat(lists.sessionWhite); + return addMatchToList(combined); + } return lists[type]; }; scope.appendTo = function appendToList(type, entry){ diff --git a/lib/main.js b/lib/main.js index 0dc2b99..56de16d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -16,6 +16,9 @@ settings.onloaded(function(){ notice("everything loaded"); + message("perform startup reset"); + settings.startupReset(); + persistentRndStorage.init(); message("register non port message listener"); diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js index cb271a2..3987d53 100644 --- a/lib/settingDefinitions.js +++ b/lib/settingDefinitions.js @@ -42,6 +42,11 @@ name: "whiteList", defaultValue: "" }, + { + name: "sessionWhiteList", + resetOnStartup: true, + defaultValue: "" + }, { name: "blackList", defaultValue: "" diff --git a/lib/settings.js b/lib/settings.js index b22a4ad..18134d0 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -683,5 +683,12 @@ logging.message("settings still default?", settings.isStillDefault); } }; + scope.startupReset = function(){ + scope.forEach(function(definition){ + if (definition.resetOnStartup){ + definition.set(definition.defaultValue); + } + }); + }; Object.seal(scope); }()); \ No newline at end of file diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 79e698b..90bf53c 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -279,6 +279,13 @@ "displayAdvancedSettings": [true] } }, + { + "name": "sessionWhiteList", + "displayDependencies": { + "blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"], + "displayAdvancedSettings": [true] + } + }, { "name": "blackList", "displayDependencies": { diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index 2434393..46e7f50 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -12,6 +12,7 @@ const domainNotification = require("./domainNotification"); const Notification = require("./Notification"); const {createActionButtons, modalPrompt} = require("./gui"); + const lists = require("./lists"); Promise.all([ browser.tabs.query({active: true, currentWindow: true}), @@ -98,6 +99,25 @@ } }); } + }, + { + name: "whitelistDomainTemporarily", + isIcon: true, + callback: function(domain){ + modalPrompt( + browser.i18n.getMessage("inputSessionWhitelistURL"), + domain + ).then(function(domain){ + if (domain){ + lists.appendTo("sessionWhite", domain).then(function(){ + window.close(); + }); + } + else { + window.close(); + } + }); + } } ].forEach(function(domainAction){ domainNotification.addAction(domainAction); @@ -137,6 +157,25 @@ } }); } + }, + { + name: "whitelistURLTemporarily", + isIcon: true, + callback: function({url}){ + modalPrompt( + browser.i18n.getMessage("inputSessionWhitelistDomain"), + "^" + url.href.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "$" + ).then(function(url){ + if (url){ + lists.appendTo("sessionWhite", url).then(function(){ + window.close(); + }); + } + else { + window.close(); + } + }); + } } ].forEach(function(action){ Notification.addAction(action); diff --git a/releaseNotes.txt b/releaseNotes.txt index 8d45b38..0963347 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -3,7 +3,7 @@ Version 0.5.1: - new features: - - + - new setting: session white list that is cleared on addon load (= browser start) fixes: - Changes made in the page action were not saved in all Firefox versions