-
Notifications
You must be signed in to change notification settings - Fork 0
/
Geo_Services.js
54 lines (48 loc) · 1.41 KB
/
Geo_Services.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 判断是否是重写
const isRequest = typeof $request != "undefined";
const isResponse = typeof $response != "undefined";
// 判断是否是Surge
const isSurge = typeof $httpClient != "undefined";
// 判断是否是QuanX
const isQuanX = typeof $task != "undefined";
// 判断是否是Loon
const isLoon = typeof $loon != "undefined";
// 关闭请求
const done = (value = {}) => {
if (isQuanX) return $done(value);
if (isSurge) isRequest ? $done(value) : $done();
};
/*
README:https://github.com/VirgilClyne/iRingo
*/
// Default GeoCountryCode: TW
let GeoCountryCode = "TW";
// Argument Function Supported
if (typeof $argument != "undefined") {
let arg = Object.fromEntries($argument.split("&").map((item) => item.split("=")));
console.log(JSON.stringify(arg));
GeoCountryCode = arg.GeoCountryCode;
};
const url = $request.url;
const path1 = "/pep/gcc";
if (url.indexOf(path1) != -1) {
console.log(path1);
var today = new Date();
var UTCstring = today.toUTCString();
var response = {};
response.headers = {
'Content-Type': 'text/html',
'Date': UTCstring,
'Connection': 'keep-alive',
'Content-Encoding': 'identity'
};
response.body = GeoCountryCode;
if (isQuanX) {
response.status = "HTTP/1.1 200 OK";
done(response);
}
if (isSurge || isLoon) {
response.status = 200;
done({ response });
}
} else done();