From a2f759b5669f8cfae9bf2d9429add4e8caec7bf8 Mon Sep 17 00:00:00 2001 From: coomdev Date: Sun, 9 Jan 2022 23:39:02 +0100 Subject: [PATCH] Accidentally broke catalog --- main.meta.js | 2 +- main.user.js | 13 +++---------- src/main.ts | 12 ++---------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/main.meta.js b/main.meta.js index 8f4782f..802c2f4 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.109 +// @version 0.110 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index 05a1b63..6bdc944 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.109 +// @version 0.110 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -16393,6 +16393,7 @@ }); }); document.querySelectorAll(".board").forEach((e) => { + mo.observe(e, { childList: true, subtree: true }); }); const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')]; const scts = document.getElementById("shortcuts"); @@ -16412,20 +16413,12 @@ isCatalog: !!document.querySelector(".catalog-small") || !!location.pathname.match(/\/catalog$/) }); const n = 7; - const range = ~~(posts.length / n); + const range = ~~(posts.length / n) + 1; await Promise.all([...new Array(n + 1)].map(async (e, i) => { - console.log(i * range, (i + 1) * range, posts.length); const postsslice = posts.slice(i * range, (i + 1) * range); - let k = i * range; for (const post of postsslice) { - if (i == 6) - console.log("before Thread" + i, k, post); await processPost(post); - ++k; - if (i == 6) - console.log("after Thread" + i, k, post); } - console.log("Thread" + i, k, "Completed", postsslice.slice(-1)[0]); })); }; var getSelectedFile = () => { diff --git a/src/main.ts b/src/main.ts index be3fa06..8dbf532 100644 --- a/src/main.ts +++ b/src/main.ts @@ -161,7 +161,7 @@ const startup = async () => { }); document.querySelectorAll('.board').forEach(e => { - // mo.observe(e!, { childList: true, subtree: true }); + mo.observe(e!, { childList: true, subtree: true }); }); const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')]; @@ -188,20 +188,12 @@ const startup = async () => { // await processPost(posts[i] as any); const n = 7; - const range = ~~(posts.length / n); + const range = ~~(posts.length / n) + 1; await Promise.all([...new Array(n + 1)].map(async (e, i) => { - console.log(i * range, (i + 1) * range, posts.length); const postsslice = posts.slice(i * range, (i + 1) * range); - let k = i * range; for (const post of postsslice) { - if (i == 6) - console.log('before Thread' + i, k, post); await processPost(post as any); - ++k; - if (i == 6) - console.log('after Thread' + i, k, post); } - console.log('Thread' + i, k, 'Completed', postsslice.slice(-1)[0]); })); //await Promise.all(posts.map(e => processPost(e as any))); };