统一使用系统代理

上网、浏览、聊天、下载等
回复
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

统一使用系统代理

#1

帖子 eexpress » 2014-01-20 18:28

各种软件都设置代理,是麻烦的。统一到系统代理设置。

问题:
tw, thunderbird里面正常。3个浏览器不能访问,估计是pac没写对?是因为url没有www.的前缀导致?
fb, 浏览器带www.前缀都正常。thunderbird里面一直是“正在初始化流”。不知道这里面的帐号名到底是中文的,还是邮箱的。

片段:

代码: 全选

       dnsDomainIs(host, '.twitter.com') ||
        dnsDomainIs(host, '.gmail.com') ||
        dnsDomainIs(host, '.facebook.com') ||
		shExpMatch(url, "twitter.*") ||
附件
网络_001.png
● 鸣学
头像
oneleaf
论坛管理员
帖子: 10455
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 统一使用系统代理

#2

帖子 oneleaf » 2014-01-20 23:56

代码: 全选

function FindProxyForURL(url, host) {
    var autoproxy = 'PROXY 192.168.1.1:8087';
    var blackhole = 'PROXY 192.168.1.1:8086';
    if (dnsDomainIs(host, '.google.com') ||
        dnsDomainIs(host, '.google.com.hk') ||
        dnsDomainIs(host, '.google-analytics.com') ||
        dnsDomainIs(host, '.googleapis.com') ||
        dnsDomainIs(host, '.googlecode.com') ||
        dnsDomainIs(host, '.googlevideo.com') ||
        dnsDomainIs(host, '.googleusercontent.com') ||
        dnsDomainIs(host, '.ggpht.com') ||
        dnsDomainIs(host, '.wikipedia.org') ||
        dnsDomainIs(host, '.sf.net') ||
        dnsDomainIs(host, '.sourceforge.net') ||
        host == 'cdnjs.cloudflare.com' ||
        host == 'wp.me' ||
        host == 'ow.ly' ||
        host == 'po.st' ||
        host == 'goo.gl')
    {
        return autoproxy;
    }
    if (host == 'pagead2.googlesyndication.com' ||
        host == 'p.tanx.com' ||
        host == 'a.alimama.cn' ||
        FindProxyForURLByAdblock(url, host) != 'DIRECT')
    {
        return blackhole;
    } else {
        return FindProxyForURLByAutoProxy(url, host);
    }
}

// AUTO-GENERATED RULES, DO NOT MODIFY!
function FindProxyForURLByAdblock(url, host) {
    if (shExpMatch(url, "*/data/preview/*.jpg") || shExpMatch(url, "*/data/preview/*.gif")) return "DIRECT";
    if (url.indexOf("http://zerodm.net/js/ads/zxdmxz.js") == 0) return "DIRECT";
    if (url.indexOf("http://zhaozi.cn/d/js/acmsd/ggao5") == 0) return "DIRECT";
    if (url.indexOf("http://linuxidc.com/linuxfile/linux.js") == 0) return "DIRECT";
    if (url.indexOf("http://img.jb51.net/inc/content.js") == 0) return "DIRECT";
.......
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 统一使用系统代理

#3

帖子 eexpress » 2014-01-21 11:03

goa自带的pac,太庞大了。而且它自己也调用了一次。
系统这一级,我想尽量小的设置。
● 鸣学
头像
oneleaf
论坛管理员
帖子: 10455
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 统一使用系统代理

#4

帖子 oneleaf » 2014-01-21 15:01

就按上面的Demo写咯。
回复