Template for userscripts.
This commit is contained in:
commit
c25f0c361e
6
.env
Normal file
6
.env
Normal file
@ -0,0 +1,6 @@
|
||||
NAME=Userscript template
|
||||
DESCRIPTION=Small template to easily create new Userscript projects
|
||||
VERSION=0.1.0
|
||||
AUTHOR=Midefos
|
||||
NAMESPACE=https://git.midefos.com/midefos
|
||||
MATCH=https://www.*.com
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
app.bundle.js
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Jorge Bolois Guerrero
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Usercript template
|
||||
|
||||
Small template to easily create new Userscript projects.
|
||||
|
||||
It is a UserScript, so you will need a browser extesion to use it. I recommend to use **Tampermonkey** or **Greasymonkey** for managing your UserScripts.
|
||||
|
||||
## Manual compile
|
||||
Clone the repository.
|
||||
|
||||
npm install
|
||||
npm run bundle
|
||||
|
||||
Then use **app.bundle.js** in your prefered browser script manager.
|
7
app.js
Normal file
7
app.js
Normal file
@ -0,0 +1,7 @@
|
||||
import App from "./src/App.js";
|
||||
|
||||
function init() {
|
||||
App.init();
|
||||
}
|
||||
|
||||
init();
|
22
bundler.js
Normal file
22
bundler.js
Normal file
@ -0,0 +1,22 @@
|
||||
import fs from 'fs';
|
||||
import browserify from 'browserify';
|
||||
import dotenv from 'dotenv';
|
||||
import banner from 'browserify-banner';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const STATIC_BANNER = "// ==UserScript==\n" +
|
||||
`// @name ${process.env['NAME']}\n` +
|
||||
`// @description ${process.env['DESCRIPTION']}\n` +
|
||||
`// @version ${process.env['VERSION']}\n` +
|
||||
`// @author ${process.env['AUTHOR']}\n` +
|
||||
`// @namespace ${process.env['NAMESPACE']}\n` +
|
||||
`// @match ${process.env['MATCH']}\n` +
|
||||
"// @license MIT\n" +
|
||||
"// ==/UserScript==\n\n";
|
||||
|
||||
browserify("./app.js")
|
||||
.transform("babelify", { presets: ["@babel/preset-env"] })
|
||||
.plugin(banner, { banner: STATIC_BANNER })
|
||||
.bundle()
|
||||
.pipe(fs.createWriteStream("app.bundle.js"));
|
3906
package-lock.json
generated
Normal file
3906
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "userscript-template",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"bundle": "node bundler.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git"
|
||||
},
|
||||
"author": "Midefos",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/preset-env": "^7.18.6",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "^17.0.0",
|
||||
"browserify-banner": "^2.0.4",
|
||||
"dotenv": "^16.0.3"
|
||||
}
|
||||
}
|
7
src/App.js
Normal file
7
src/App.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default class App {
|
||||
|
||||
static init() {
|
||||
// Logic.
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user