From 15bec7b1159432d4d1139b445b558320b1f41aa5 Mon Sep 17 00:00:00 2001 From: Nes370 Date: Sat, 17 Oct 2026 19:29:36 -0700 Subject: [PATCH] Bugfixes Fixed safety detection on chan.sankakucomplex.com, and improved source parsing on Gelbooru v0.2.0 sites. --- src/engines/Gelbooru.ts | 8 +++++--- src/engines/SankakuComplex.ts | 27 ++++++++------------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/engines/Gelbooru.ts b/src/engines/Gelbooru.ts index c660b79..5d57103 100644 --- a/src/engines/Gelbooru.ts +++ b/src/engines/Gelbooru.ts @@ -89,10 +89,12 @@ export default class Gelbooru extends ScrapeEngineBase { if (matches && matches.length == 3) { // If Source element if (matches[1] == "Source") { - if (version == Version.v020) { - post.sources = [matches[2]]; + const anchor = el.querySelector("a"); + if (anchor && anchor.href) { + post.sources = [anchor.href]; } else { - post.sources = [(el.children[0] as HTMLAnchorElement).href]; + // Fallback to plain text just in case + post.sources = [matches[2]]; } } // If Rating element diff --git a/src/engines/SankakuComplex.ts b/src/engines/SankakuComplex.ts index d67713c..a9c57b3 100644 --- a/src/engines/SankakuComplex.ts +++ b/src/engines/SankakuComplex.ts @@ -27,25 +27,14 @@ export default class SankakuComplex extends ScrapeEngineBase { post.contentType = guessContentType(post.contentUrl); // Set rating - const safetyExp = new RegExp("Rating: (.*)"); - const safetyElements = Array.from(document.querySelectorAll("#stats > ul > li")) - .map((x) => x as HTMLLIElement) - .filter((x) => x.innerText.startsWith("Rating")); - - if (safetyElements.length > 0) { - const matches = safetyElements[0].innerText.match(safetyExp); - if (matches && matches.length > 0) { - switch (matches[1].toLowerCase()) { - case "safe": - post.rating = "safe"; - break; - case "questionable": - post.rating = "sketchy"; - break; - case "explicit": - post.rating = "unsafe"; - break; - } + const ratingElement = document.querySelector("#stats .rating-s, #stats .rating-q, #stats .rating-e"); + if (ratingElement) { + if (ratingElement.classList.contains("rating-s")) { + post.rating = "safe"; + } else if (ratingElement.classList.contains("rating-q")) { + post.rating = "sketchy"; + } else if (ratingElement.classList.contains("rating-e")) { + post.rating = "unsafe"; } }