Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2222 - Handle updated Chrome new tab page url #632

Merged
merged 1 commit into from Nov 18, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

handle updated chrome newtab url

  • Loading branch information
christophertino committed Nov 18, 2020
commit f08aa7c222cd7e87919790fb5e8a259e1b37e4e1
@@ -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
*
@@ -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);
}
@@ -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;
}

@@ -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);
}
ProTip! Use n and p to navigate between commits in a pull request.