initial commit
This commit is contained in:
commit
70ccf22939
14 changed files with 1327 additions and 0 deletions
31
.devcontainer/devcontainer.json
Normal file
31
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||||
|
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
|
||||||
|
{
|
||||||
|
"name": "Node.js & TypeScript",
|
||||||
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm",
|
||||||
|
|
||||||
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/git-lfs:1": {}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
// "postCreateCommand": "yarn install",
|
||||||
|
"postStartCommand": "yarn install",
|
||||||
|
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xcf filter=lfs diff=lfs merge=lfs -text
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/node_modules/
|
||||||
|
/dist/
|
15
.vscode/settings.json
vendored
Normal file
15
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports": "explicit"
|
||||||
|
},
|
||||||
|
"git.closeDiffOnOperation": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"prettier.trailingComma": "all",
|
||||||
|
}
|
16
.vscode/tasks.json
vendored
Normal file
16
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "build",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [],
|
||||||
|
"label": "npm: build",
|
||||||
|
"detail": "webpack --config webpack.config.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
BIN
gfx/bttv.xcf
(Stored with Git LFS)
Normal file
BIN
gfx/bttv.xcf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
gfx/bttv_original.png
(Stored with Git LFS)
Normal file
BIN
gfx/bttv_original.png
(Stored with Git LFS)
Normal file
Binary file not shown.
18
package.json
Normal file
18
package.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "lmlfc-bttv",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "Jörn-Michael Miehe <joern-michael.miehe@lenaisten.de>",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --config webpack.config.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/chrome": "^0.0.254",
|
||||||
|
"copy-webpack-plugin": "^11.0.0",
|
||||||
|
"prettier": "^3.1.1",
|
||||||
|
"ts-loader": "^9.5.1",
|
||||||
|
"typescript": "^5.3.3",
|
||||||
|
"webpack": "^5.89.0",
|
||||||
|
"webpack-cli": "^5.1.4"
|
||||||
|
}
|
||||||
|
}
|
BIN
public/bttv.png
(Stored with Git LFS)
Normal file
BIN
public/bttv.png
(Stored with Git LFS)
Normal file
Binary file not shown.
18
public/manifest.json
Normal file
18
public/manifest.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"manifest_version": 3,
|
||||||
|
"name": "LMLFC-BTTV",
|
||||||
|
"version": "1.0",
|
||||||
|
"description": "Add the reading time to Chrome Extension documentation articles",
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"js": ["main.js"],
|
||||||
|
"matches": ["*://*.lenameyerlandrut-fanclub.de/*"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"web_accessible_resources": [
|
||||||
|
{
|
||||||
|
"resources": ["bttv.png"],
|
||||||
|
"matches": ["*://*.lenameyerlandrut-fanclub.de/*"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
src/main.ts
Normal file
47
src/main.ts
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const emote_regex = /bttv:([^\s]+)/g;
|
||||||
|
|
||||||
|
async function bttv_get_url(code: string): Promise<string> {
|
||||||
|
return "changed from ext";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function process_text(text: string): Promise<string> {
|
||||||
|
const emotes = text.matchAll(emote_regex);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
const cb_form = document.querySelector("#mgc_cb_evo_form");
|
||||||
|
if (!(cb_form instanceof HTMLFormElement)) return;
|
||||||
|
|
||||||
|
const bttv_btn = (() => {
|
||||||
|
const btn = document.createElement("a");
|
||||||
|
btn.style.setProperty("cursor", "pointer");
|
||||||
|
btn.style.setProperty("margin-right", "4px");
|
||||||
|
|
||||||
|
const img = document.createElement("img");
|
||||||
|
img.setAttribute("src", chrome.runtime.getURL("bttv.png"));
|
||||||
|
img.style.setProperty("max-height", "25px");
|
||||||
|
img.style.setProperty("max-width", "25px");
|
||||||
|
img.style.setProperty("vertical-align", "middle");
|
||||||
|
|
||||||
|
btn.addEventListener("click", async (event) => {
|
||||||
|
const cb_input = document.querySelector("#mgc_cb_evo_input");
|
||||||
|
if (!(cb_input instanceof HTMLInputElement)) return;
|
||||||
|
|
||||||
|
cb_input.focus();
|
||||||
|
cb_input.value += await bttv_get_url("foo bar");
|
||||||
|
cb_input.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
btn.appendChild(img);
|
||||||
|
return btn;
|
||||||
|
})();
|
||||||
|
|
||||||
|
cb_form.insertBefore(
|
||||||
|
bttv_btn,
|
||||||
|
document.querySelector("#mgc_cb_evo_form > input[type=image]:nth-child(2)"),
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("done.");
|
||||||
|
})();
|
13
tsconfig.json
Normal file
13
tsconfig.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es6",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"rootDir": "src",
|
||||||
|
"outDir": "dist/js",
|
||||||
|
"noEmitOnError": true,
|
||||||
|
"typeRoots": ["node_modules/@types"]
|
||||||
|
}
|
||||||
|
}
|
29
webpack.config.js
Normal file
29
webpack.config.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const path = require("path");
|
||||||
|
const CopyPlugin = require("copy-webpack-plugin");
|
||||||
|
module.exports = {
|
||||||
|
mode: "production",
|
||||||
|
entry: {
|
||||||
|
main: path.join(__dirname, "src", "main.ts"),
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: path.join(__dirname, "dist"),
|
||||||
|
filename: "[name].js",
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".js"],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
loader: "ts-loader",
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CopyPlugin({
|
||||||
|
patterns: [{ from: ".", to: ".", context: "public" }],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
Loading…
Reference in a new issue