Browse Source

Remove requirement for blob: in userscript mode, remove dead code

pull/54/head
coomdev 2 years ago
parent
commit
4f2e10fcf7
  1. 3
      README.md
  2. 41
      chrome/dist/background.js
  3. 99
      chrome/dist/main.js
  4. 2
      chrome/manifest.json
  5. 114
      dist/main.js
  6. 7
      firefox/dist/background.js
  7. 69
      firefox/dist/main.js
  8. 3
      firefox/manifest.json
  9. 2
      firefox_update.json
  10. 2
      main.meta.js
  11. 116
      main.user.js
  12. BIN
      pngextraembedder-0.324.xpi
  13. 71
      src/main.ts
  14. 14
      src/platform.ts

3
README.md

@ -17,6 +17,7 @@ Note: 4chanX isn't a hard requirement, just recommended because it's overall a n
- [Install ViolentMonkey](https://violentmonkey.github.io/get-it/) (it is preferable to TamperMonkey(closed source) and GreaseMonkey(abandonned shit)), use [ViolentMonkey Beta](https://violentmonkey.github.io/get-it/#beta-release) if you want to spite the b4k meanie admin (based & redpilled). Be sure to read the trouble shooting section to know how to set this up.
- [Install 4chanX (recommended)](https://www.4chan-x.net/builds/4chan-X.user.js)
- Use the prebuilt [main.user.js](https://git.coom.tech/coomdev/PEE/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/main.user.js)
- Reorder PEE and 4chanX in the dashboard so that PEE runs BEFORE 4chanX (or add blob: to your 4chanX JS whitelist)
## The newer way (WIP)
@ -26,7 +27,7 @@ Also, use this if you plan to use b4k's archive.
- [Install 4chanX (recommended)](https://www.4chan-x.net/builds/4chan-X.user.js)
- [Install JKCS (recommended)](https://git.coom.tech/araragi/JKCS/src/branch/master/README.md)
- Install the correct WebExtension for your Browser ([Firefox](https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.322.xpi) or Chrome-based (Down for "maintainance"))
- Install the correct WebExtension for your Browser ([Firefox](https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.324.xpi) or Chrome-based (Down for "maintainance"))
For FF users, the extension is signed so you can just drag and drop it on your about:addons tab.

41
chrome/dist/background.js

@ -1855,6 +1855,36 @@
"esbuild.inject.js"() {
"use strict";
Buffer2 = require_buffer().Buffer;
if (false) {
if (false) {
const ocreate = unsafeWindow.document.createElement.bind(document);
unsafeWindow.document.createElement = (tag) => {
if (tag != "meta")
return ocreate(tag);
unsafeWindow.document.createElement = ocreate;
return unsafeWindow.document.createElement("link");
};
}
if (false) {
if (typeof cloneInto != "undefined")
console.log("CLONE INTO DEFINED");
else
console.log("CLONE INTO NOT DEFINED");
let a = 1;
console.log(a++);
const unsafeWindow2 = window;
console.log(a++);
const ocreate = unsafeWindow2.document.createElement.bind(document);
console.log(a++);
exportFunction((tag) => {
if (tag != "meta")
return ocreate(tag);
unsafeWindow2.document.createElement = ocreate;
return unsafeWindow2.document.createElement("link");
}, window.document, { defineAs: "createElement" });
console.log(a++);
}
}
}
});
@ -1916,16 +1946,7 @@
for (const k of keys)
ctor[k] = bridge(k, ctor[k]);
};
var popupport;
var pendingcmds = {};
if (false) {
popupport = chrome.runtime.connect({ name: "popup" });
popupport.onMessage.addListener((msg) => {
if (msg.id in pendingcmds) {
pendingcmds[msg.id](msg);
delete pendingcmds[msg.id];
}
});
if (true) {
}
var Platform = class {
static async openInTab(src, opts) {

99
chrome/dist/main.js

File diff suppressed because one or more lines are too long

2
chrome/manifest.json

@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!",
"version": "0.323",
"version": "0.324",
"icons": {
"64": "1449696017588.png"
},

114
dist/main.js

File diff suppressed because one or more lines are too long

7
firefox/dist/background.js

@ -1947,13 +1947,6 @@
ctor[k] = bridge(k, ctor[k]);
};
if (false) {
popupport = chrome.runtime.connect({ name: "popup" });
popupport.onMessage.addListener((msg) => {
if (msg.id in pendingcmds) {
pendingcmds[msg.id](msg);
delete pendingcmds[msg.id];
}
});
}
var Platform = class {
static async openInTab(src, opts) {

69
firefox/dist/main.js

File diff suppressed because one or more lines are too long

3
firefox/manifest.json

@ -7,7 +7,7 @@
},
"name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!",
"version": "0.323",
"version": "0.324",
"icons": {
"64": "1449696017588.png"
},
@ -100,7 +100,6 @@
"css": [],
"run_at": "document_start",
"js": [
"polyfill.min.js",
"dist/main.js"
]
}

2
firefox_update.json

@ -1 +1 @@
{"addons":{"{34ac4994-07f2-44d2-8599-682516a6c6a6}":{"updates":[{"version":"0.323","update_link":"https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.323.xpi"}]}}}
{"addons":{"{34ac4994-07f2-44d2-8599-682516a6c6a6}":{"updates":[{"version":"0.324","update_link":"https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.324.xpi"}]}}}

2
main.meta.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.320
// @version 0.324
// @description uhh
// @author You
// @match https://boards.4channel.org/*

116
main.user.js

File diff suppressed because one or more lines are too long

BIN
pngextraembedder-0.324.xpi

Binary file not shown.

71
src/main.ts

@ -801,6 +801,42 @@ const startup = async (is4chanX = true) => {
await bodyInit;
}
document.addEventListener('QRDialogCreation', <any>((e: CustomEvent<HTMLElement>) => {
const a = document.createElement('span');
const po = new PostOptions({
target: a,
props: { processors, textinput: (e.detail || e.target).querySelector('textarea')! }
});
let prevFile: File;
let target;
const somethingChanged = async (m: any) => {
// file possibly changed
const currentFile = await getSelectedFile();
if (prevFile != currentFile) {
prevFile = currentFile;
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
}
};
const obs = new MutationObserver(somethingChanged);
if (!cappState.is4chanX) {
target = e.detail;
a.style.display = "inline-block";
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
const filesinp = target.querySelector('#qrFile') as HTMLInputElement;
filesinp.addEventListener("change", somethingChanged);
}
else {
target = e.target as HTMLDivElement;
target.querySelector('#qr-filename-container')?.appendChild(a);
const filesinp = target.querySelector('#file-n-submit') as HTMLInputElement;
obs.observe(filesinp, { attributes: true });
}
}), { once: !cappState!.is4chanX }); // 4chan's normal extension destroys the QR form everytime
try {
cp = new CommandProcessor();
} catch {
@ -948,41 +984,6 @@ document.addEventListener('ThreadUpdate', <any>(async (e: CustomEvent<any>) => {
}
}));
document.addEventListener('QRDialogCreation', <any>((e: CustomEvent<HTMLElement>) => {
const a = document.createElement('span');
const po = new PostOptions({
target: a,
props: { processors, textinput: (e.detail || e.target).querySelector('textarea')! }
});
let prevFile: File;
let target;
const somethingChanged = async (m: any) => {
// file possibly changed
const currentFile = await getSelectedFile();
if (prevFile != currentFile) {
prevFile = currentFile;
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
}
};
const obs = new MutationObserver(somethingChanged);
if (!cappState.is4chanX) {
target = e.detail;
a.style.display = "inline-block";
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
const filesinp = target.querySelector('#qrFile') as HTMLInputElement;
filesinp.addEventListener("change", somethingChanged);
}
else {
target = e.target as HTMLDivElement;
target.querySelector('#qr-filename-container')?.appendChild(a);
const filesinp = target.querySelector('#file-n-submit') as HTMLInputElement;
obs.observe(filesinp, { attributes: true });
}
}), { once: !cappState!.is4chanX }); // 4chan's normal extension destroys the QR form everytime
function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) {
if (ress.length == 0)
return;

14
src/platform.ts

@ -138,13 +138,13 @@ let popupport: browser.runtime.Port;
const pendingcmds: Record<number, (v?: any) => void> = {};
if (execution_mode == "chrome_api") {
popupport = chrome.runtime.connect({ name: 'popup' });
popupport.onMessage.addListener((msg: any) => {
if (msg.id in pendingcmds) {
pendingcmds[msg.id](msg);
delete pendingcmds[msg.id];
}
});
//popupport = chrome.runtime.connect({ name: 'popup' });
//popupport.onMessage.addListener((msg: any) => {
// if (msg.id in pendingcmds) {
// pendingcmds[msg.id](msg);
// delete pendingcmds[msg.id];
// }
//});
}
// Used to call background-only APIs from content scripts
@Bridged

Loading…
Cancel
Save