MCPcopy Create free account
hub / github.com/NobyDa/Script / nobyda

Function nobyda

Surge/JS/Bili_Auto_Regions.js:253–363  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

251}
252
253function nobyda() {
254 const isHTTP = typeof $httpClient != "undefined";
255 const isLoon = typeof $loon != "undefined";
256 const isQuanX = typeof $task != "undefined";
257 const isSurge = typeof $network != "undefined" && typeof $script != "undefined";
258 const ssid = (() => {
259 if (isQuanX && typeof ($environment) !== 'undefined') {
260 return $environment.ssid;
261 }
262 if (isSurge && $network.wifi) {
263 return $network.wifi.ssid;
264 }
265 if (isLoon) {
266 return JSON.parse($config.getConfig()).ssid;
267 }
268 })();
269 const notify = (title, subtitle, message) => {
270 console.log(`${title}\n${subtitle}\n${message}`);
271 if (isQuanX) $notify(title, subtitle, message);
272 if (isHTTP) $notification.post(title, subtitle, message);
273 }
274 const read = (key) => {
275 if (isQuanX) return $prefs.valueForKey(key);
276 if (isHTTP) return $persistentStore.read(key);
277 }
278 const adapterStatus = (response) => {
279 if (!response) return null;
280 if (response.status) {
281 response["statusCode"] = response.status;
282 } else if (response.statusCode) {
283 response["status"] = response.statusCode;
284 }
285 return response;
286 }
287 const getPolicy = (groupName) => {
288 if (isSurge) {
289 if (typeof ($httpAPI) === 'undefined') return 3;
290 return new Promise((resolve) => {
291 $httpAPI("GET", "v1/policy_groups/select", {
292 group_name: encodeURIComponent(groupName)
293 }, (b) => resolve(b.policy || 2))
294 })
295 }
296 if (isLoon) {
297 if (typeof ($config.getPolicy) === 'undefined') return 3;
298 const getName = $config.getPolicy(groupName);
299 return getName || 2;
300 }
301 if (isQuanX) {
302 if (typeof ($configuration) === 'undefined') return 3;
303 return new Promise((resolve) => {
304 $configuration.sendMessage({
305 action: "get_policy_state"
306 }).then(b => {
307 if (b.ret && b.ret[groupName]) {
308 resolve(b.ret[groupName][1]);
309 } else resolve(2);
310 }, () => resolve());

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected