Browse Source

Fix filename detection for OP in archive

pull/46/head
coomdev 2 years ago
parent
commit
c4da6dfbe9
  1. 2
      main.meta.js
  2. 7
      main.user.js
  3. 9
      src/websites/index.ts

2
main.meta.js

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

7
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.151
// @version 0.152
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -18419,13 +18419,16 @@
getInfoBox: (post) => post.querySelector("span.file-info")
};
var DesuArchive = {
getFileThumbnail: (post) => post.querySelector(".thread_image_box"),
getFileThumbnail: (post) => post.classList.contains("post_is_op") ? post.querySelector(".thread_image_link") : post.querySelector(".thread_image_box"),
getPost: (post) => post.querySelector(".post_wrapper"),
postsWithFiles: (h) => [...(h || document).querySelectorAll('article[class*="has_image"]')],
settingsHost: () => document.querySelector(".letters"),
catalogControlHost: () => document.getElementById("index-options"),
getImageLink: (post) => post.querySelector("a[rel]")?.getAttribute("href") || "",
getFilename: (post) => {
const opfn = post.querySelector("a.post_file_filename")?.textContent;
if (opfn)
return opfn;
const a = post.querySelector("a[rel]");
return a?.title || "";
},

9
src/websites/index.ts

@ -11,7 +11,7 @@ export type QueryProcessor = {
};
export const V4chan: QueryProcessor = {
getFileThumbnail: post => post.querySelector('div.file')!,
getFileThumbnail: post => post.querySelector('div.file')!,
getPost: (post) => post.querySelector('.post')!,
postsWithFiles: (h) => [...(h || document).querySelectorAll('.file')].map(e => e.closest('.postContainer')) as any,
settingsHost: () => document.getElementById("navtopright") as any,
@ -28,7 +28,7 @@ export const V4chan: QueryProcessor = {
};
export const X4chan: QueryProcessor = {
getFileThumbnail: post => post.querySelector('div.file')!,
getFileThumbnail: post => post.querySelector('div.file')!,
getPost: (post) => post.querySelector('.post')!,
postsWithFiles: (h) => [...(h || document).querySelectorAll('.postContainer:not([class*="noFile"])')] as HTMLElement[],
settingsHost: () => document.getElementById("shortcuts") as any,
@ -44,13 +44,16 @@ export const X4chan: QueryProcessor = {
};
export const DesuArchive: QueryProcessor = {
getFileThumbnail: post => post.querySelector('.thread_image_box')!,
getFileThumbnail: post => post.classList.contains('post_is_op') ? post.querySelector('.thread_image_link')! : post.querySelector('.thread_image_box')!,
getPost: (post) => post.querySelector('.post_wrapper')!,
postsWithFiles: (h) => [...(h || document).querySelectorAll('article[class*="has_image"]')] as HTMLElement[],
settingsHost: () => document.querySelector(".letters") as any,
catalogControlHost: () => document.getElementById("index-options") as HTMLDivElement,
getImageLink: (post: HTMLElement) => post.querySelector('a[rel]')?.getAttribute('href') || '',
getFilename: (post: HTMLElement) => {
const opfn = post.querySelector('a.post_file_filename')?.textContent;
if (opfn)
return opfn;
const a = post.querySelector('a[rel]') as (HTMLAnchorElement | null);
return a?.title || '';
},

Loading…
Cancel
Save