MCPcopy Create free account
hub / github.com/chavyleung/scripts / init

Function init

acfun/acfun.cookie.js:18–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18function init() {
19 isSurge = () => {
20 return undefined === this.$httpClient ? false : true
21 }
22 isQuanX = () => {
23 return undefined === this.$task ? false : true
24 }
25 getdata = (key) => {
26 if (isSurge()) return $persistentStore.read(key)
27 if (isQuanX()) return $prefs.valueForKey(key)
28 }
29 setdata = (key, val) => {
30 if (isSurge()) return $persistentStore.write(key, val)
31 if (isQuanX()) return $prefs.setValueForKey(key, val)
32 }
33 msg = (title, subtitle, body) => {
34 if (isSurge()) $notification.post(title, subtitle, body)
35 if (isQuanX()) $notify(title, subtitle, body)
36 }
37 log = (message) => console.log(message)
38 get = (url, cb) => {
39 if (isSurge()) {
40 $httpClient.get(url, cb)
41 }
42 if (isQuanX()) {
43 url.method = 'GET'
44 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
45 }
46 }
47 post = (url, cb) => {
48 if (isSurge()) {
49 $httpClient.post(url, cb)
50 }
51 if (isQuanX()) {
52 url.method = 'POST'
53 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
54 }
55 }
56 done = (value = {}) => {
57 $done(value)
58 }
59 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
60}
61chavy.done()

Callers 1

acfun.cookie.jsFile · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected