From d65c29f34dd045ac81192f366e34579f3a15f266 Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Sat, 25 Mar 2017 00:24:39 -0400 Subject: [PATCH] Ignore about: and moz- URLs in a few places. --- omega-target-chromium-extension/background.coffee | 8 ++++++-- .../omega_target_web.coffee | 3 ++- omega-target-chromium-extension/src/options.coffee | 10 ++++++++-- .../src/web_request_monitor.coffee | 2 ++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/omega-target-chromium-extension/background.coffee b/omega-target-chromium-extension/background.coffee index ca93899..a76258c 100644 --- a/omega-target-chromium-extension/background.coffee +++ b/omega-target-chromium-extension/background.coffee @@ -288,8 +288,12 @@ encodeError = (obj) -> refreshActivePageIfEnabled = -> return if localStorage['omega.local.refreshOnProfileChange'] == 'false' chrome.tabs.query {active: true, lastFocusedWindow: true}, (tabs) -> - if tabs[0].url and tabs[0].url.substr(0, 6) != 'chrome' - chrome.tabs.reload(tabs[0].id, {bypassCache: true}) + url = tabs[0].url + return if not url + return if url.substr(0, 6) == 'chrome' + return if url.substr(0, 6) == 'about:' + return if url.substr(0, 4) == 'moz-' + chrome.tabs.reload(tabs[0].id, {bypassCache: true}) chrome.runtime.onMessage.addListener (request, sender, respond) -> options.ready.then -> diff --git a/omega-target-chromium-extension/omega_target_web.coffee b/omega-target-chromium-extension/omega_target_web.coffee index 0b88bf0..4e2cee1 100644 --- a/omega-target-chromium-extension/omega_target_web.coffee +++ b/omega-target-chromium-extension/omega_target_web.coffee @@ -40,7 +40,8 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) -> port.onMessage.addListener(callback) return - isChromeUrl = (url) -> url.substr(0, 6) == 'chrome' + isChromeUrl = (url) -> url.substr(0, 6) == 'chrome' or + url.substr(0, 4) == 'moz-' or url.substr(0, 6) == 'about:' optionsChangeCallback = [] requestInfoCallback = null diff --git a/omega-target-chromium-extension/src/options.coffee b/omega-target-chromium-extension/src/options.coffee index 8f5db9f..72d0334 100644 --- a/omega-target-chromium-extension/src/options.coffee +++ b/omega-target-chromium-extension/src/options.coffee @@ -201,8 +201,12 @@ class ChromeOptions extends OmegaTarget.Options index = (index + 1) % profiles.length @applyProfile(profiles[index]).then => if @_options['-refreshOnProfileChange'] - if tab.url and tab.url.indexOf('chrome') != 0 - chrome.tabs.reload(tab.id) + url = tab.url + return if not url + return if url.substr(0, 6) == 'chrome' + return if url.substr(0, 6) == 'about:' + return if url.substr(0, 4) == 'moz-' + chrome.tabs.reload(tab.id) else chrome.browserAction.setPopup({popup: 'popup/index.html'}) Promise.resolve() @@ -356,6 +360,8 @@ class ChromeOptions extends OmegaTarget.Options return result if not url else return result + return result if url.substr(0, 6) == 'about:' + return result if url.substr(0, 4) == 'moz-' domain = OmegaPac.getBaseDomain(Url.parse(url).hostname) return { diff --git a/omega-target-chromium-extension/src/web_request_monitor.coffee b/omega-target-chromium-extension/src/web_request_monitor.coffee index 1e14676..cc22bfd 100644 --- a/omega-target-chromium-extension/src/web_request_monitor.coffee +++ b/omega-target-chromium-extension/src/web_request_monitor.coffee @@ -89,6 +89,8 @@ module.exports = class WebRequestMonitor return if req.error.indexOf('net::ERR_FILE_') == 0 return if req.url.indexOf('file:') == 0 return if req.url.indexOf('chrome') == 0 + return if req.url.indexOf('about:') == 0 + return if req.url.indexOf('moz-') == 0 # Some ad-blocking extensions may redirect requests to 127.0.0.1. return if req.url.indexOf('://127.0.0.1') > 0 return unless reqInfo