| 54 | } |
| 55 | |
| 56 | return new class { |
| 57 | constructor(t, e) { |
| 58 | this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) |
| 59 | } |
| 60 | |
| 61 | isNode() { |
| 62 | return "undefined" != typeof module && !!module.exports |
| 63 | } |
| 64 | |
| 65 | isQuanX() { |
| 66 | return "undefined" != typeof $task |
| 67 | } |
| 68 | |
| 69 | isSurge() { |
| 70 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon |
| 71 | } |
| 72 | |
| 73 | isLoon() { |
| 74 | return "undefined" != typeof $loon |
| 75 | } |
| 76 | |
| 77 | toObj(t, e = null) { |
| 78 | try { |
| 79 | return JSON.parse(t) |
| 80 | } catch { |
| 81 | return e |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | toStr(t, e = null) { |
| 86 | try { |
| 87 | return JSON.stringify(t) |
| 88 | } catch { |
| 89 | return e |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | getjson(t, e) { |
| 94 | let s = e; |
| 95 | const i = this.getdata(t); |
| 96 | if (i) try { |
| 97 | s = JSON.parse(this.getdata(t)) |
| 98 | } catch { |
| 99 | } |
| 100 | return s |
| 101 | } |
| 102 | |
| 103 | setjson(t, e) { |
| 104 | try { |
| 105 | return this.setdata(JSON.stringify(t), e) |
| 106 | } catch { |
| 107 | return !1 |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | getScript(t) { |
| 112 | return new Promise(e => { |
| 113 | this.get({url: t}, (t, s, i) => e(i)) |
nothing calls this directly
no outgoing calls
no test coverage detected