Browse Source

Accidentally broke catalog

pull/46/head 0.111
coomdev 2 years ago
parent
commit
a2f759b566
  1. 2
      main.meta.js
  2. 13
      main.user.js
  3. 12
      src/main.ts

2
main.meta.js

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

13
main.user.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.109 // @version 0.110
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*
@ -16393,6 +16393,7 @@
}); });
}); });
document.querySelectorAll(".board").forEach((e) => { document.querySelectorAll(".board").forEach((e) => {
mo.observe(e, { childList: true, subtree: true });
}); });
const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')]; const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
const scts = document.getElementById("shortcuts"); const scts = document.getElementById("shortcuts");
@ -16412,20 +16413,12 @@
isCatalog: !!document.querySelector(".catalog-small") || !!location.pathname.match(/\/catalog$/) isCatalog: !!document.querySelector(".catalog-small") || !!location.pathname.match(/\/catalog$/)
}); });
const n = 7; 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) => { 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); const postsslice = posts.slice(i * range, (i + 1) * range);
let k = i * range;
for (const post of postsslice) { for (const post of postsslice) {
if (i == 6)
console.log("before Thread" + i, k, post);
await processPost(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 = () => { var getSelectedFile = () => {

12
src/main.ts

@ -161,7 +161,7 @@ const startup = async () => {
}); });
document.querySelectorAll('.board').forEach(e => { 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"])')]; const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
@ -188,20 +188,12 @@ const startup = async () => {
// await processPost(posts[i] as any); // await processPost(posts[i] as any);
const n = 7; 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) => { 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); const postsslice = posts.slice(i * range, (i + 1) * range);
let k = i * range;
for (const post of postsslice) { for (const post of postsslice) {
if (i == 6)
console.log('before Thread' + i, k, post);
await processPost(post as any); 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))); //await Promise.all(posts.map(e => processPost(e as any)));
}; };

Loading…
Cancel
Save