Browse Source

Added support for other FoolFuuka-based archives (tested only on archived.moe)

pull/46/head
coomdev 2 years ago
parent
commit
436706c697
  1. 7
      extheader.js
  2. 9
      main.meta.js
  3. 19
      main.user.js
  4. 4
      src/main.ts
  5. 8
      src/websites/index.ts

7
extheader.js

@ -12,6 +12,13 @@ export const extheader = `// ==UserScript==
// @match https://boards.4channel.org/*
// @match https://boards.4chan.org/*
// @match https://desuarchive.org/*
// @match https://archived.moe/*
// @match https://archive.nyafuu.org/*
// @match https://arch.b4k.co/*
// @match https://archive.wakarimasen.moe/*
// @match https://fireden.net/*
// @match https://thebarchive.com/*
// @match https://archiveofsins.com/*
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest

9
main.meta.js

@ -1,12 +1,19 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.152
// @version 0.154
// @description uhh
// @author You
// @match https://boards.4channel.org/*
// @match https://boards.4chan.org/*
// @match https://desuarchive.org/*
// @match https://archived.moe/*
// @match https://archive.nyafuu.org/*
// @match https://arch.b4k.co/*
// @match https://archive.wakarimasen.moe/*
// @match https://fireden.net/*
// @match https://thebarchive.com/*
// @match https://archiveofsins.com/*
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest

19
main.user.js

@ -1,12 +1,19 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.152
// @version 0.154
// @description uhh
// @author You
// @match https://boards.4channel.org/*
// @match https://boards.4chan.org/*
// @match https://desuarchive.org/*
// @match https://archived.moe/*
// @match https://archive.nyafuu.org/*
// @match https://arch.b4k.co/*
// @match https://archive.wakarimasen.moe/*
// @match https://fireden.net/*
// @match https://thebarchive.com/*
// @match https://archiveofsins.com/*
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
@ -18418,7 +18425,7 @@
getMD5: (post) => post.querySelector("img[data-md5]")?.getAttribute("data-md5") || "",
getInfoBox: (post) => post.querySelector("span.file-info")
};
var DesuArchive = {
var FoolFuuka = {
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"]')],
@ -18438,8 +18445,8 @@
var getQueryProcessor = (is4chanX) => {
if (["boards.4chan.org", "boards.4channel.org"].includes(location.host))
return is4chanX ? X4chan : V4chan;
if (location.host == "desuarchive.org")
return DesuArchive;
if (document.querySelector('meta[name="generator"]')?.getAttribute("content")?.startsWith("FoolFuuka"))
return FoolFuuka;
};
// src/main.ts
@ -18696,10 +18703,10 @@
};
document.addEventListener("4chanXInitFinished", () => startup(true));
document.addEventListener("4chanParsingDone", () => startup(false), { once: true });
if (location.host == "desuarchive.org") {
if (GM.info.script.matches.slice(2).some((m) => m.includes(location.host))) {
window.addEventListener("load", () => {
startup(false);
});
}, { once: true });
}
document.addEventListener("4chanThreadUpdated", (e) => {
document.dispatchEvent(new CustomEvent("ThreadUpdate", {

4
src/main.ts

@ -359,10 +359,10 @@ const startup = async (is4chanX = true) => {
document.addEventListener('4chanXInitFinished', () => startup(true));
document.addEventListener('4chanParsingDone', () => startup(false), { once: true });
if (location.host == "desuarchive.org") {
if (GM.info.script.matches.slice(2).some(m => m.includes(location.host))) {
window.addEventListener('load', () => {
startup(false);
});
}, { once: true });
}
document.addEventListener('4chanThreadUpdated', ((e: CustomEvent<{ count: number }>) => {

8
src/websites/index.ts

@ -43,7 +43,7 @@ export const X4chan: QueryProcessor = {
getInfoBox: post => post.querySelector("span.file-info")!
};
export const DesuArchive: QueryProcessor = {
export const FoolFuuka: QueryProcessor = {
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[],
@ -64,6 +64,6 @@ export const DesuArchive: QueryProcessor = {
export const getQueryProcessor = (is4chanX: boolean) => {
if (['boards.4chan.org', 'boards.4channel.org'].includes(location.host))
return is4chanX ? X4chan : V4chan;
if (location.host == "desuarchive.org")
return DesuArchive;
};
if (document.querySelector('meta[name="generator"]')?.getAttribute("content")?.startsWith("FoolFuuka"))
return FoolFuuka;
};

Loading…
Cancel
Save