Browse Source

Attempt to add support for thread updates

pull/4/head
coomdev 2 years ago
parent
commit
fb5e188e51
  1. 7
      main.user.js
  2. 7
      src/main.ts

7
main.user.js

@ -7096,6 +7096,9 @@
return await extractEmbedded(reader.getReader());
};
var processPost = async (post) => {
if (post.hasAttribute("data-processed"))
return;
post.setAttribute("data-processed", "true");
let thumb = post.querySelector(".fileThumb");
if (!thumb)
return;
@ -7207,7 +7210,9 @@
var startup = async () => {
await Promise.all([...document.querySelectorAll(".postContainer")].map((e) => processPost(e)));
document.addEventListener("PostsInserted", async (e) => {
processPost(e.target);
let threadelement = e.target;
let posts = [...threadelement.querySelectorAll("postContainer")].filter((e2) => e2.hasAttribute("data-processed"));
posts.map((e2) => processPost(e2));
});
let getSelectedFile = () => {
return new Promise((res) => {

7
src/main.ts

@ -127,6 +127,9 @@ let processImage2 = async (src: string) => {
};
let processPost = async (post: HTMLDivElement) => {
if (post.hasAttribute('data-processed'))
return;
post.setAttribute('data-processed', "true");
let thumb = post.querySelector(".fileThumb") as HTMLAnchorElement;
if (!thumb)
return;
@ -256,7 +259,9 @@ const startup = async () => {
//await Promise.all([...document.querySelectorAll('.postContainer')].filter(e => e.textContent?.includes("191 KB")).map(e => processPost(e as any)));
document.addEventListener('PostsInserted', <any>(async (e: CustomEvent<string>) => {
processPost(e.target as any);
let threadelement = e.target as HTMLDivElement
let posts = [...threadelement.querySelectorAll("postContainer")].filter(e => e.hasAttribute('data-processed'));
posts.map(e => processPost(e as any));
}));
let getSelectedFile = () => {

Loading…
Cancel
Save