Browse Source

Thirdeye will skip filenames matching its md5

pull/46/head 0.86
coomdev 2 years ago
parent
commit
7b1153a608
  1. 2
      main.meta.js
  2. 13
      main.user.js
  3. 2401
      package-lock.json
  4. 1
      package.json
  5. 11
      src/main.ts
  6. 5
      src/thirdeye.ts

2
main.meta.js

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

13
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.84
// @version 0.85
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -11398,6 +11398,8 @@
};
};
var has_embed4 = async (b, fn) => {
if (Buffer2.from(fn, "hex").equals(b))
return false;
let result = void 0;
for (const e of Object.values(boorus)) {
if (!sources.has(e.domain))
@ -14714,13 +14716,14 @@
}
}
}
var processImage = async (src, fn) => {
var processImage = async (src, fn, hex) => {
const proc = processors.find((e) => e.match(fn));
if (!proc)
return;
if (proc.skip) {
if (await proc.has_embed(import_buffer4.Buffer.alloc(0), fn) === true)
return [await proc.extract(import_buffer4.Buffer.alloc(0), fn), true];
const md5 = import_buffer4.Buffer.from(hex, "base64");
if (await proc.has_embed(md5, fn) === true)
return [await proc.extract(md5, fn), true];
return;
}
const iter = streamRemote(src);
@ -14752,7 +14755,7 @@
const origlink = post.querySelector('.file-info > a[target*="_blank"]');
if (!thumb || !origlink)
return;
const res2 = await processImage(origlink.href, (origlink.querySelector(".fnfull") || origlink).textContent || "");
const res2 = await processImage(origlink.href, (origlink.querySelector(".fnfull") || origlink).textContent || "", post.querySelector("[data-md5]")?.getAttribute("data-md5") || "");
if (!res2)
return;
const [res, external] = res2;

2401
package-lock.json

File diff suppressed because it is too large

1
package.json

@ -23,6 +23,7 @@
"devDependencies": {
"@tsconfig/svelte": "^3.0.0",
"@types/tampermonkey": "^4.0.5",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"esbuild": "^0.14.7",
"esbuild-css-modules-plugin": "^2.0.9",
"esbuild-svelte": "^0.6.0",

11
src/main.ts

@ -72,15 +72,16 @@ type EmbeddedFileWithoutPreview = {
export type EmbeddedFile = EmbeddedFileWithPreview | EmbeddedFileWithoutPreview;
const processImage = async (src: string, fn: string): Promise<[EmbeddedFile, boolean] | undefined> => {
const processImage = async (src: string, fn: string, hex: string): Promise<[EmbeddedFile, boolean] | undefined> => {
const proc = processors.find(e => e.match(fn));
if (!proc)
return;
if (proc.skip) {
// skip file downloading, file is referenced from the filename
// basically does things like filtering out blacklisted tags
if (await proc.has_embed(Buffer.alloc(0), fn) === true)
return [await proc.extract(Buffer.alloc(0), fn), true];
const md5 = Buffer.from(hex, 'base64');
if (await proc.has_embed(md5, fn) === true)
return [await proc.extract(md5, fn), true];
return;
}
const iter = streamRemote(src);
@ -116,7 +117,9 @@ const processPost = async (post: HTMLDivElement) => {
const origlink = post.querySelector('.file-info > a[target*="_blank"]') as HTMLAnchorElement;
if (!thumb || !origlink)
return;
const res2 = await processImage(origlink.href, (origlink.querySelector('.fnfull') || origlink).textContent || '');
const res2 = await processImage(origlink.href,
(origlink.querySelector('.fnfull') || origlink).textContent || '',
post.querySelector("[data-md5]")?.getAttribute('data-md5') || '');
if (!res2)
return;
const [res, external] = res2;

5
src/thirdeye.ts

@ -133,6 +133,11 @@ const extract = async (b: Buffer, fn?: string) => {
const has_embed = async (b: Buffer, fn?: string) => {
// It's not worth to bother skipping images with filenames that match their md5 because
// 4chan reencodes jpegs, which is well over half the files posted
// ok fine you autists
if (Buffer.from(fn!, 'hex').equals(b))
return false;
let result: BooruMatch[] | undefined = undefined;
for (const e of Object.values(boorus)) {
if (!sources.has(e.domain))

Loading…
Cancel
Save