Browse Source

Fix fireshit, and some possible init order issues.

pull/46/head
coomdev 2 years ago
parent
commit
9a8ec9acbf
  1. BIN
      2017-07-21_21h19_18.png
  2. 2
      README.md
  3. 16
      chrome/dist/background.js
  4. 32
      chrome/dist/main.js
  5. 2
      chrome/manifest.json
  6. 33
      dist/main.js
  7. BIN
      efdb47d2f0e04144bbaa-0.302.xpi
  8. 16
      firefox/dist/background.js
  9. 32
      firefox/dist/main.js
  10. 2
      firefox/manifest.json
  11. 2
      firefox_update.json
  12. 2
      main.meta.js
  13. 35
      main.user.js
  14. BIN
      pngextraembedder-0.305.xpi
  15. 17
      src/main.ts
  16. 16
      src/platform.ts
  17. 6
      src/processor.worker.ts

BIN
2017-07-21_21h19_18.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

2
README.md

@ -25,7 +25,7 @@ Please report any issue you have with those (only for mainstream browsers)
Also, use this if you plan to use b4k's archive. 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 4chanX (recommended)](https://www.4chan-x.net/builds/4chan-X.user.js)
- 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.302.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.305.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. For FF users, the extension is signed so you can just drag and drop it on your about:addons tab.

16
chrome/dist/background.js

