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

Function nobyda

BDTieBa-DailyBonus/TieBa.js:246–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

244}
245
246function nobyda() {
247 const isRequest = typeof $request != "undefined"
248 const isSurge = typeof $httpClient != "undefined"
249 const isQuanX = typeof $task != "undefined"
250 const notify = (title, subtitle, message) => {
251 if (isQuanX) $notify(title, subtitle, message)
252 if (isSurge) $notification.post(title, subtitle, message)
253 }
254 const write = (value, key) => {
255 if (isQuanX) return $prefs.setValueForKey(value, key)
256 if (isSurge) return $persistentStore.write(value, key)
257 }
258 const read = (key) => {
259 if (isQuanX) return $prefs.valueForKey(key)
260 if (isSurge) return $persistentStore.read(key)
261 }
262 const adapterStatus = (response) => {
263 if (response) {
264 if (response.status) {
265 response["statusCode"] = response.status
266 } else if (response.statusCode) {
267 response["status"] = response.statusCode
268 }
269 }
270 return response
271 }
272 const get = (options, callback) => {
273 if (isQuanX) {
274 if (typeof options == "string") options = {
275 url: options
276 }
277 options["method"] = "GET"
278 $task.fetch(options).then(response => {
279 callback(null, adapterStatus(response), response.body)
280 }, reason => callback(reason.error, null, null))
281 }
282 if (isSurge) $httpClient.get(options, (error, response, body) => {
283 callback(error, adapterStatus(response), body)
284 })
285 }
286 const post = (options, callback) => {
287 if (isQuanX) {
288 if (typeof options == "string") options = {
289 url: options
290 }
291 options["method"] = "POST"
292 $task.fetch(options).then(response => {
293 callback(null, adapterStatus(response), response.body)
294 }, reason => callback(reason.error, null, null))
295 }
296 if (isSurge) {
297 $httpClient.post(options, (error, response, body) => {
298 callback(error, adapterStatus(response), body)
299 })
300 }
301 }
302 const done = (value = {}) => {
303 if (isQuanX) return $done(value)

Callers 1

TieBa.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected