forked from txthinking/bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmitm_youtube.tengo
62 lines (56 loc) · 2.2 KB
/
mitm_youtube.tengo
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
55
56
57
58
59
60
61
62
// Testing, don't use
text := import("text")
_rule := func(address) {
if text.has_suffix(address, "googlevideo.com:443") || text.has_suffix(address, "www.youtube.com:443") || text.has_suffix(address, "s.youtube.com:443") || text.has_suffix(address, "youtubei.googleapis.com:443") {
return {"protocol": "https"}
}
return {}
}
_request := func(request){
if(text.contains(request["URL"], "googlevideo.com") && !text.contains(request["URL"], "googlevideo.com/dclk_video_ads") && !text.contains(request["URL"], "redirector") && text.contains(request["URL"], "&ctier=L") && text.contains(request["URL"], ",ctier,")){
return {
"StatusCode": 302,
"Location": text.replace(text.replace(request["URL"], "&ctier=L", "", 1), ",ctier,", "", 1)
}
}
if(text.contains(request["URL"], "googlevideo.com") && !text.contains(request["URL"], "googlevideo.com/dclk_video_ads") && !text.contains(request["URL"], "googlevideo.com/videoplayback?") && !text.contains(request["URL"], "redirector") && text.contains(request["URL"], "&oad")){
return {
"StatusCode": 503
}
}
if(text.re_match(`^https?:\/\/youtubei\.googleapis\.com\/youtubei\/v\d\/player\/ad_break`, request["URL"])){
return {
"StatusCode": 503
}
}
if(text.re_match(`^https?:\/\/(www|s)\.youtube\.com\/api\/stats\/ads`, request["URL"])){
return {
"StatusCode": 503
}
}
if(text.re_match(`^https?:\/\/(www|s)\.youtube\.com\/(pagead|ptracking)`, request["URL"])){
return {
"StatusCode": 503
}
}
if(text.re_match(`^https?:\/\/s\.youtube\.com\/api\/stats\/qoe\?adcontext`, request["URL"])){
return {
"StatusCode": 503
}
}
return request
}
_response := func(request, response){
delete(response, "Alt-Svc") // disable http3
return response
}
result := {}
if address {
result = _rule(address)
}
if request && !response {
result = _request(request)
}
if request && response {
result = _response(request, response)
}