mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -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
|
||||
xhr = Promise.promisify(require('xhr'))
|
||||
Url = require('url')
|
||||
querystring = require('querystring')
|
||||
chromeApiPromisifyAll = require('./chrome_api')
|
||||
proxySettings = chromeApiPromisifyAll(chrome.proxy.settings)
|
||||
parseExternalProfile = require('./parse_external_profile')
|
||||
@ -321,7 +322,14 @@ class ChromeOptions extends OmegaTarget.Options
|
||||
url = inspectUrl
|
||||
else
|
||||
@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)
|
||||
return {
|
||||
url: url
|
||||
|
@ -129,7 +129,7 @@ module.exports = class WebRequestMonitor
|
||||
chrome.tabs.onReplaced?.addListener (added, removed) =>
|
||||
@tabInfo[added] ?= @_newTabInfo()
|
||||
delete @tabInfo[removed]
|
||||
chrome.tabs.onUpdated.addListener (tab) =>
|
||||
chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) =>
|
||||
info = @tabInfo[tab.id] ?= @_newTabInfo()
|
||||
return unless info
|
||||
for callback in @_tabCallbacks
|
||||
@ -154,8 +154,9 @@ module.exports = class WebRequestMonitor
|
||||
info = @tabInfo[req.tabId]
|
||||
if info
|
||||
if status == 'start' and req.type == 'main_frame'
|
||||
for own key, value of @_newTabInfo()
|
||||
info[key] = value
|
||||
if req.url.indexOf('chrome://errorpage/') != 0
|
||||
for own key, value of @_newTabInfo()
|
||||
info[key] = value
|
||||
return if info.requestCount > 1000
|
||||
info.requests[req.requestId] = req
|
||||
if (oldStatus = info.requestStatus[req.requestId])
|
||||
|
@ -251,18 +251,16 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
||||
$scope.domainsForCondition[domain.domain] ?= true
|
||||
$scope.profileForDomains ?= preselectedProfileNameForCondition
|
||||
|
||||
omegaTarget.getActivePageInfo().then((info) ->
|
||||
$q.all([
|
||||
omegaTarget.state('currentProfileCanAddRule')
|
||||
omegaTarget.getActivePageInfo(),
|
||||
]).then ([canAddRule, info]) ->
|
||||
$scope.currentProfileCanAddRule = canAddRule
|
||||
if info
|
||||
$scope.currentTempRuleProfile = info.tempRuleProfileName
|
||||
if $scope.currentTempRuleProfile
|
||||
preselectedProfileNameForCondition = $scope.currentTempRuleProfile
|
||||
$scope.currentDomain = info.domain
|
||||
else
|
||||
$q.reject()
|
||||
).then(->
|
||||
omegaTarget.state('currentProfileCanAddRule')
|
||||
).then (value) ->
|
||||
$scope.currentProfileCanAddRule = value
|
||||
|
||||
$scope.prepareConditionForm = ->
|
||||
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)}}')
|
||||
span(omega-profile-inline='p' options='availableProfiles' disp-name='dispNameFilter')
|
||||
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')
|
||||
span.glyphicon.glyphicon-plus
|
||||
= ' '
|
||||
|
Loading…
Reference in New Issue
Block a user