Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eac92a3

Browse files
author
san
committed
Added the ability to add a specific behavior for an address.
1 parent 81b4c57 commit eac92a3

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

background.js

2.03 KB
Binary file not shown.

pac.template

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11

2-
const direct_list_map = new Set(/*{{DIRECT_LIST}}*/);
3-
const proxy_list_map = new Set(/*{{PROXY_LIST}}*/);
2+
const suffixMap = new Map(/*{{SUFFIX_LIST}}*/);
43

54
function FindProxyForURL(url, host) {
65

7-
function searchSuffix( set , str) {
8-
if (set.length === 0) return false;
9-
if (str.length === 0) return true;
10-
11-
for (var i = -1; i > -(str.length+1); i--) {
12-
console.log(str.slice(i,str.length));
13-
if (set.has(str.slice(i,str.length)))
14-
return true;
6+
function searchSuffix(map, str) {
7+
if (map.length === 0 || str.length === 0) return "";
8+
9+
for (var i = -1; i > -(str.length + 1); i--) {
10+
console.log(str.slice(i, str.length));
11+
if (map.has(str.slice(i, str.length)))
12+
// return map.get(str.slice(i, str.length));
13+
return str.slice(i, str.length)
1514
}
16-
return false;
15+
return "";
1716
}
1817

1918
// Local addresses always DIRECT
@@ -26,7 +25,14 @@ function FindProxyForURL(url, host) {
2625
return "DIRECT";
2726
}
2827

29-
if (searchSuffix(direct_list_map, host)) return "DIRECT";
30-
if (searchSuffix(proxy_list_map, host)) return /*{{PROXY_RETURN}}*/;
31-
return /*{{DEFAULT_ACTION}}*/;
28+
const suffix = searchSuffix(suffixMap,host);
29+
if (suffix){
30+
const proxy = suffixMap.get(suffix);
31+
if (proxy)
32+
return proxy
33+
else
34+
return /*{{CURRENT_PROXY}}*/;
35+
}
36+
else
37+
return /*{{DEFAULT_ACTION}}*/;
3238
}

popup.html

412 Bytes
Binary file not shown.

popup.js

922 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)