@ -1877,22 +1877,6 @@
var localSet = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value)); var localSet = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value));
var port1; var port1;
console.log("chrome_api", true); console.log("chrome_api", true);
if (false) {
iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.name = location.origin;
const iframeloaded = new Promise((_) => {
iframe.onload = _;
});
iframe.src = `${chrome.runtime.getURL("")}options.html`;
document.documentElement.appendChild(iframe);
iframeloaded.then(() => {
port1 = genPort();
port1.onmessage = (ev) => {
lqueue[ev.data.id](ev.data);
};
});
}
if (false) { if (false) {
port1 = { port1 = {
onmessage(ev) { onmessage(ev) {

32
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, "manifest_version": 3,
"name": "PngExtraEmbedder", "name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!", "description": "Discover embedded files on 4chan and archives!",
"version": "0.302", "version": "0.305",
"icons": { "icons": {
"64": "1449696017588.png" "64": "1449696017588.png"
}, },

33
dist/main.js

File diff suppressed because one or more lines are too long

BIN
efdb47d2f0e04144bbaa-0.302.xpi

Binary file not shown.

16
firefox/dist/background.js

@ -1877,22 +1877,6 @@
var localSet = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value)); var localSet = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value));
var port1; var port1;
console.log("ff_api", true); console.log("ff_api", true);
if (false) {
iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.name = location.origin;
const iframeloaded = new Promise((_) => {
iframe.onload = _;
});
iframe.src = `${chrome.runtime.getURL("")}options.html`;
document.documentElement.appendChild(iframe);
iframeloaded.then(() => {
port1 = genPort();
port1.onmessage = (ev) => {
lqueue[ev.data.id](ev.data);
};
});
}
if (false) { if (false) {
port1 = { port1 = {
onmessage(ev) { onmessage(ev) {

32
firefox/dist/main.js

File diff suppressed because one or more lines are too long

2
firefox/manifest.json

@ -7,7 +7,7 @@
}, },
"name": "PngExtraEmbedder", "name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!", "description": "Discover embedded files on 4chan and archives!",
"version": "0.302", "version": "0.305",
"icons": { "icons": {
"64": "1449696017588.png" "64": "1449696017588.png"
}, },

2
firefox_update.json

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

2
main.meta.js

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

35
main.user.js

File diff suppressed because one or more lines are too long

BIN
pngextraembedder-0.305.xpi

Binary file not shown.

17
src/main.ts

@ -23,7 +23,7 @@ import NotificationsHandler from './Components/NotificationsHandler.svelte';
import { fireNotification, getEmbedsFromCache, getSelectedFile } from "./utils"; import { fireNotification, getEmbedsFromCache, getSelectedFile } from "./utils";
import { getQueryProcessor, QueryProcessor } from "./websites"; import { getQueryProcessor, QueryProcessor } from "./websites";
import { ifetch, Platform, sendCmd, lqueue, supportedAltDomain, supportedMainDomain, genPort } from "./platform"; import { ifetch, Platform, sendCmd, lqueue, supportedAltDomain, supportedMainDomain, genPort, initMainIPC } from "./platform";
import TextEmbeddingsSvelte from "./Components/TextEmbeddings.svelte"; import TextEmbeddingsSvelte from "./Components/TextEmbeddings.svelte";
import { HydrusClient } from "./hydrus"; import { HydrusClient } from "./hydrus";
import { registerPlugin } from 'linkifyjs'; import { registerPlugin } from 'linkifyjs';
@ -401,10 +401,10 @@ class CommandProcessor {
const convertToLocalEmbed = (wef: WorkerEmbeddedFile) => { const convertToLocalEmbed = (wef: WorkerEmbeddedFile) => {
let ret: EmbeddedFileWithPreview; let ret: EmbeddedFileWithPreview;
ret = wef as any; ret = {...wef} as any;
// handles bigger files where data is represented as a {url, header} object // handles bigger files where data is represented as a {url, header} object
if (typeof wef.data == "object") { if (typeof wef.data == "object") {
if (!(wef.data instanceof Uint8Array)) { if ('url' in wef.data) {
const ref = wef.data; const ref = wef.data;
if (!wef.thumbnail) if (!wef.thumbnail)
return wef; return wef;
@ -418,10 +418,10 @@ const convertToLocalEmbed = (wef: WorkerEmbeddedFile) => {
} }
} }
if (wef.data instanceof Uint8Array) { if (typeof wef.data != "string" && !('url' in wef.data)) {
ret.data = Buffer.from(wef.data); ret.data = Buffer.from(wef.data);
} }
if (wef.thumbnail instanceof Uint8Array) { if (wef.thumbnail && typeof wef.thumbnail != "string") {
ret.thumbnail = Buffer.from(wef.thumbnail); ret.thumbnail = Buffer.from(wef.thumbnail);
} }
return ret!; return ret!;
@ -681,6 +681,9 @@ const startup = async (is4chanX = true) => {
else else
qp = lqp; qp = lqp;
if (execution_mode != 'userscript')
await initMainIPC();
const nset = await localLoad('settingsv2', initial_settings); const nset = await localLoad('settingsv2', initial_settings);
settings.set(nset); settings.set(nset);
@ -759,8 +762,6 @@ const startup = async (is4chanX = true) => {
el = [e]; el = [e];
if (el) { if (el) {
appState.update(v => { appState.update(v => {
console.log("ADDED FROM MUTATION UPDATE", el.length);
v.processing += el.length; v.processing += el.length;
return v; return v;
}); });
@ -849,9 +850,7 @@ const startup = async (is4chanX = true) => {
//console.log(posts); //console.log(posts);
const range = ~~(posts.length / n) + 1; const range = ~~(posts.length / n) + 1;
appState.update(v => { appState.update(v => {
console.log("ADDED FROM INIT", posts.length);
v.processing += posts.length; v.processing += posts.length;
console.log("NOW IS", v.processing);
return v; return v;
}); });

16
src/platform.ts

@ -22,8 +22,7 @@ export const genPort = () => {
return port1; return port1;
}; };
if (execution_mode != 'userscript' && !isBackground && execution_mode != 'worker') { export const initMainIPC = async () => {
// It has to be a content script
iframe = document.createElement('iframe'); iframe = document.createElement('iframe');
iframe.style.display = 'none'; iframe.style.display = 'none';
iframe.name = location.origin; iframe.name = location.origin;
@ -33,13 +32,12 @@ if (execution_mode != 'userscript' && !isBackground && execution_mode != 'worker
iframe.src = `${chrome.runtime.getURL('')}options.html`; iframe.src = `${chrome.runtime.getURL('')}options.html`;
//const meself = new URL(chrome.runtime.getURL('')).origin; //const meself = new URL(chrome.runtime.getURL('')).origin;
document.documentElement.appendChild(iframe); document.documentElement.appendChild(iframe);
iframeloaded.then(() => { await iframeloaded;
port1 = genPort(); port1 = genPort();
port1.onmessage = (ev) => { port1.onmessage = (ev) => {
lqueue[ev.data.id](ev.data); lqueue[ev.data.id](ev.data);
}; };
}); };
}
let msgBuff: [any, Transferable[] | undefined][] = []; let msgBuff: [any, Transferable[] | undefined][] = [];

6
src/processor.worker.ts

@ -188,9 +188,9 @@ let init = false;
const tr: Transferable[] = []; const tr: Transferable[] = [];
for (const ef of res) { for (const ef of res) {
for (const e of ef[0]) { for (const e of ef[0]) {
if (Buffer.isBuffer(e.thumbnail) || e.thumbnail instanceof Uint8Array) if (e.thumbnail && Buffer.isBuffer(e.thumbnail) || typeof e.thumbnail != "string")
tr.push(e.thumbnail.buffer); tr.push(e.thumbnail!.buffer);
if (Buffer.isBuffer(e.data) || e.data instanceof Uint8Array) if (Buffer.isBuffer(e.data) || (typeof e.data != 'string' && !('url' in e.data)))
tr.push(e.data.buffer); tr.push(e.data.buffer);
} }
} }

Loading…
Cancel
Save