mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Fix a bug where failed resources cannot be added as rules in some cases.
currentProfileCanAddRule is now correctly set regardless of page info. Parse URLs like `chrome://errorpage/?lasturl=` in some browsers. Fix #365.
This commit is contained in:
parent
807fad5449
commit
8f71270f1d
@ -3,6 +3,7 @@ OmegaPac = OmegaTarget.OmegaPac
|
|||||||
Promise = OmegaTarget.Promise
|
Promise = OmegaTarget.Promise
|
||||||
xhr = Promise.promisify(require('xhr'))
|
xhr = Promise.promisify(require('xhr'))
|
||||||
Url = require('url')
|
Url = require('url')
|
||||||
|
querystring = require('querystring')
|
||||||
chromeApiPromisifyAll = require('./chrome_api')
|
chromeApiPromisifyAll = require('./chrome_api')
|
||||||
proxySettings = chromeApiPromisifyAll(chrome.proxy.settings)
|
proxySettings = chromeApiPromisifyAll(chrome.proxy.settings)
|
||||||
parseExternalProfile = require('./parse_external_profile')
|
parseExternalProfile = require('./parse_external_profile')
|
||||||
@ -321,7 +322,14 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
url = inspectUrl
|
url = inspectUrl
|
||||||
else
|
else
|
||||||
@clearBadge()
|
@clearBadge()
|
||||||
return null if not url or url.substr(0, 6) == 'chrome'
|
return null if not url
|
||||||
|
if url.substr(0, 6) == 'chrome'
|
||||||
|
errorPagePrefix = 'chrome://errorpage/'
|
||||||
|
if url.substr(0, errorPagePrefix.length) == errorPagePrefix
|
||||||
|
url = querystring.parse(url.substr(url.indexOf('?') + 1)).lasturl
|
||||||
|
return null if not url
|
||||||
|
else
|
||||||
|
return null
|
||||||
domain = OmegaPac.getBaseDomain(Url.parse(url).hostname)
|
domain = OmegaPac.getBaseDomain(Url.parse(url).hostname)
|
||||||
return {
|
return {
|
||||||
url: url
|
url: url
|
||||||
|
@ -129,7 +129,7 @@ module.exports = class WebRequestMonitor
|
|||||||
chrome.tabs.onReplaced?.addListener (added, removed) =>
|
chrome.tabs.onReplaced?.addListener (added, removed) =>
|
||||||
@tabInfo[added] ?= @_newTabInfo()
|
@tabInfo[added] ?= @_newTabInfo()
|
||||||
delete @tabInfo[removed]
|
delete @tabInfo[removed]
|
||||||
chrome.tabs.onUpdated.addListener (tab) =>
|
chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) =>
|
||||||
info = @tabInfo[tab.id] ?= @_newTabInfo()
|
info = @tabInfo[tab.id] ?= @_newTabInfo()
|
||||||
return unless info
|
return unless info
|
||||||
for callback in @_tabCallbacks
|
for callback in @_tabCallbacks
|
||||||
@ -154,6 +154,7 @@ module.exports = class WebRequestMonitor
|
|||||||
info = @tabInfo[req.tabId]
|
info = @tabInfo[req.tabId]
|
||||||
if info
|
if info
|
||||||
if status == 'start' and req.type == 'main_frame'
|
if status == 'start' and req.type == 'main_frame'
|
||||||
|
if req.url.indexOf('chrome://errorpage/') != 0
|
||||||
for own key, value of @_newTabInfo()
|
for own key, value of @_newTabInfo()
|
||||||
info[key] = value
|
info[key] = value
|
||||||
return if info.requestCount > 1000
|
return if info.requestCount > 1000
|
||||||
|
@ -251,18 +251,16 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
|||||||
$scope.domainsForCondition[domain.domain] ?= true
|
$scope.domainsForCondition[domain.domain] ?= true
|
||||||
$scope.profileForDomains ?= preselectedProfileNameForCondition
|
$scope.profileForDomains ?= preselectedProfileNameForCondition
|
||||||
|
|
||||||
omegaTarget.getActivePageInfo().then((info) ->
|
$q.all([
|
||||||
|
omegaTarget.state('currentProfileCanAddRule')
|
||||||
|
omegaTarget.getActivePageInfo(),
|
||||||
|
]).then ([canAddRule, info]) ->
|
||||||
|
$scope.currentProfileCanAddRule = canAddRule
|
||||||
if info
|
if info
|
||||||
$scope.currentTempRuleProfile = info.tempRuleProfileName
|
$scope.currentTempRuleProfile = info.tempRuleProfileName
|
||||||
if $scope.currentTempRuleProfile
|
if $scope.currentTempRuleProfile
|
||||||
preselectedProfileNameForCondition = $scope.currentTempRuleProfile
|
preselectedProfileNameForCondition = $scope.currentTempRuleProfile
|
||||||
$scope.currentDomain = info.domain
|
$scope.currentDomain = info.domain
|
||||||
else
|
|
||||||
$q.reject()
|
|
||||||
).then(->
|
|
||||||
omegaTarget.state('currentProfileCanAddRule')
|
|
||||||
).then (value) ->
|
|
||||||
$scope.currentProfileCanAddRule = value
|
|
||||||
|
|
||||||
$scope.prepareConditionForm = ->
|
$scope.prepareConditionForm = ->
|
||||||
currentDomain = $scope.currentDomain
|
currentDomain = $scope.currentDomain
|
||||||
|
@ -58,7 +58,7 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp)
|
|||||||
a(href='#' role='button' ng-click='setDefaultProfile(profile.name, p.name)' title='{{getProfileTitle(profile)}}')
|
a(href='#' role='button' ng-click='setDefaultProfile(profile.name, p.name)' title='{{getProfileTitle(profile)}}')
|
||||||
span(omega-profile-inline='p' options='availableProfiles' disp-name='dispNameFilter')
|
span(omega-profile-inline='p' options='availableProfiles' disp-name='dispNameFilter')
|
||||||
li.divider(ng-show='!!currentDomain && validResultProfiles.length')
|
li.divider(ng-show='!!currentDomain && validResultProfiles.length')
|
||||||
li(ng-show='!!currentProfileCanAddRule')
|
li(ng-show='!!currentProfileCanAddRule && !!currentDomain')
|
||||||
a(href='#' role='button' ng-click='prepareConditionForm()' data-shortcut='addRule')
|
a(href='#' role='button' ng-click='prepareConditionForm()' data-shortcut='addRule')
|
||||||
span.glyphicon.glyphicon-plus
|
span.glyphicon.glyphicon-plus
|
||||||
= ' '
|
= ' '
|
||||||
|
Loading…
Reference in New Issue
Block a user