generated from taotao7/userscript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev.user.js
86 lines (84 loc) · 2.4 KB
/
dev.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// ==UserScript==
// @name aone-helper [dev]
// @description a aone helper
// @namespace github.com/taotao7
// @require http://libs.baidu.com/jquery/1.8.3/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.js
// @resource 0 http://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/layer.css
// @match *aone.alibaba-inc.com/*
// @match *team.aone.alibaba-inc.com/*
// @match *code.alibaba-inc.com/*
// @match *my.aone.alibaba-inc.com/*
// @match *ati.alibaba-inc.com/*
// @version 0.0.3
// @homepage https://github.com/taotao7/Aone-Helper
// @author taotao7
// @license MIT
// @grant GM_log
// @grant GM_listValues
// @grant GM_getValue
// @grant Gm_setValue
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant GM.xmlHttpRequest
// @grant GM.setValue
// @grant GM.getValue
// ==/UserScript==
/* globals GM */
'use strict';
(function () {
const url = `http://localhost:8124/bundle.user.js?${Date.now()}`
new Promise(function loadBundleFromServer (resolve, reject) {
const req = GM.xmlHttpRequest({
method: 'GET',
url: url,
onload: function (r) {
if (r.status !== 200) {
return reject(r)
}
resolve(r.responseText)
},
onerror: e => reject(e)
})
if (req && 'catch' in req) {
req.catch(e => { /* ignore */ })
}
}).catch(function (e) {
const log = function (obj, b) {
let prefix = 'loadBundleFromServer: '
try {
prefix = GM.info.script.name + ': '
} catch (e) {}
if (b) {
console.log(prefix + obj, b)
} else {
console.log(prefix, obj)
}
}
if (e && 'status' in e) {
if (e.status <= 0) {
log('Server is not responding')
GM.getValue('scriptlastsource3948218', false).then(function (src) {
if (src) {
log('%cExecuting cached script version', 'color: Crimson; font-size:x-large;')
/* eslint-disable no-eval */
eval(src)
}
})
} else {
log('HTTP status: ' + e.status)
}
} else {
log(e)
}
}).then(function (s) {
if (s) {
/* eslint-disable no-eval */
eval(`${s}
//# sourceURL=${url}`)
GM.setValue('scriptlastsource3948218', s)
}
})
})()