diff --git a/PEE-chrome.crx b/PEE-chrome.crx
index 72c0322..a472ff4 100644
Binary files a/PEE-chrome.crx and b/PEE-chrome.crx differ
diff --git a/README.md b/README.md
index 7addf78..9ce9125 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Note: 4chanX isn't a hard requirement, just recommended because it's overall a n
## The newer way (WIP)
- [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/coomdev/PEE/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.208-an+fx.xpi) or [Chrome-based](https://git.coom.tech/coomdev/PEE/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/PEE-chrome.crx))
+- Install the correct WebExtension for your Browser ([Firefox](https://git.coom.tech/coomdev/PEE/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pngextraembedder-0.210-an+fx.xpi) or [Chrome-based](https://git.coom.tech/coomdev/PEE/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/PEE-chrome.crx))
How to Build
============
diff --git a/chrome/manifest.json b/chrome/manifest.json
index 00356b8..e31871a 100644
--- a/chrome/manifest.json
+++ b/chrome/manifest.json
@@ -3,7 +3,7 @@
"update_url": "https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/chrome_update.xml",
"name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!",
- "version": "0.209",
+ "version": "0.210",
"icons": {
"64": "1449696017588.png"
},
diff --git a/chrome_update.xml b/chrome_update.xml
index 8ec254e..06fe8c0 100644
--- a/chrome_update.xml
+++ b/chrome_update.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/extheader.js b/extheader.js
index 6884422..553b80d 100644
--- a/extheader.js
+++ b/extheader.js
@@ -28,6 +28,7 @@ export const extheader = `// ==UserScript==
// @grant GM.setValue
// @grant GM_openInTab
// @grant GM.openInTab
+// @grant GM_addElement
// @grant unsafeWindow
// @run-at document-start
// @connect 4chan.org
diff --git a/firefox/manifest.json b/firefox/manifest.json
index 9dc3214..74c8119 100644
--- a/firefox/manifest.json
+++ b/firefox/manifest.json
@@ -7,7 +7,7 @@
},
"name": "PngExtraEmbedder",
"description": "Discover embedded files on 4chan and archives!",
- "version": "0.208",
+ "version": "0.210",
"icons": {
"64": "1449696017588.png"
},
diff --git a/firefox_update.json b/firefox_update.json
index 2521b9e..1c065a0 100644
--- a/firefox_update.json
+++ b/firefox_update.json
@@ -1 +1 @@
-{"addons":{"{34ac4994-07f2-44d2-8599-682516a6c6a6}":{"updates":[{"version":"0.208","update_link":"https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pee-firefox.zip"}]}}}
\ No newline at end of file
+{"addons":{"{34ac4994-07f2-44d2-8599-682516a6c6a6}":{"updates":[{"version":"0.210","update_link":"https://git.coom.tech/fuckjannies/lolipiss/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/pee-firefox.zip"}]}}}
\ No newline at end of file
diff --git a/pngextraembedder-0.208-an+fx.xpi b/pngextraembedder-0.208-an+fx.xpi
deleted file mode 100644
index 30afa9d..0000000
Binary files a/pngextraembedder-0.208-an+fx.xpi and /dev/null differ
diff --git a/pngextraembedder-0.210-an+fx.xpi b/pngextraembedder-0.210-an+fx.xpi
new file mode 100644
index 0000000..4cb9e94
Binary files /dev/null and b/pngextraembedder-0.210-an+fx.xpi differ
diff --git a/src/background.ts b/src/background.ts
index 98447a1..3881418 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -142,14 +142,18 @@ const bgCorsFetch = async (c: browser.runtime.Port, id: number, input: string, i
let buff: Buffer[] = [];
+ const ctotal = +headerObj['content-length'] || 0; // content total
+ let ltotal = 0; // loaded total
+
// sequence number, required to reorder messages client-side
// if they get processed out of order
let s = 0;
const e = {
write(chunk: Uint8Array) {
+ ltotal += chunk.byteLength;
+ c.postMessage({ id, progress: [ltotal, ctotal] });
if (!pendingFetches.get(c)![id].fetchFully) {
const url = URL.createObjectURL(new Blob([chunk]));
- console.log('created blob of size', chunk.byteLength);
c.postMessage({ id, s: s++, pushData: { data: url } });
} else {
buff.push(Buffer.from(chunk));
diff --git a/src/platform.ts b/src/platform.ts
index 193ce84..e3bf656 100644
--- a/src/platform.ts
+++ b/src/platform.ts
@@ -69,7 +69,7 @@ const extrBlob = async (url: string) => {
return new Uint8Array(ret);
};
-export const corsFetch = async (input: string, init?: RequestInit) => {
+export const corsFetch = async (input: string, init?: RequestInit, lsn?: EventTarget) => {
const id = gid++;
/* if (init) {
@@ -106,6 +106,12 @@ export const corsFetch = async (input: string, init?: RequestInit) => {
const cmdbuff: any[] = [];
lqueue[id] = (async (e: any) => {
+ // this is computed from the background script because the content script may
+ // request everything to be delivered in one chunk, defeating the purpose
+ if (e.progress) {
+ lsn?.dispatchEvent(new CustomEvent("progress", { detail: e.progress }));
+ }
+
if (e.pushData) {
if (e.s > s) {
// insert before an hypothetical cmd with a higher seq number
@@ -125,8 +131,10 @@ export const corsFetch = async (input: string, init?: RequestInit) => {
// this also means that cmdbuff must contain 0 or more ordered commands that must be processed
// afterward until discontinuity
const processCmd = async (e: any) => {
+
if (e.pushData.data) {
const data = await extrBlob(e.pushData.data);
+
if (gcontroller)
gcontroller.enqueue(data);
else
@@ -169,17 +177,9 @@ export const corsFetch = async (input: string, init?: RequestInit) => {
return ret;
};
- const blob = async () => {
- return new Blob([await arrayBuffer()]);
- };
-
- const text = async () => {
- return new TextDecoder().decode(await arrayBuffer());
- };
-
- const json = async () => {
- return JSON.parse(await text());
- };
+ const blob = async () => new Blob([await arrayBuffer()]);
+ const text = async () => new TextDecoder().decode(await arrayBuffer());
+ const json = async () => JSON.parse(await text());
if (e.ok)
_({
@@ -227,7 +227,7 @@ export async function getHeaders(s: string) {
export async function ifetch(...[url, opt, lisn]: [...Parameters, EventTarget?]): ReturnType {
if (execution_mode != "userscript")
- return corsFetch(url.toString(), opt);
+ return corsFetch(url.toString(), opt, lisn);
return GM_fetch(url, opt, lisn);
}