2020-10-10 00:35:17 +08:00
|
|
|
|
/*
|
|
|
|
|
Bilibli番剧,自动切换地区
|
|
|
|
|
|
2020-11-26 20:36:24 +08:00
|
|
|
|
此脚本仅适用于Surge4.0+ (iOS)
|
|
|
|
|
此脚本仅适用于Surge4.0+ (iOS)
|
|
|
|
|
此脚本仅适用于Surge4.0+ (iOS)
|
2020-10-10 00:35:17 +08:00
|
|
|
|
|
|
|
|
|
您需要配置相关规则集(https://raw.githubusercontent.com/DivineEngine/Profiles/master/Surge/Ruleset/StreamingMedia/StreamingSE.list)绑定相关select策略组,并且需要具有相关的区域代理服务器纳入您的子策略中。
|
|
|
|
|
最后,您可以通过BoxJs设置策略名和子策略名,或者手动填入脚本。
|
|
|
|
|
|
2021-02-07 18:16:23 +08:00
|
|
|
|
Update: 2021.02.07
|
2020-10-10 00:35:17 +08:00
|
|
|
|
Author: @NobyDa
|
|
|
|
|
|
|
|
|
|
****************************
|
|
|
|
|
Surge 4.2+ 远程脚本配置 :
|
|
|
|
|
****************************
|
|
|
|
|
[Script]
|
2021-02-07 18:16:23 +08:00
|
|
|
|
Bili Region = type=http-response,pattern=^https:\/\/ap(p|i)\.bilibili\.com\/(pgc\/view\/(v\d\/)?app|x(\/v\d)?\/view\/video)\/(season|online)\?access_key,requires-body=1,max-size=0,control-api=1,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Surge/JS/Bili_Auto_Regions.js
|
2020-10-10 00:35:17 +08:00
|
|
|
|
|
|
|
|
|
[MITM]
|
2021-02-07 18:16:23 +08:00
|
|
|
|
hostname = ap?.bilibili.com
|
2020-10-10 00:35:17 +08:00
|
|
|
|
****************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const Group = $persistentStore.read('BiliArea_Policy') || '📺 DomesticMedia'; //Your blibli policy group name.
|
|
|
|
|
const CN = $persistentStore.read('BiliArea_CN') || 'DIRECT'; //Your China sub-policy name.
|
|
|
|
|
const TW = $persistentStore.read('BiliArea_TW') || '🇹🇼 sub-policy'; //Your Taiwan sub-policy name.
|
|
|
|
|
const HK = $persistentStore.read('BiliArea_HK') || '🇭🇰 sub-policy'; //Your HongKong sub-policy name.
|
|
|
|
|
|
2020-11-26 22:34:26 +08:00
|
|
|
|
var obj = JSON.parse($response.body),
|
|
|
|
|
obj = (obj.result || obj.data || {}).title || '';
|
2020-10-10 00:35:17 +08:00
|
|
|
|
const current = $surge.selectGroupDetails().decisions[Group] || 'Policy error ⚠️'
|
|
|
|
|
const str = (() => {
|
|
|
|
|
if (obj.match(/\u50c5[\u4e00-\u9fa5]+\u6e2f/)) {
|
|
|
|
|
if (current != HK) return HK;
|
|
|
|
|
} else if (obj.match(/\u50c5[\u4e00-\u9fa5]+\u53f0/)) {
|
|
|
|
|
if (current != TW) return TW;
|
|
|
|
|
} else if (current != CN) return CN;
|
|
|
|
|
})()
|
|
|
|
|
|
2021-02-07 18:16:23 +08:00
|
|
|
|
if (str) {
|
2020-10-10 00:35:17 +08:00
|
|
|
|
const change = $surge.setSelectGroupPolicy(Group, str);
|
|
|
|
|
const notify = $persistentStore.read('BiliAreaNotify') === 'true';
|
|
|
|
|
if (!notify) $notification.post(obj, ``, `${current} => ${str} => ${change?`🟢`:`🔴`}`);
|
|
|
|
|
if (change) {
|
|
|
|
|
$done(); //Kill the connection. Due to the characteristics of Surge, it will auto reconnect with the new policy.
|
|
|
|
|
} else {
|
|
|
|
|
$done({});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$done({});
|
|
|
|
|
}
|