moved
[Accesser.git] / accesser / pac
blob03b5bea0d3f82f15b50be195164dfd70b23f20ba
1 var domains = {
2   "apkmirror.com": 1,
3   "archiveofourown.org": 1,
4   "artstation.com": 1,
5   "bbc.com": 1,
6   "dmc.nico": 1,
7   "dropbox-dns.com": 1,
8   "dropbox.com": 1,
9   "dropboxapi.com": 1,
10   "dw.com": 1,
11   "e-hentai.org": 1,
12   "epochtimes.com": 1,
13   "euronews.com": 1,
14   "exhentai.org": 1,
15   "ftchinese.com": 1,
16   "gghpt.com": 1,
17   "github.com": 1,
18   "githubassets.com": 1,
19   "githubusercontent.com": 1,
20   "google.com": 1,
21   "google.com.hk": 1,
22   "googleapis.com": 1,
23   "googlevideo.com": 1
24   "i.pximg.net": 1,
25   "imgur.com": 1,
26   "instagram.com": 1,
27   "kobo.com": 1,
28   "medium.com": 1,
29   "mega.nz": 1,
30   "nicovideo.jp": 1,
31   "nytimes.com": 1,
32   "phncdn.com": 1,
33   "pinterest.com": 1,
34   "pixiv.net": 1,
35   "pornhub.com": 1,
36   "quora.com": 1,
37   "reddit.com": 1,
38   "redditmedia.com": 1,
39   "reuters.com": 1,
40   "startpage.com": 1,
41   "steamcommunity.com": 1,
42   "thetvdb.com": 1,
43   "tumblr.co": 1,
44   "tumblr.com": 1,
45   "twimg.com": 1,
46   "twitter.com": 1,
47   "uptodown.com": 1,
48   "vimeo.com": 1,
49   "wikipedia.org": 1,
50   "youtube.com": 1,
53 var shexps = {
54   "*://api.openai.com/*": 1,
55   "*://steamcommunity-a.akamaihd.net/*": 1,
56   "*://steamuserimages-a.akamaihd.net/*": 1,
57   "*://*.amazon.co.jp/*": 1,
58   "*://*onedrive.live.com/*": 1,
59   "*://*.bbc.co.uk/*": 1,
60   "*://*.bbci.co.uk/*": 1,
61   "*://*.japantimes.co.jp/*": 1,
62   "*://*.yahoo.co.jp/*": 1,
63   "*://*.cna.com.tw/*": 1
66 var proxy = "PROXY {{host}}:{{port}};";
68 var direct = 'DIRECT;';
70 var hasOwnProperty = Object.hasOwnProperty;
72 function shExpMatchs(str, shexps) {
73     for (shexp in shexps) {
74         if (shExpMatch(str, shexp)) {
75             return true;
76         }
77     }
78     return false;
81 function FindProxyForURL(url, host) {
82     var suffix;
83     var pos = host.lastIndexOf('.');
84     pos = host.lastIndexOf('.', pos - 1);
85     while(1) {
86         if (pos <= 0) {
87             if (hasOwnProperty.call(domains, host)) {
88                 return proxy;
89             } else if (shExpMatchs(url, shexps)) {
90                 return proxy;
91             } else {
92                 return direct;
93             }
94         }
95         suffix = host.substring(pos + 1);
96         if (hasOwnProperty.call(domains, suffix)) {
97             return proxy;
98         }
99         pos = host.lastIndexOf('.', pos - 1);
100     }