diff --git a/.gitignore b/.gitignore index 048759e..507da87 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules/ dist/ coverage/ +package-lock.json +package.json diff --git a/package.json b/package.json index a809fa6..69f9330 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,8 @@ "setupFilesAfterEnv": [ "./src/test/jest.setup.ts" ] + }, + "overrides": { + "@types/node": "18.19.115" } } diff --git a/src/engines/Mastodon.ts b/src/engines/Mastodon.ts index b1d9d6b..0cbcf55 100644 --- a/src/engines/Mastodon.ts +++ b/src/engines/Mastodon.ts @@ -10,7 +10,6 @@ interface Attachment { url: string; // original URL, ?sensitive=true stripped previewUrl?: string; // local cached preview (for video posters) contentType: ContentType; - sensitive: boolean; } /** @@ -31,9 +30,9 @@ interface Attachment { */ export default class Mastodon extends ScrapeEngineBase { name = "mastodon"; - features: ScrapeEngineFeature[] = ["content", "rating", "source"]; + features: ScrapeEngineFeature[] = ["content", "source"]; notes = [ - "Rating is assumed to be unsafe when source is marked sensitive." + "Rating is assumed to be safe." ]; // Explicit hosts we claim. Other Mastodon instances are picked up by the @@ -59,12 +58,8 @@ export default class Mastodon extends ScrapeEngineBase { post.pageUrl = document.location.href; post.contentUrl = att.url; post.contentType = att.contentType; - post.sources = [document.location.href]; post.referrer = document.location.origin; - - // Baraag is an adult-focused instance: default to safe, - // and bump to explicit when the source flags the attachment. - post.rating = att.sensitive ? "unsafe" : "safe"; + // post.rating = "safe"; // Cached preview as a poster frame for videos. if (att.contentType === "video" && att.previewUrl) { @@ -104,7 +99,7 @@ export default class Mastodon extends ScrapeEngineBase { const img = a.querySelector("img"); const preview = img?.currentSrc || img?.src; - const { url, sensitive } = this.normalizeUrl(rawHref); + const url = this.normalizeUrl(rawHref); const finalUrl = url || this.largestFromSrcset(img); if (!finalUrl) continue; @@ -112,7 +107,6 @@ export default class Mastodon extends ScrapeEngineBase { url: finalUrl, previewUrl: preview && preview !== finalUrl ? preview : undefined, contentType: this.contentTypeFor(finalUrl), - sensitive, }); } @@ -124,14 +118,13 @@ export default class Mastodon extends ScrapeEngineBase { * The marker is metadata, not part of the media URL, and leaving it in can * confuse booru deduplication and content-type sniffing. */ - private normalizeUrl(href: string): { url: string; sensitive: boolean } { + private normalizeUrl(href: string): string { try { const u = new URL(href, document.location.href); - const sensitive = u.searchParams.get("sensitive") === "true"; u.searchParams.delete("sensitive"); - return { url: u.toString(), sensitive }; + return u.toString(); } catch { - return { url: href, sensitive: false }; + return href; } }