2022-05-02 19:07:24 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
|
|
|
|
import { spawnSync } from 'child_process';
|
|
|
|
import { writeFileSync, readFileSync, copyFileSync } from 'fs'
|
|
|
|
|
|
|
|
import esbuild from "esbuild";
|
|
|
|
import esbuildSvelte from "esbuild-svelte";
|
|
|
|
import sveltePreprocess from "svelte-preprocess";
|
2022-05-06 00:11:24 +00:00
|
|
|
//import path from 'path';
|
2022-05-02 19:07:24 +00:00
|
|
|
|
2022-05-06 00:11:24 +00:00
|
|
|
//import ChromeExtension from 'crx';
|
2022-05-02 19:07:24 +00:00
|
|
|
|
2022-05-06 00:11:24 +00:00
|
|
|
//const crx = new ChromeExtension({
|
|
|
|
// codebase: 'https://github.com/coomdev/pngextraembedder/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/PEE-chrome.crx',
|
|
|
|
// privateKey: readFileSync('./key.pem')
|
|
|
|
//});
|
2022-05-02 19:07:24 +00:00
|
|
|
|
|
|
|
let res = spawnSync("git", ["rev-list", "--count", "HEAD"]);
|
|
|
|
let rev = +res.stdout;
|
|
|
|
|
|
|
|
const domains = [
|
|
|
|
"https://*.coom.tech/*",
|
2022-06-08 23:06:37 +00:00
|
|
|
"https://*.4chan.org/*",
|
|
|
|
"https://*.4channel.org/*",
|
2022-06-26 19:03:31 +00:00
|
|
|
"https://*.4plebs.org/*",
|
2022-05-02 19:07:24 +00:00
|
|
|
"https://desuarchive.org/*",
|
|
|
|
"https://archived.moe/*",
|
|
|
|
"https://archive.nyafuu.org/*",
|
|
|
|
"https://arch.b4k.co/*",
|
|
|
|
"https://archive.wakarimasen.moe/*",
|
|
|
|
"https://b4k.co/*",
|
|
|
|
"https://fireden.net/*",
|
|
|
|
"https://thebarchive.com/*",
|
|
|
|
"https://archiveofsins.com/*",
|
|
|
|
];
|
|
|
|
|
2022-05-04 03:21:53 +00:00
|
|
|
const manif3 = {
|
2022-06-08 22:35:05 +00:00
|
|
|
manifest_version: 3,
|
2022-05-06 00:11:24 +00:00
|
|
|
// "update_url": "https://github.com/coomdev/pngextraembedder/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/chrome_update.xml",
|
2022-06-08 22:35:05 +00:00
|
|
|
name: "PngExtraEmbedder",
|
|
|
|
description: "Discover embedded files on 4chan and archives!",
|
|
|
|
version: "0." + rev,
|
|
|
|
icons: {
|
|
|
|
64: "1449696017588.png"
|
2022-05-04 03:21:53 +00:00
|
|
|
},
|
2022-06-08 22:35:05 +00:00
|
|
|
permissions: [
|
2022-07-24 17:22:39 +00:00
|
|
|
"storage"
|
2022-05-04 03:21:53 +00:00
|
|
|
],
|
2022-07-18 13:57:11 +00:00
|
|
|
"host_permissions":["<all_urls>"],
|
2022-06-08 22:35:05 +00:00
|
|
|
web_accessible_resources: [{
|
|
|
|
resources: ["*.html", "*.js"],
|
|
|
|
matches: ["<all_urls>"]
|
2022-05-04 03:21:53 +00:00
|
|
|
}],
|
2022-06-08 22:35:05 +00:00
|
|
|
content_scripts: [
|
2022-05-04 03:21:53 +00:00
|
|
|
{
|
2022-06-08 22:35:05 +00:00
|
|
|
matches: domains,
|
|
|
|
css: [],
|
|
|
|
run_at: "document_start",
|
|
|
|
js: ["dist/main.js"],
|
2022-05-04 03:21:53 +00:00
|
|
|
}
|
|
|
|
],
|
2022-07-18 13:57:11 +00:00
|
|
|
// declarative_net_request: {
|
|
|
|
// rule_resources: [
|
|
|
|
// {
|
|
|
|
// id: 'rule1',
|
|
|
|
// enabled: true,
|
|
|
|
// path: 'b4k-csp.json'
|
|
|
|
// }
|
|
|
|
// ]
|
|
|
|
// }
|
2022-05-04 03:21:53 +00:00
|
|
|
};
|
|
|
|
|
2022-05-02 19:07:24 +00:00
|
|
|
(async () => {
|
|
|
|
let res;
|
|
|
|
|
2022-05-04 03:21:53 +00:00
|
|
|
const lmanif = manif3;
|
|
|
|
|
2022-05-02 19:07:24 +00:00
|
|
|
res = await esbuild
|
|
|
|
.build({
|
|
|
|
entryPoints: ["src/main.ts"],
|
|
|
|
bundle: true,
|
|
|
|
treeShaking: true,
|
|
|
|
outfile: "./chrome/dist/main.js",
|
|
|
|
define: {
|
|
|
|
global: 'window',
|
|
|
|
execution_mode: '"chrome_api"',
|
2022-05-04 03:21:53 +00:00
|
|
|
manifest: lmanif.version,
|
2022-05-02 19:07:24 +00:00
|
|
|
isBackground: 'false',
|
|
|
|
BUILD_VERSION: JSON.stringify([0, rev])
|
|
|
|
},
|
|
|
|
inject: ['./esbuild.inject.js'],
|
|
|
|
plugins: [
|
|
|
|
esbuildSvelte({
|
|
|
|
compilerOptions: { css: true, accessors: true },
|
|
|
|
preprocess: sveltePreprocess(),
|
|
|
|
})
|
|
|
|
],
|
|
|
|
loader: {
|
|
|
|
'.css': 'text',
|
|
|
|
'.png': 'binary'
|
|
|
|
},
|
|
|
|
metafile: true
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(res.metafile.inputs);
|
|
|
|
console.log(Object.entries(res.metafile.inputs).sort((a, b) => a[1].bytes - b[1].bytes).map(e => `${e[0]} -> ${e[1].bytes}`).join('\n'));
|
|
|
|
|
|
|
|
res = await esbuild
|
|
|
|
.build({
|
|
|
|
entryPoints: ["src/background.ts"],
|
|
|
|
bundle: true,
|
|
|
|
treeShaking: true,
|
|
|
|
outfile: "./chrome/dist/background.js",
|
|
|
|
define: {
|
|
|
|
global: 'window',
|
|
|
|
execution_mode: '"chrome_api"',
|
2022-05-04 03:21:53 +00:00
|
|
|
manifest: lmanif.version,
|
2022-05-03 00:55:49 +00:00
|
|
|
isBackground: 'true',
|
2022-05-02 19:07:24 +00:00
|
|
|
BUILD_VERSION: JSON.stringify([0, rev])
|
|
|
|
},
|
|
|
|
inject: ['./esbuild.inject.js'],
|
|
|
|
metafile: true
|
|
|
|
});
|
|
|
|
console.log(res.metafile.inputs);
|
|
|
|
console.log(Object.entries(res.metafile.inputs).sort((a, b) => a[1].bytes - b[1].bytes).map(e => `${e[0]} -> ${e[1].bytes}`).join('\n'));
|
|
|
|
|
2022-05-04 03:21:53 +00:00
|
|
|
writeFileSync('./chrome/manifest.json', JSON.stringify(lmanif, null, 2));
|
|
|
|
copyFileSync("./logo.png", "./chrome/1449696017588.png");
|
2022-05-02 19:07:24 +00:00
|
|
|
|
2022-05-06 00:11:24 +00:00
|
|
|
//const ext = await crx.load('./chrome');
|
|
|
|
//const crxBuffer = await ext.pack();
|
|
|
|
//const updateXML = crx.generateUpdateXML();
|
|
|
|
//writeFileSync('./chrome_update.xml', updateXML);
|
|
|
|
//writeFileSync('./PEE-chrome.crx', crxBuffer);
|
2022-05-02 19:07:24 +00:00
|
|
|
})();
|