Switchyomega: 增加关于“临时规则”的界面帮助或说明 | Add help text for temp rules

Created on 24 Jun 2015  ·  11Comments  ·  Source: FelisCatus/SwitchyOmega

红框处的部分,貌似是针对这么一个单独网址的,想确认一下

不知这个选择是临时性的还是永久性的呢?试了几次,没搞明白用法,Wiki里似乎也没写。

image

Needs-UI-Design PR-welcome enhancement

Most helpful comment

不想重启 但想清除临时规则 做不到

All 11 comments

临时的……重启浏览器后失效。

虽然也很想在界面上加点帮助文字,不过……因为弹出菜单就那么一点地方,所以有点困难。

多谢~

最终的结论是啥?必须重启浏览器?打开好多标签了,真心不想重启。。。

你可以添加永久规则啊 @l5oo00

不想重启 但想清除临时规则 做不到

screenshot_20180823_032020

diff --git a/omega-target/src/options.coffee b/omega-target/src/options.coffee
index 30c80ba..9c6fcda 100644
--- a/omega-target/src/options.coffee
+++ b/omega-target/src/options.coffee
@@ -789,7 +789,7 @@ class Options
     @log.method('Options#addTempRule', this, arguments)
     return Promise.resolve() if not @_currentProfileName
     profile = OmegaPac.Profiles.byName(profileName, @_options)
-    if not profile
+    if not profile and profileName != "RemoveTempRule"
       return Promise.reject new ProfileNotExistError(profileName)
     if not @_tempProfile?
       @_tempProfile = OmegaPac.Profiles.create('', 'SwitchProfile')
@@ -804,6 +804,11 @@ class Options
         key = OmegaPac.Profiles.nameAsKey(rule.profileName)
         list = @_tempProfileRulesByProfile[key]
         list.splice(list.indexOf(rule), 1)
+        if profileName == "RemoveTempRule"
+          delete @_tempProfileRules[domain]
+          @_tempProfile.rules.splice(@_tempProfile.rules.indexOf(rule), 1)
+          OmegaPac.Profiles.updateRevision(@_tempProfile)
+          return @applyProfile(@_currentProfileName)

         rule.profileName = profileName
         changed = true
diff --git a/omega-web/src/popup/js/profiles.js b/omega-web/src/popup/js/profiles.js
index e14afae..bc001d6 100644
--- a/omega-web/src/popup/js/profiles.js
+++ b/omega-web/src/popup/js/profiles.js
@@ -233,6 +233,11 @@
     var profiles = state.validResultProfiles.map(function(name) {
       return state.availableProfiles['+' + name];
     }).sort(compareProfile);
+    if (pageInfo.tempRuleProfileName) {
+      profiles = [{name: "RemoveTempRule", profileType: "SystemProfile",
+                  color: "#aaaaaa", desc: "RemoveTempRule", builtin: true
+                }].concat(profiles);
+    }
     profiles.forEach(function(profile) {
       if (profile.name.indexOf('__') === 0) return;
       if ((profile.name === OmegaPopup.state.currentProfileName) &&

@kaoyusu Thanks for your contribution. I cannot accept this patch right away due to the hackish implementation which fails to address a few corner cases (*) and lack of localization of the new string. I will put this on hold until I develop a more robust solution, but you're welcome to improve the patch and re-submit it as a pull request.

(*) For example, a profile literally named "RemoveTempRule" exists for whatever reason.

@FelisCatus 额,这个是用于移除当前域名临时规则的,只有当前域名存在临时规则RemoveTempRule才会显示
只是给大家做一下参考,我自己用了蛮长时间的,也没发现什么问题

please update the doc or the feature or both, since I just found out what the filter function exactly work for some years.

Could you consider use this function to add/remove Bypass List both forever and temporarily when normal Profile activated?
The Bypass List is actually inconvenient.

thanks!

@kaoyusu Thanks for your contribution. I cannot accept this patch right away due to the hackish implementation which fails to address a few corner cases (*) and lack of localization of the new string. I will put this on hold until I develop a more robust solution, but you're welcome to improve the patch and re-submit it as a pull request.

(*) For example, a profile literally named "RemoveTempRule" exists for whatever reason.

@FelisCatus 额,这个是用于移除当前域名临时规则的,只有当前域名存在临时规则RemoveTempRule才会显示
只是给大家做一下参考,我自己用了蛮长时间的,也没发现什么问题

希望能尽快加入这个功能……现在这个问题真的挺困扰人的。

被坑过不少次,希望临时规则启用时域名那一行改个颜色啥的提醒下也行。

不想重启 但想清除临时规则 做不到

倒也不用重启浏览器,重启下插件,在插件列表里开关一下

Was this page helpful?
0 / 5 - 0 ratings