diff --git a/build.js b/build.js index 7dd3a97..5dbfcc8 100644 --- a/build.js +++ b/build.js @@ -11,8 +11,8 @@ const extheader = `// ==UserScript== // @version 0.${rev} // @description uhh // @author You -// @match https://boards.4channel.org/*/thread/* -// @match https://boards.4chan.org/*/thread/* +// @match https://boards.4channel.org/* +// @match https://boards.4chan.org/* // @icon https://www.google.com/s2/favicons?domain=4channel.org // @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js // @updateURL https://git.coom.tech/coomdev/PEE/raw/branch/%e4%b8%ad%e5%87%ba%e3%81%97/main.user.js diff --git a/main.user.js b/main.user.js index c94730b..853060a 100644 --- a/main.user.js +++ b/main.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.41 +// @version 0.42 // @description uhh // @author You -// @match https://boards.4channel.org/*/thread/* -// @match https://boards.4chan.org/*/thread/* +// @match https://boards.4channel.org/* +// @match https://boards.4chan.org/* // @icon https://www.google.com/s2/favicons?domain=4channel.org // @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js // @updateURL https://git.coom.tech/coomdev/PEE/raw/branch/%e4%b8%ad%e5%87%ba%e3%81%97/main.user.js @@ -12624,7 +12624,6 @@ if (!("content-length" in obj)) return; const len = +obj["content-length"]; - console.log("completed read of ", len); ptr += len; if (fetchRestOnNonCanceled) fetchSize = size; @@ -12781,12 +12780,18 @@ for (const rec of reco) if (rec.type == "childList") rec.addedNodes.forEach((e) => { - const el = e.querySelector(".postContainer"); + if (!(e instanceof HTMLElement)) + return; + const el = e.querySelectorAll(".postContainer"); if (el) - processPost(el); + [...el].map((el2) => processPost(el2)); }); }); - mo.observe(document.querySelector(".thread"), { childList: true, subtree: true }); + document.querySelectorAll(".board").forEach((e) => { + mo.observe(e, { childList: true, subtree: true }); + }); + const posts = [...document.querySelectorAll(".postContainer")]; + await Promise.all(posts.map((e) => processPost(e))); const getSelectedFile = () => { return new Promise((res) => { document.addEventListener("QRFile", (e) => res(e.detail), { once: true }); @@ -12845,7 +12850,6 @@ input.click(); }; }); - await Promise.all([...document.querySelectorAll(".postContainer")].map((e) => processPost(e))); }; document.addEventListener("4chanXInitFinished", startup); var customStyles = document.createElement("style"); diff --git a/src/main.ts b/src/main.ts index bc87c08..a4d1673 100644 --- a/src/main.ts +++ b/src/main.ts @@ -289,13 +289,19 @@ const startup = async () => { for (const rec of reco) if (rec.type == "childList") rec.addedNodes.forEach(e => { - const el = (e as any).querySelector(".postContainer"); + if (!(e instanceof HTMLElement)) + return; + const el = (e as any).querySelectorAll(".postContainer"); if (el) - processPost(el as any); + [...el].map(el => processPost(el as any)); }); }); - mo.observe(document.querySelector('.thread')!, { childList: true, subtree: true }); + document.querySelectorAll('.board').forEach(e => { + mo.observe(e!, { childList: true, subtree: true }); + }); + const posts = [...document.querySelectorAll('.postContainer')]; + await Promise.all(posts.map(e => processPost(e as any))); const getSelectedFile = () => { return new Promise(res => { @@ -357,9 +363,6 @@ const startup = async () => { input.click(); }; })); - - await Promise.all([...document.querySelectorAll('.postContainer')].map(e => processPost(e as any))); - }; document.addEventListener('4chanXInitFinished', startup);