-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
const { series } = require('gulp'); | ||
const del = require('del'); | ||
const { execOut } = require('../../scripts/utils'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { version } = require('../../package.json'); | ||
|
||
function cleanOutput() { | ||
return del(['./dist']); | ||
} | ||
|
||
function buildUserJs(cb) { | ||
const template = fs.readFileSync(path.join(__dirname, './userjs.template')).toString(); | ||
const script = fs.readFileSync('./dist/index.js').toString(); | ||
const style = fs.readFileSync('./dist/style.css').toString(); | ||
const userjs = template.replace(/{{version}}/g, version).replace(/{{script}}/g, script).replace(/{{style}}/g, style); | ||
fs.writeFileSync('./dist/ocs.user.js', userjs); | ||
cb(); | ||
} | ||
|
||
exports.default = series( | ||
cleanOutput, | ||
series( | ||
() => execOut('vue-tsc --noEmit && vite build --emptyOutDir false -c vite.config.ts'), | ||
() => execOut('vue-tsc --noEmit && vite build --emptyOutDir false -c vite.config.min.ts') | ||
() => execOut('vue-tsc --noEmit && vite build --emptyOutDir false -c vite.config.min.ts'), | ||
buildUserJs | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ==UserScript== | ||
// @name OCS 网课助手 | ||
// @version {{version}} | ||
// @description ocs 网课助手,支持各平台网课学习,支持超星学习通,知道智慧树,等网课的学习,作业,考试功能。 | ||
// @author enncy | ||
// @antifeature payment | ||
// @license MIT | ||
// @namespace https://enncy.cn | ||
// @homepage https://enncy.github.io/online-course-script/ | ||
// @source https://github.com/enncy/online-course-script/ | ||
// @icon https://cdn.ocs.enncy.cn/logo.ico | ||
// @connect enncy.cn | ||
// @connect icodef.com | ||
// @match *://*.chaoxing.com/* | ||
// @match *://*.edu.cn/* | ||
// @match *://*.org.cn/* | ||
// @match *://*.zhihuishu.com/* | ||
// @grant unsafeWindow | ||
// @grant GM_xmlhttpRequest | ||
// @grant GM_setValue | ||
// @grant GM_getValue | ||
// @run-at document-start | ||
// ==/UserScript== | ||
|
||
|
||
{{script}} | ||
|
||
const OCS_STYLE = `{{style}}` | ||
|
||
/* eslint no-undef: 0 */ | ||
|
||
(function () { | ||
"use strict"; | ||
|
||
// 将OCS对象加入到全局属性 | ||
unsafeWindow.OCS = OCS; | ||
// 运行脚本 | ||
OCS.start({ | ||
// 加载样式 | ||
style: OCS_STYLE, | ||
// 支持拖动 | ||
draggable: true, | ||
// 加载默认脚本列表,默认 OCS.definedScripts | ||
scripts: OCS.definedScripts, | ||
}); | ||
})(); | ||
|