mirror of
https://github.com/JosunLP/UserScriptProjectTemplate.git
synced 2025-06-21 10:11:07 +00:00
init
This commit is contained in:
parent
2fc6859169
commit
f61a73f2f6
10 changed files with 3151 additions and 1 deletions
299
.gitignore
vendored
299
.gitignore
vendored
|
@ -1,7 +1,257 @@
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,webstorm,intellij,sublimetext
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio,visualstudiocode,webstorm,intellij,sublimetext
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
# Azure Toolkit for IntelliJ plugin
|
||||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||
.idea/**/azureSettings.xml
|
||||
|
||||
### SublimeText ###
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
sftp-config-alt*.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
# Support for Project snippet scope
|
||||
.vscode/*.code-snippets
|
||||
|
||||
# Ignore code-workspaces
|
||||
*.code-workspace
|
||||
|
||||
### WebStorm ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
|
||||
# AWS User-specific
|
||||
|
||||
# Generated files
|
||||
|
||||
# Sensitive or high-churn files
|
||||
|
||||
# Gradle
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
|
||||
# Mongo Explorer plugin
|
||||
|
||||
# File-based project format
|
||||
|
||||
# IntelliJ
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
|
||||
# JIRA plugin
|
||||
|
||||
# Cursive Clojure plugin
|
||||
|
||||
# SonarLint plugin
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
|
||||
# Editor-based Rest Client
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
|
||||
### WebStorm Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
|
||||
# Azure Toolkit for IntelliJ plugin
|
||||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||
|
||||
### VisualStudio ###
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
|
@ -23,6 +273,7 @@ mono_crash.*
|
|||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
|
@ -61,6 +312,9 @@ project.lock.json
|
|||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
|
@ -86,6 +340,7 @@ StyleCopReport.xml
|
|||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
|
@ -137,6 +392,11 @@ _TeamCity*
|
|||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
@ -284,6 +544,15 @@ node_modules/
|
|||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
|
@ -340,6 +609,9 @@ ASALocalRun/
|
|||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
|
@ -348,3 +620,28 @@ MigrationBackup/
|
|||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
### VisualStudio Patch ###
|
||||
# Additional files built by Visual Studio
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,webstorm,intellij,sublimetext
|
||||
|
||||
dist
|
||||
tools/userScriptHeader.js
|
BIN
assets/icon.afdesign
Normal file
BIN
assets/icon.afdesign
Normal file
Binary file not shown.
BIN
assets/icon.png
Normal file
BIN
assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
26
header.config.json
Normal file
26
header.config.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"updateUrl": "",
|
||||
"downloadUrl": "",
|
||||
"supportUrl": "",
|
||||
"iconUrl": "./assets/icon.png",
|
||||
"includes": [
|
||||
"https://*.ingress.com/intel*"
|
||||
],
|
||||
"excludes": [
|
||||
"https://*.ingress.com/mission/*"
|
||||
],
|
||||
"requires": [],
|
||||
"recources": [],
|
||||
"connecters": [],
|
||||
"matches": [
|
||||
"https://*.ingress.com/intel*"
|
||||
],
|
||||
"runAt": "document-start",
|
||||
"grants": [
|
||||
"GM_setValue",
|
||||
"GM_getValue"
|
||||
],
|
||||
"antifeatures": [],
|
||||
"noframes": false,
|
||||
"unwrap": false
|
||||
}
|
2623
package-lock.json
generated
Normal file
2623
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
34
package.json
Normal file
34
package.json
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "userscript-project-template",
|
||||
"version": "0.0.1",
|
||||
"description": "A user script project template to create large and structured TypeScript projects for Tampermonkey or Greasemonkey. It is intended to form a scalable base and is primarily aimed at the Ingress community.",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"build": "webpack && npm run build-userScriptHeader",
|
||||
"build-tooling": "tsc ./tools/userScriptHeader.ts --target esnext --module esnext --lib ESNext",
|
||||
"build-userScriptHeader": "npm run build-tooling && node ./tools/userScriptHeader.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/JosunLP/UserScriptProjectTemplate.git"
|
||||
},
|
||||
"keywords": [
|
||||
"User",
|
||||
"Script",
|
||||
"TypeScript",
|
||||
"Webpack",
|
||||
"Ingress"
|
||||
],
|
||||
"author": "Jonas Pfalzgraf <info@josunlp.de>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/JosunLP/UserScriptProjectTemplate/issues"
|
||||
},
|
||||
"homepage": "https://github.com/JosunLP/UserScriptProjectTemplate#readme",
|
||||
"devDependencies": {
|
||||
"ts-loader": "^9.3.1",
|
||||
"typescript": "^4.7.4",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
}
|
0
src/index.ts
Normal file
0
src/index.ts
Normal file
135
tools/userScriptHeader.ts
Normal file
135
tools/userScriptHeader.ts
Normal file
|
@ -0,0 +1,135 @@
|
|||
const fs = require("fs");
|
||||
const pkg = require("../package.json");
|
||||
const config = require("../header.config.json");
|
||||
const targetFile = "./dist/" + pkg.name + ".bundle.js";
|
||||
|
||||
/**
|
||||
* Appends header
|
||||
* @param header
|
||||
*/
|
||||
function appendHeader(header: string) {
|
||||
fs.readFile(targetFile, "utf8", (err: any, data: string) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
fs.writeFile(targetFile, header + data, (err: any) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds base64 url from file
|
||||
* @param filePath
|
||||
* @returns
|
||||
*/
|
||||
async function buildBase64UrlFromFile(filePath: string): Promise<string> {
|
||||
const file = await fs.promises.readFile(filePath);
|
||||
return "data:image/png;base64," + file.toString("base64");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates multible entrys
|
||||
* @param type
|
||||
* @param array
|
||||
* @returns multible entrys
|
||||
*/
|
||||
function generateMultibleEntrys(type: string, array: string[]): string {
|
||||
let result: string = "";
|
||||
debugger;
|
||||
if (array) {
|
||||
array.forEach((item: string) => {
|
||||
result += `// ${type} ${item} `;
|
||||
if (array.length > 1) {
|
||||
result += "\n";
|
||||
result += " ";
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes empty lines from string
|
||||
* @param string
|
||||
* @returns empty lines from string
|
||||
*/
|
||||
function removeEmptyLinesFromString(string: string): string {
|
||||
return string.replace(/\n\s*\n/g, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates user script header
|
||||
*/
|
||||
async function generateUserScriptHeader() {
|
||||
const includes = generateMultibleEntrys("@include", config.includes);
|
||||
const excludes = generateMultibleEntrys("@exclude", config.excludes);
|
||||
const requires = generateMultibleEntrys("@require", config.requires);
|
||||
const resources = generateMultibleEntrys("@resource", config.resources);
|
||||
const connecters = generateMultibleEntrys("@connect", config.connecters);
|
||||
const grants = generateMultibleEntrys("@grant", config.grants);
|
||||
const matches = generateMultibleEntrys("@match", config.matches);
|
||||
const antifeatures = generateMultibleEntrys(
|
||||
"@antifeature",
|
||||
config.antifeatures
|
||||
);
|
||||
const base64url = await buildBase64UrlFromFile(config.iconUrl);
|
||||
let noframes = "";
|
||||
let matchAllFrames = "";
|
||||
let updateUrl = "";
|
||||
let downloadUrl = "";
|
||||
let supportUrl = "";
|
||||
|
||||
if (config.noframes) {
|
||||
noframes = `// @noframes
|
||||
`;
|
||||
}
|
||||
if (config.matchAllFrames) {
|
||||
matchAllFrames = `// @matchAllFrames
|
||||
`;
|
||||
}
|
||||
if (config.updateUrl !== "") {
|
||||
updateUrl = `// @updateURL ${config.updateUrl}
|
||||
`;
|
||||
}
|
||||
if (config.downloadUrl !== "") {
|
||||
downloadUrl = `// @downloadURL ${config.downloadUrl}
|
||||
`;
|
||||
}
|
||||
if (config.supportUrl !== "") {
|
||||
supportUrl = `// @supportURL ${config.supportUrl}
|
||||
`;
|
||||
}
|
||||
|
||||
let header = `// ==UserScript==
|
||||
// @name ${pkg.name}
|
||||
// @namespace ${pkg.homepage}
|
||||
// @version ${pkg.version}
|
||||
// @description ${pkg.description}
|
||||
// @author ${pkg.author}
|
||||
// @homepage ${pkg.homepage}
|
||||
// @icon64 ${base64url}
|
||||
// @run-at ${config.runAt}
|
||||
${updateUrl}
|
||||
${downloadUrl}
|
||||
${supportUrl}
|
||||
${includes}
|
||||
${excludes}
|
||||
${requires}
|
||||
${resources}
|
||||
${connecters}
|
||||
${grants}
|
||||
${matches}
|
||||
${antifeatures}
|
||||
${noframes}
|
||||
${matchAllFrames}
|
||||
// ==/UserScript==
|
||||
`;
|
||||
header = removeEmptyLinesFromString(header);
|
||||
console.log(header);
|
||||
// appendHeader(header);
|
||||
}
|
||||
|
||||
generateUserScriptHeader();
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"noImplicitAny": true,
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"allowJs": false,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
24
webpack.config.js
Normal file
24
webpack.config.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const path = require('path');
|
||||
const pkg = require('./package.json');
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.ts',
|
||||
devtool: 'inline-source-map',
|
||||
mode: 'development',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
filename: pkg.name + '.bundle.js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
},
|
||||
};
|
Loading…
Add table
Reference in a new issue