Explorar o código

removed list of new tab URLs

Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
c5ed075c33
Modificáronse 2 ficheiros con 10 adicións e 4 borrados
  1. 9 2
      extension/core/bg/util.js
  2. 1 2
      extension/ui/bg/ui-button.js

+ 9 - 2
extension/core/bg/util.js

@@ -30,10 +30,17 @@ singlefile.util = (() => {
 		"addons.mozilla.org"
 	];
 
-	return { isAllowedURL };
+	return {
+		isAllowedProtocol,
+		isAllowedURL
+	};
+
+	function isAllowedProtocol(url) {
+		return url && (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file://"));
+	}
 
 	function isAllowedURL(url) {
-		return url && (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file://")) && !FORBIDDEN_DOMAINS.find(domain => url.startsWith("https://" + domain) || url.startsWith("http://" + domain));
+		return isAllowedProtocol(url) && !FORBIDDEN_DOMAINS.find(domain => url.startsWith("https://" + domain) || url.startsWith("http://" + domain));
 	}
 
 })();

+ 1 - 2
extension/ui/bg/ui-button.js

@@ -25,7 +25,6 @@
 
 singlefile.ui.button = (() => {
 
-	const NEW_TAB_URLS = ["about:newtab", "chrome://newtab/", "chrome://startpage/"];
 	const DEFAULT_ICON_PATH = "/extension/ui/resources/icon_128.png";
 	const WAIT_ICON_PATH_PREFIX = "/extension/ui/resources/icon_128_wait";
 	const BUTTON_DEFAULT_TOOLTIP_MESSAGE = browser.i18n.getMessage("buttonDefaultTooltip");
@@ -114,7 +113,7 @@ singlefile.ui.button = (() => {
 	}
 
 	function onForbiddenDomain(tab, options) {
-		if (!NEW_TAB_URLS.includes(tab.url)) {
+		if (singlefile.util.isAllowedProtocol(tab.url)) {
 			refresh(tab.id, getProperties(options, BUTTON_BLOCKED_BADGE_MESSAGE, [255, 255, 255, 1], BUTTON_BLOCKED_TOOLTIP_MESSAGE));
 		}
 	}