diff --git a/omega-target-chromium-extension/src/coffee/omega_target_web.coffee b/omega-target-chromium-extension/src/coffee/omega_target_web.coffee index 4e5ca6d86..eb58202ea 100644 --- a/omega-target-chromium-extension/src/coffee/omega_target_web.coffee +++ b/omega-target-chromium-extension/src/coffee/omega_target_web.coffee @@ -140,8 +140,8 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) -> callBackgroundNoReply('applyProfile', name) addTempRule: (domain, profileName, toggle) -> callBackground('addTempRule', domain, profileName, toggle) - addCondition: (condition, profileName) -> - callBackground('addCondition', condition, profileName) + addCondition: (condition, profileName, addToBottom) -> + callBackground('addCondition', condition, profileName, addToBottom) addProfile: (profile) -> callBackground('addProfile', profile).then omegaTarget.refresh setDefaultProfile: (profileName, defaultProfileName) -> diff --git a/omega-target-chromium-extension/src/js/omega_target_popup.js b/omega-target-chromium-extension/src/js/omega_target_popup.js index c95786132..a36c712eb 100644 --- a/omega-target-chromium-extension/src/js/omega_target_popup.js +++ b/omega-target-chromium-extension/src/js/omega_target_popup.js @@ -71,8 +71,12 @@ OmegaTargetPopup = { callBackgroundNoReply('setDefaultProfile', [profileName, defaultProfileName], cb); }, - addCondition: function(condition, profileName, cb){ - callBackground('addCondition', [condition, profileName], cb) + addCondition: function(condition, profileName, addToBottom, cb){ + if (typeof addToBottom == 'function') { + cb = addToBottom; + addToBottom = null; + } + callBackground('addCondition', [condition, profileName, addToBottom], cb) }, getTempRules: function(cb){ callBackground('getTempRules', [], cb); diff --git a/omega-target/src/options.coffee b/omega-target/src/options.coffee index 82a5a09d4..313a22cf0 100644 --- a/omega-target/src/options.coffee +++ b/omega-target/src/options.coffee @@ -998,9 +998,10 @@ class Options # Add a condition to the current active switch profile. # @param {Object.} cond The condition to add # @param {string>} profileName The name of the result profile of the rule. + # @param {boolean=} addToBottom Whether to append the rule to the end. # @returns {Promise} A promise which is fulfilled when the condition is saved. ### - addCondition: (condition, profileName) -> + addCondition: (condition, profileName, addToBottom) -> @log.method('Options#addCondition', this, arguments) return Promise.resolve() if not @_currentProfileName profile = OmegaPac.Profiles.byName(@_currentProfileName, @_options) @@ -1022,7 +1023,7 @@ class Options break - if @_options['-addConditionsToBottom'] + if addToBottom ? @_options['-addConditionsToBottom'] profile.rules.push({ condition: cond profileName: profileName diff --git a/omega-web/src/coffee/popup.coffee b/omega-web/src/coffee/popup.coffee index a5f127a62..ac6922c5e 100644 --- a/omega-web/src/coffee/popup.coffee +++ b/omega-web/src/coffee/popup.coffee @@ -163,7 +163,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget, refresh() $scope.addCondition = (condition, profileName) -> - omegaTarget.addCondition(condition, profileName).then -> + omegaTarget.addCondition(condition, profileName, true).then -> omegaTarget.state('lastProfileNameForCondition', profileName) refresh() @@ -174,7 +174,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget, conditionType: 'HostWildcardCondition' pattern: domain }) - omegaTarget.addCondition(conditions, profileName).then -> + omegaTarget.addCondition(conditions, profileName, true).then -> omegaTarget.state('lastProfileNameForCondition', profileName) refresh() diff --git a/omega-web/src/popup/network/js/url.js b/omega-web/src/popup/network/js/url.js index 827a11155..c5d39704a 100644 --- a/omega-web/src/popup/network/js/url.js +++ b/omega-web/src/popup/network/js/url.js @@ -316,7 +316,7 @@ export const initUrlCellDetail = async (cell) => { OmegaTargetPopup.addCondition([{ conditionType: 'HostWildcardCondition', pattern - }], profileName, ()=>{ + }], profileName, true, ()=>{ OmegaTargetPopup.setState('lastProfileNameForCondition', profileName, ()=>{ Toastify({ text: "Add condition success",