diff --git a/build.js b/build.js new file mode 100644 index 0000000..beed1db --- /dev/null +++ b/build.js @@ -0,0 +1,32 @@ +/* eslint-disable */ + +const { writeFileSync, readFileSync } = require('fs'); + +const extheader = `// ==UserScript== +// @name PNGFileEmbed +// @namespace https://tampermonkey.net/ +// @version 0.1 +// @description uhh +// @author You +// @match https://boards.4channel.org/g/thread/* +// @icon https://www.google.com/s2/favicons?domain=4channel.org +// @grant GM_xmlhttpRequest +// @run-at document-start +// @connect 4chan.org +// @connect 4channel.org +// @connect i.4cdn.org +// ==/UserScript== + +`; + +(async () => { + await require('esbuild').build({ + entryPoints: ['src/main.ts'], + bundle: true, + outfile: 'dist/main.js', + define: { + global: 'window' + } + }); + writeFileSync('./main.user.js', extheader + readFileSync('./dist/main.js')); +})(); diff --git a/main.user.js b/main.user.js index 31f0933..aaebb1b 100644 --- a/main.user.js +++ b/main.user.js @@ -7173,8 +7173,7 @@ return { file: new Blob([ret]), name: container.name }; }; var startup = async () => { - let glow = [...document.querySelectorAll(".postContainer")].find((e) => e.textContent?.includes("191 KB")); - await processPost(glow); + await Promise.all([...document.querySelectorAll(".postContainer")].map((e) => processPost(e))); document.addEventListener("PostsInserted", async (e) => { processPost(e.target); }); diff --git a/package.json b/package.json index e5b1ca5..6cf633a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "esbuild src/main.ts --bundle --outfile=dist/main.js --define:global=window", + "build": "node ./build.js", "watch": "esbuild src/main.ts --bundle --outfile=dist/main.js --define:global=window --watch" }, "author": "",