Procházet zdrojové kódy

don't display "blocked domain" badge when displaying new tabs

Gildas před 6 roky
rodič
revize
8ecb9e60f9
2 změnil soubory, kde provedl 10 přidání a 4 odebrání
  1. 1 1
      extension/core/bg/core.js
  2. 9 3
      extension/ui/bg/ui-button.js

+ 1 - 1
extension/core/bg/core.js

@@ -105,7 +105,7 @@ singlefile.core = (() => {
 						}
 						await singlefile.tabs.sendMessage(tab.id, { method: "content.save", options: mergedOptions });
 					} else {
-						singlefile.ui.button.onForbiddenDomain(tabId, options);
+						singlefile.ui.button.onForbiddenDomain(tab, options);
 					}
 				}
 			} catch (error) {

+ 9 - 3
extension/ui/bg/ui-button.js

@@ -22,6 +22,7 @@
 
 singlefile.ui.button = (() => {
 
+	const NEW_TAB_URLS = ["about:newtab", "chrome://newtab/"];
 	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");
@@ -86,14 +87,17 @@ singlefile.ui.button = (() => {
 	}
 
 	function onTabUpdated(tabId, changeInfo, tab) {
+		console.log("onTabUpdated", arguments);
 		refreshTab(tab);
 	}
 
 	async function onTabCreated(tab) {
+		console.log("onTabCreated", arguments);
 		refreshTab(tab);
 	}
 
 	async function onTabActivated(tab) {
+		console.log("onTabActivated", arguments);
 		refreshTab(tab);
 	}
 
@@ -109,8 +113,10 @@ singlefile.ui.button = (() => {
 		refresh(tabId, getProperties(options, BUTTON_ERROR_BADGE_MESSAGE, [229, 4, 12, 255]));
 	}
 
-	function onForbiddenDomain(tabId, options) {
-		refresh(tabId, getProperties(options, BUTTON_BLOCKED_BADGE_MESSAGE, [255, 255, 255, 1], BUTTON_BLOCKED_TOOLTIP_MESSAGE));
+	function onForbiddenDomain(tab, options) {
+		if (!NEW_TAB_URLS.includes(tab.url)) {
+			refresh(tab.id, getProperties(options, BUTTON_BLOCKED_BADGE_MESSAGE, [255, 255, 255, 1], BUTTON_BLOCKED_TOOLTIP_MESSAGE));
+		}
 	}
 
 	function onCancelled(tabId, options) {
@@ -135,7 +141,7 @@ singlefile.ui.button = (() => {
 			await refresh(tab.id, properties);
 		} else {
 			try {
-				await onForbiddenDomain(tab.id, options);
+				await onForbiddenDomain(tab, options);
 			} catch (error) {
 				/* ignored */
 			}