Skip to content

Commit

Permalink
fix(build): 对脚本打包的 match 元数据进行去重
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Jun 12, 2023
1 parent b8d76a9 commit 9de7d2c
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions scripts/build-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,60 +38,60 @@ async function createUserJs(cb) {
const ocs = require(path.join(distPath, 'index.js'));

const createOptions = () =>
/** @type {import('../packages/utils').CreateOptions} */
({
parseRequire: true,
parseResource: true,
resourceBuilder: (key, value) => `const ${key} = \`${value}\`;`,
metaDataFormatter: {
header: '==UserScript==',
footer: '==/UserScript==',
prefix: '// ',
symbol: '@',
gap: '\t'.repeat(4)
},
metadata: {
name: 'OCS 网课助手',
version: version,
description: `OCS(online-course-script) 网课助手,专注于帮助大学生从网课中释放出来。让自己的时间把握在自己的手中,拥有人性化的操作页面,流畅的步骤提示,支持 ${ocs
.definedProjects()
.filter((p) => p.studyProject)
.map((s) => `【${s.name}】`)
.join(' ')},等网课的学习,作业。具体的功能请查看脚本悬浮窗中的教程页面,OCS官网 https://docs.ocsjs.com 。`,
author: 'enncy',
license: 'MIT',
namespace: 'https://enncy.cn',
homepage: 'https://docs.ocsjs.com',
source: 'https://github.com/ocsjs/ocsjs',
icon: 'https://cdn.ocsjs.com/logo.png',
connect: ['enncy.cn', 'icodef.com', 'ocsjs.com', 'localhost'],
match: ocs
.definedProjects()
.map((p) => p.domains.map((d) => `*://*.${d}/*`))
.flat(),
grant: [
'GM_info',
'GM_getTab',
'GM_saveTab',
'GM_setValue',
'GM_getValue',
'unsafeWindow',
'GM_listValues',
'GM_deleteValue',
'GM_notification',
'GM_xmlhttpRequest',
'GM_getResourceText',
'GM_addValueChangeListener',
'GM_removeValueChangeListener'
],
require: [path.join(__dirname, distPath, 'index.js')],
resource: [`STYLE ${path.join(__dirname, '../packages/scripts/assets/css/style.css')}`],
'run-at': 'document-start',
antifeature: 'payment'
},
entry: path.join(__dirname, '../packages/scripts/entry.js'),
dist: path.join(__dirname, distPath, 'ocs.user.js')
});
/** @type {import('../packages/utils').CreateOptions} */
({
parseRequire: true,
parseResource: true,
resourceBuilder: (key, value) => `const ${key} = \`${value}\`;`,
metaDataFormatter: {
header: '==UserScript==',
footer: '==/UserScript==',
prefix: '// ',
symbol: '@',
gap: '\t'.repeat(4)
},
metadata: {
name: 'OCS 网课助手',
version: version,
description: `OCS(online-course-script) 网课助手,专注于帮助大学生从网课中释放出来。让自己的时间把握在自己的手中,拥有人性化的操作页面,流畅的步骤提示,支持 ${ocs
.definedProjects()
.filter((p) => p.studyProject)
.map((s) => `【${s.name}】`)
.join(' ')},等网课的学习,作业。具体的功能请查看脚本悬浮窗中的教程页面,OCS官网 https://docs.ocsjs.com 。`,
author: 'enncy',
license: 'MIT',
namespace: 'https://enncy.cn',
homepage: 'https://docs.ocsjs.com',
source: 'https://github.com/ocsjs/ocsjs',
icon: 'https://cdn.ocsjs.com/logo.png',
connect: ['enncy.cn', 'icodef.com', 'ocsjs.com', 'localhost'],
match: Array.from(new Set(ocs
.definedProjects()
.map((p) => p.domains.map((d) => `*://*.${d}/*`))
.flat())),
grant: [
'GM_info',
'GM_getTab',
'GM_saveTab',
'GM_setValue',
'GM_getValue',
'unsafeWindow',
'GM_listValues',
'GM_deleteValue',
'GM_notification',
'GM_xmlhttpRequest',
'GM_getResourceText',
'GM_addValueChangeListener',
'GM_removeValueChangeListener'
],
require: [path.join(__dirname, distPath, 'index.js')],
resource: [`STYLE ${path.join(__dirname, '../packages/scripts/assets/css/style.css')}`],
'run-at': 'document-start',
antifeature: 'payment'
},
entry: path.join(__dirname, '../packages/scripts/entry.js'),
dist: path.join(__dirname, distPath, 'ocs.user.js')
});

await createUserScript(createOptions());
const opts = createOptions();
Expand Down

0 comments on commit 9de7d2c

Please sign in to comment.