Opera中自动为代理添加例外
Opera的全局代理设置中可以添加例外,也就是不使用代理的网站。在使用全局代理时,有时碰到不需要使用代理的网站就要手动复制网址,打开Opera的对话框来添加例外,这样有些麻烦,这次我写了一个按钮,可以自动把当前的网站添加到代理的例外列表中。
首先通过下面这段语句获得当前的域名:
focus address field & go to line start & next word & range next word & range next word & range next word & range previous character & copy
先定位到地址栏,假设当前的网址是http://www.google.com/search?q=test,先让光标跳到网址的开始处,再用next word跳到下一个单词,也就是越过http://,然后从www处使用range next word开始向后标记单词,相当于键盘上的Shift+方向键,Opera把”.”和”/”作为一个单词的结束,标记三次后选中的就是www.gogole.com/,结尾多了一个斜杠,所以再用range previous character 向后退一位,至此就把当前的域名www.google.com选中了,接下来自然是用copy命令复制到剪切板。
把域名复制到剪切板后就该把它添加到代理的例外列表中了,有两种途径,一是通过Opera的对话框,二是通过opera:config,前者的优点就是需要的延时少,不过接下来在定位上有点小麻烦。
在打开代理设置对话框时,因为不知道里面的复选框的勾选状态,所以不好判断该用几个focus命令跳转,我只好先用disable proxy servers命令取消勾选所有的复选框,此处假设当前正在使用http和https代理,所以在打开对话框后又把http和https server勾选上。最终的按钮如下:Add Exception
focus address field,,,Add Exception,Transfer Success & go to line start & next word & range next word & range next word & range next word & range previous character & copy & cancel & disable proxy servers & show preferences & show proxy servers & delay, 100 & check item & focus next widget & focus next widget & focus next widget & check item & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & check item & focus next widget & go to end & insert,"," & paste & ok & delay,10 & cancel + show hidden popup menu & focus address field & go to line start & next word & range next word & range next word & range next word & range next word & range previous character & copy & cancel & disable proxy servers & show preferences & show proxy servers & delay, 100 & check item & focus next widget & focus next widget & focus next widget & check item & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & focus next widget & check item & focus next widget & go to end & insert,"," & paste & ok & delay,10 & cancel
你也许已经发现上面的语句多了很长一段,没错,这是因为对于像www.bbc.co.uk这样的网站,它的域名有四个单词的长度,所以需要另外考虑。对于三个单词长度的网址,就单击上面的按钮,对于bbc这样的有四个单词长度的网址,就按住按钮不放,一秒钟后相应的命令就会被执行。至于原理,请移步此处。
至于通过opera:config的方法,自然非常简单了:Add Exception
focus address field,,,Add Exception 2,Transfer Success & go to line start & next word & range next word & range next word & range next word & range previous character & copy & cancel & go to page,"opera:config#Proxy|NoProxyServers" & delay, 1000 & go to line end & insert,"," & paste & focus address field & insert,"opera:config#proxy" & go & focus previous widget & focus previous widget & click button & delay, 20 & ok & close page + show hidden popup menu & focus address field,,,Add Exception 2,Transfer Success & go to line start & next word & range next word & range next word & range next word & range next word & range previous character & copy & cancel & go to page,"opera:config#Proxy|NoProxyServers" & delay, 1000 & go to line end & insert,"," & paste & focus address field & insert,"opera:config#proxy" & go & focus previous widget & focus previous widget & click button & delay, 20 & ok & close page
当然,你也可以把这些语句添加到菜单、快捷键、鼠标手势或者对话框中。
唉!要考试了,复习去了。:(
Update: 直接忽略上面的第2到4段吧,用js直接就可以得到当前的域名了,可惜我不会js啊,感谢论坛里的DJ,他可是真正的高手,什么都会。获取域名的语句如下:
go to page,"javascript:prompt('', location.hostname)" & delay, 10 & copy & cancel
所以上面的按钮可以简化成:对话框方式:Add Exception,opera:config方式:
Add Exception
REPLY))
用js获取域名,会一点js的都知道,但是通过prompt+oper命令复制,才是DJ最牛的地方啊。
简单的js还是要学一点啊,在加上Css,上手opera那个爽啊
REPLY))
你真能折腾,佩服
楼上说cs也是可以,不过我倒喜欢这种用对话框命令的。
需要代理经常会关掉js╮(╯_╰)╭
REPLY))
@A.shun, 我是说js,不是cs。。囧
REPLY))
@alife, 用js我倒是想到了,只写出来这个:
focus address field & insert, "javascript:document.write(location.host)" & go & delay, 1000 & select all & copy & back & cancel也可以实现,就是饶了些。我只知道在地址栏里操作,不知道还有prompt这个东西
REPLY))
pac文件不支持通配符,设置自动代理麻烦。反过来设定排除的网址反而是好方法。
你这两个按钮确实非常方便。
一点不爽就是,op无法自动检测重复,就像书签一样。
还有你上面的,opera:config的方法在锁定tab的情况下无效。
REPLY))
@A.shun, pac支持通配符啊,我现在主要就用的pac,偶尔用全局代理,我的pac文件是这样:http://blog.judes.me/2009/09/10/opera-proxy.html
考虑到禁用js的情况,可以把两种方法合二为一,把js写在opera内部命令的后面,如果禁用js就不执行,对剪切板没有影响。
在前面加一个delay,1或者"|"就行了,也不知道是为什么
REPLY))
@jude,
。。。。。
看来我属于长期被误导的- -
还在对这玩意不是太依赖︶︿︶
没有邮件通知真是个不方便啊。
REPLY))
@A.shun, 刚刚添加了邮件通知功能