From f08aa7c222cd7e87919790fb5e8a259e1b37e4e1 Mon Sep 17 00:00:00 2001 From: Christopher Tino Date: Wed, 18 Nov 2020 14:10:41 -0500 Subject: [PATCH] handle updated chrome newtab url --- src/classes/EventHandlers.js | 2 +- src/classes/PurpleBox.js | 5 +++-- src/utils/click2play.js | 4 ++-- src/utils/utils.js | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/classes/EventHandlers.js b/src/classes/EventHandlers.js index 2636b8a42..dc5f34be8 100644 --- a/src/classes/EventHandlers.js +++ b/src/classes/EventHandlers.js @@ -652,7 +652,7 @@ class EventHandlers { /** * Checks to see if the URL is valid. Also checks to make sure we - * are not on the Chrome new tab page (_/chrome/newtab) or Firefox about:pages + * are not on the legacy Chrome (< 75) new tab page (_/chrome/newtab). * * @private * diff --git a/src/classes/PurpleBox.js b/src/classes/PurpleBox.js index fc571db4a..ade9935b8 100644 --- a/src/classes/PurpleBox.js +++ b/src/classes/PurpleBox.js @@ -42,11 +42,12 @@ class PurpleBox { */ createBox(tab_id) { const tab = tabInfo.getTabInfo(tab_id); - // Skip in the event of pause, trust, prefetching, newtab page, or Firefox about:pages + // Skip in the event of pause, trust, prefetching, non http/s pages or legacy Chrome (< 75) new tab page if (!conf.show_alert || globals.SESSION.paused_blocking || (conf.hide_alert_trusted && !!Policy.checkSiteWhitelist(tab.url)) || - !tab || tab.purplebox || tab.path.includes('_/chrome/newtab') || tab.protocol === 'about' || globals.EXCLUDES.includes(tab.host) || + !tab || tab.purplebox || !tab.protocol.startsWith('http') || tab.path.includes('_/chrome/newtab') || + globals.EXCLUDES.includes(tab.host) || globals.BROWSER_INFO.os === 'android') { return Promise.resolve(false); } diff --git a/src/utils/click2play.js b/src/utils/click2play.js index e7a3de6b4..634816c9c 100644 --- a/src/utils/click2play.js +++ b/src/utils/click2play.js @@ -58,8 +58,8 @@ export function buildC2P(details, app_id) { const { tab_id } = details; const tab = tabInfo.getTabInfo(tab_id); - // If the tab is prefetched, a chrome newtab or Firefox about:page, we can't add C2P to it - if (!tab || tab.prefetched || tab.path.includes('_/chrome/newtab') || tab.protocol === 'about' || globals.EXCLUDES.includes(tab.host)) { + // If the tab is prefetched, non http/s page or legacy Chrome (< 75) new tab page, we can't add C2P to it + if (!tab || tab.prefetched || !tab.protocol.startsWith('http') || tab.path.includes('_/chrome/newtab') || globals.EXCLUDES.includes(tab.host)) { return; } diff --git a/src/utils/utils.js b/src/utils/utils.js index df76c10ab..f3856e623 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -723,7 +723,7 @@ export function capitalize(phrase, separator = ' ') { /** * Inject content scripts and CSS into a given tabID (top-level frame only). - * Note: Chrome 61 blocks content scripts on the new tab page (_/chrome/newtab). Be + * Note: Chrome 61 blocks content scripts on the new tab page. Be * sure to check the current URL before calling this function, otherwise Chrome will throw * a permission error * @@ -774,8 +774,8 @@ export function injectNotifications(tab_id, importExport = false) { return Promise.resolve(true); } const tab = tabInfo.getTabInfo(tab_id); - // check for prefetching, chrome new tab page and Firefox about:pages - if (tab && (tab.prefetched === true || tab.path.includes('_/chrome/newtab') || tab.protocol === 'about' || (!importExport && globals.EXCLUDES.includes(tab.host)))) { + // check for prefetching, non http/s pages and legacy Chrome (< 75) new tab page + if (tab && (tab.prefetched === true || !tab.protocol.startsWith('http') || tab.path.includes('_/chrome/newtab') || (!importExport && globals.EXCLUDES.includes(tab.host)))) { // return false to prevent sendMessage calls return Promise.resolve(false); }