forked from magicoflolis/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserscript.js
More file actions
152 lines (150 loc) · 7.28 KB
/
userscript.js
File metadata and controls
152 lines (150 loc) · 7.28 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* eslint-disable no-unused-vars */
/* eslint-disable no-useless-escape */
/* eslint-env node */
// import { transformFileSync } from "@swc/core";
import { readFileSync, writeFile } from "fs";
import watch from 'node-watch';
const log = (...message) => {
console.log(`[NodeJS] DBG ${performance.now()}ms`,...message);
//console.log('[%cNodeJS%c] %cDBG', 'color: rgb(0, 186, 124);', '', 'color: rgb(255, 212, 0);', `${[...message]} ${performance.now()}ms`)
},
delay = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
},
nano = (template, data) => {
return template.replace(/\{([\w\.]*)\}/g, (str, key) => {
let keys = key.split("."),
v = data[keys.shift()];
for (let i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
return typeof v !== "undefined" && v !== null ? v : "";
});
},
p = {
dev: "./dist/magic-userjs.dev.user.js",
pub: "./dist/magic-userjs.user.js",
},
js_env = process.env.JS_ENV === 'development',
jsonData = JSON.parse(readFileSync('./package.json', 'utf-8')),
watcher = watch('./src/main.js', { recursive: true }, (evt, name) => {
let header = readFileSync("./src/header.js").toString(),
boxCSS = readFileSync("../tests/compiled/magicuserjs.css").toString(),
code = readFileSync("./src/main.js").toString(),
// code = transformFileSync("./src/main.js").code,
renderOut = (outFile, jshead) => {
let ujs = nano(header, {
jshead: jshead,
boxCSS: boxCSS,
code: code,
time: +new Date(),
});
writeFile(outFile, ujs, (err) => {
return (err) ? log(err) : log(`Build-path: ${outFile}`);
});
},
time = +new Date(),
jshead_common = `// ==UserScript==
// @name ${js_env ? `[Dev] ${jsonData.productName}` : jsonData.productName}
// @name:zh Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
// @name:zh-CN Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
// @name:zh-TW Magic Userscript+ : 顯示當前網站所有可用的UserJS腳本 Jaeger
// @name:ja Magic Userscript+ : 現在のサイトの利用可能なすべてのUserJSスクリプトを表示するJaeger
// @name:ru-RU Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
// @name:ru Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
// @description ${jsonData.description}
// @description:zh 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
// @description:zh-CN 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
// @description:zh-TW 顯示當前網站的所有可用UserJS(Tampermonkey)腳本,交流QQ群:104267383
// @description:ja 現在のサイトで利用可能なすべてのUserJS(Tampermonkey)スクリプトを表示します。
// @description:ru-RU Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
// @description:ru Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
// @author ${jsonData.author}
// @namespace ${jsonData.homepage}
// @homepageURL ${jsonData.homepage}
// @downloadURL https://github.com/magicoflolis/Userscript-Plus/releases/latest/download/magic-userjs.user.js
// @updateURL https://github.com/magicoflolis/Userscript-Plus/releases/latest/download/magic-userjs.user.js
// @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
// @version ${js_env ? time : jsonData.version}
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3ggEBCQHM3fXsAAAAVdJREFUOMudkz2qwkAUhc/goBaGJBgUtBCZyj0ILkpwAW7Bws4yO3AHLiCtEFD8KVREkoiFxZzX5A2KGfN4F04zMN+ce+5c4LMUgDmANYBnrnV+plBSi+FwyHq9TgA2LQpvCiEiABwMBtzv95RSfoNEHy8DYBzHrNVqVEr9BWKcqNFoxF6vx3a7zc1mYyC73a4MogBg7vs+z+czO50OW60Wt9stK5UKp9Mpj8cjq9WqDTBHnjAdxzGQZrPJw+HA31oulzbAWgLoA0CWZVBKIY5jzGYzdLtdE9DlcrFNrY98zobqOA6TJKHW2jg4nU5sNBpFDp6mhVe5rsvVasUwDHm9Xqm15u12o+/7Hy0gD8KatOd5vN/v1FozTVN6nkchxFuI6hsAAIMg4OPxMJCXdtTbR7JJCMEgCJhlGUlyPB4XfumozInrupxMJpRSRtZlKoNYl+m/6/wDuWAjtPfsQuwAAAAASUVORK5CYII=
// @license MIT
// @include *
// @exclude *://paypal.com/*
// @exclude *://mega.nz
// @exclude *://*.alipay.com/*
// @exclude *://*bank.*/*
// @exclude *://*perfectmoney.*/*
// @exclude *://*stripe.com/*
// @exclude *://*ica.yandex.com/*
// @exclude *://*authorize.net/*
// @exclude *://*2checkout.com/*
// @exclude *://192.168*
// @exclude *://127.0.0*
// @exclude *://router.*.*/*
// @exclude *://gitlab.com/*
// @exclude *://10.0.0*
// @exclude *://*skrill.com/*
// @exclude *://*zalo.me/*
// @exclude *://pay.amazon.*/*
// @exclude *://*.opayo.co.uk/*
// @exclude *://*.payza.org/*
// @exclude *://*.bluesnap.com/*
// @exclude *://securionpay.com/*
// @exclude *://*.unionpayintl.*/*
// @exclude *://*.99bill.com/*
// @exclude *://*.yeepay.com/*
// @exclude *://*payoneer.com/*
// @exclude *://*myetherwallet.com/*
// @exclude *://bitpay.com/*
// @exclude *://*.*/login
// @exclude *://*.*/join
// @exclude *://*.*/signin
// @exclude *://*.*/signup
// @exclude *://*.*/sign-up
// @exclude *://*.*/cart
// @exclude *://*.*.gov/*
// @exclude *://*.*/password_reset
// @exclude *://*.*/checkout*
// @exclude *://*.*/settings/*
// @exclude *://*.*/options/*
// @exclude *://*.*.*/login
// @exclude *://*.*.*/join
// @exclude *://*.*.*/signin
// @exclude *://*.*.*/signup
// @exclude *://*.*.*/sign-up
// @exclude *://*.*.*/cart
// @exclude *://*.*.*/checkout*
// @exclude *://*.*.*/settings/*
// @exclude *://*.*.*/options/*
// @exclude *://*.*.*.gov/*
// @exclude *://*.*.*/password_reset
// @require ${js_env ? `https://cdn.jsdelivr.net/gh/jae-jae/l.js/userjs/l.userjs.min.js` : `https://greasyfork.org/scripts/23419-l-js/code/ljs.js`}
// @require ${js_env ? `http://localhost:8080/userjs-base.js?_=${time}` : `https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/userjs-base.js?_=${time}`}
// @resource uiJs ${js_env ? `http://localhost:8080/ui.js?_=${time}` : `https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.js?_=${time}`}
// @resource count https://greasyfork.org/scripts/by-site.json
// @resource adult https://sleazyfork.org/scripts/by-site.json
// @grant GM_xmlhttpRequest
// @grant GM_getResourceText
// @grant GM_getValue
// @grant GM_setValue
// @grant unsafeWindow
// @noframes
// @connect greasyfork.org
// @connect sleazyfork.org
// @connect cdn.jsdelivr.net
// @run-at document-end
// ==/UserScript==`;
if(js_env){
// Development version
renderOut(p.dev, jshead_common);
} else {
// Release version
renderOut(p.pub, jshead_common);
}
});
log(`ENV: ${process.env.JS_ENV}`);
watcher.on('error', (err) => {
log(err);
delay(5000).then(() => {
watcher.close();
watcher;
});
});