Commit 91dd8db6 authored by Akari Labs's avatar Akari Labs

allow configuring userscript header match

parent c00a89b0
......@@ -90,5 +90,8 @@ typings/
# build output
dist/
# config
buildconfig.json
# annoying thing dolphin does
.directory
\ No newline at end of file
const path = require('path');
const fs = require('fs');
if (fs.existsSync(path.resolve('config.json'))) module.exports = require('../config.json')
else module.exports = {
"domains": {
"pleroma": "example.com",
"rocketchat": "example.com"
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ module.exports = merge(require('./webpack.base.config'), {
filename: 'gltchrr_discord.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for Discord', match: 'https://discordapp.com/*' })
wrap.credit(),
wrap.userscript({name: 'gltchrr for Discord', match: ['discordapp.com', '*.discordapp.com'] })
]
});
\ No newline at end of file
const merge = require('webpack-merge');
const wrap = require('./wrap');
const config = require('./config');
module.exports = merge(require('./webpack.base.config'), {
entry: './src/pleromafe/index.js',
......@@ -8,6 +9,7 @@ module.exports = merge(require('./webpack.base.config'), {
filename: 'gltchrr_pleroma.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for PleromaFE', match: 'https://example.com/*' })
wrap.credit(),
wrap.userscript({name: 'gltchrr for PleromaFE', match: config.domains.pleroma })
]
});
\ No newline at end of file
const merge = require('webpack-merge');
const wrap = require('./wrap');
const config = require('./config');
module.exports = merge(require('./webpack.base.config'), {
entry: './src/rocketchat/index.js',
......@@ -8,6 +9,7 @@ module.exports = merge(require('./webpack.base.config'), {
filename: 'gltchrr_rocketchat.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for rocket.chat', match: 'https://example.com/*' })
wrap.credit(),
wrap.userscript({name: 'gltchrr for rocket.chat', match: config.domains.rocketchat })
]
});
\ No newline at end of file
......@@ -3,6 +3,8 @@ const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const wrap = require('./wrap');
const dev = process.env.NODE_ENV === 'dev';
module.exports = merge(require('./webpack.base.config'), {
......
const WrapperPlugin = require('wrapper-webpack-plugin');
const baseSettings = {
afterOptimizations: true
afterOptimizations: true,
match: /\.js$/
}
function getWrapper(match, header, footer) {
function getWrapper(header, footer) {
return new WrapperPlugin(Object.assign({
match, header, footer
header, footer
}, baseSettings));
}
module.exports = {
userscript({ name, match }) {
return getWrapper(/\.js$/,
`// ==UserScript==
if (!Array.isArray(match)) match = [match];
return getWrapper(`// ==UserScript==
// @name ${name}
// @description g̴̐͋litcc̣̟̭̿cch
// @author lp0 and nocebo
// @match ${match}
${match.map(x => `// @match https://${x}/*`).join('\n')}
// @grant none
// @run-at document-start
// ==/UserScript==
`);
},
credit() {
return getWrapper('/* created by caela and atsuko | licensed under MIT | source code available at https://git.agiri.ninja/akari/gltchrr */\n');
}
};
\ No newline at end of file
{
"domains": {
"pleroma": ["cathoderay.tube", "lewd.fedi.cathoderay.tube", "girldick.icu"],
"rocketchat": "meow.natalie.ee"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment