From fcb9a678b3b9b476533965d463056574a65c4249 Mon Sep 17 00:00:00 2001 From: woohoo Date: Sun, 19 Jun 2022 01:31:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8E=8B=E7=BC=A9js=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.js | 21 +++++++++++++++++++++ package.json | 4 +++- wuhu-torn-helper.js | 19 +++---------------- 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 build.js diff --git a/build.js b/build.js new file mode 100644 index 0000000..5213cba --- /dev/null +++ b/build.js @@ -0,0 +1,21 @@ +let fs = require('fs'); + +let date = new Date(); +let version = '0.3.36'; +let head = `// ==UserScript== +// @lastmodified ${date.getFullYear()}${('0' + (date.getMonth() + 1)).slice(-2)}${('0' + date.getDate()).slice(-2)}${('0' + date.getHours()).slice(-2)}${('0' + date.getMinutes()).slice(-2)} +// @name 芜湖助手 +// @namespace WOOH +// @version ${version} +// @description 托恩,起飞! +// @author Woohoo[2687093] Sabrina_Devil[2696209] +// @match https://www.torn.com/* +// @grant GM_xmlhttpRequest +// @grant unsafeWindow +// @connect * +// ==/UserScript== +` + +const data = fs.readFileSync('./release.min.user.js', 'utf8'); +fs.writeFileSync('./release.min.user.js', head + data.replace('$$WUHU_DEV_VERSION$$', version), 'utf8'); +console.log('构建完成'); diff --git a/package.json b/package.json index 67d7bbf..33f6894 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,10 @@ "name": "wuhu-torn-helper", "version": "", "dependencies": { + "uglify-js": "^3.16.1" }, "scripts": { - "uglifyjs": "uglifyjs wuhu-torn-helper.js -o release.min.user.js.js" + "release": "npm run minify && node build.js", + "minify": "uglifyjs wuhu-torn-helper.js -o release.min.user.js -m" } } diff --git a/wuhu-torn-helper.js b/wuhu-torn-helper.js index e720a5e..f3a8db7 100644 --- a/wuhu-torn-helper.js +++ b/wuhu-torn-helper.js @@ -1,17 +1,4 @@ -// ==UserScript== -// @lastmodified 202206172337 -// @name 芜湖助手 -// @namespace WOOH -// @version 0.3.36 -// @description 托恩,起飞! -// @author Woohoo[2687093] Sabrina_Devil[2696209] -// @match https://www.torn.com/* -// @grant GM_xmlhttpRequest -// @grant unsafeWindow -// @connect * -// ==/UserScript== - -(async function () { +!async function () { 'use strict'; const start_timestamp = Date.now(); // unsafewindow副本 @@ -23,7 +10,7 @@ // 防止脚本重复运行 if (window.WHTRANS) return; window.WHTRANS = true; - const version = '0.3.36'; + const version = '$$WUHU_DEV_VERSION$$'; const changelist = [ { todo: true, @@ -10298,4 +10285,4 @@ z-index:100001; } $zhongNode.initTimer.innerHTML = `助手加载时间 ${Date.now() - start_timestamp}ms`; -}()); +}(); \ No newline at end of file