Browse Source

Handle ATFBooru quirk

pull/46/head 0.110
coomdev 2 years ago
parent
commit
f769ed157f
  1. 2
      main.meta.js
  2. 23
      main.user.js
  3. 6
      src/App.svelte
  4. 24
      src/main.ts
  5. 1
      src/stores.ts
  6. 2
      src/thirdeye.ts

2
main.meta.js

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

23
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.108
// @version 0.109
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -11483,7 +11483,7 @@
// src/thirdeye.ts
var gelquirk = (prefix) => (a) => (a.post || a).map((e) => ({
full_url: e.file_url,
preview_url: e.preview_url,
preview_url: e.preview_url || e.preview_url,
source: e.source,
ext: e.file_ext || e.file_url.substr(e.file_url.lastIndexOf(".") + 1),
page: `${prefix}${e.id}`,
@ -16379,7 +16379,6 @@
var startup = async () => {
if (typeof window["FCX"] != "undefined")
appState.set({ ...cappState, is4chanX: true });
await Promise.all([...document.querySelectorAll(".postContainer")].filter((e) => e.textContent?.includes("191 KB")).map((e) => processPost(e)));
const mo = new MutationObserver((reco) => {
for (const rec of reco)
if (rec.type == "childList")
@ -16394,7 +16393,6 @@
});
});
document.querySelectorAll(".board").forEach((e) => {
mo.observe(e, { childList: true, subtree: true });
});
const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
const scts = document.getElementById("shortcuts");
@ -16413,12 +16411,21 @@
...cappState,
isCatalog: !!document.querySelector(".catalog-small") || !!location.pathname.match(/\/catalog$/)
});
const n = 8;
const range = ~~(posts.length / n) + 1;
await Promise.all([...new Array(n)].map(async (e, i) => {
const n = 7;
const range = ~~(posts.length / n);
await Promise.all([...new Array(n + 1)].map(async (e, i) => {
console.log(i * range, (i + 1) * range, posts.length);
const postsslice = posts.slice(i * range, (i + 1) * range);
for (const post of postsslice)
let k = i * range;
for (const post of postsslice) {
if (i == 6)
console.log("before Thread" + i, k, post);
await processPost(post);
++k;
if (i == 6)
console.log("after Thread" + i, k, post);
}
console.log("Thread" + i, k, "Completed", postsslice.slice(-1)[0]);
}));
};
var getSelectedFile = () => {

6
src/App.svelte

@ -71,6 +71,12 @@ import type { Booru } from './thirdeye';
<input type="checkbox" bind:checked={$settings.eye} />
Hide embedded content behind an eye.
</label>
{#if $settings.eye}
<label>
<input type="checkbox" bind:checked={$settings.ho} />
Hide original content when hidden content is visible.
</label>
{/if}
<label>
<input type="checkbox" bind:checked={$settings.pre} />
Preload external files.

24
src/main.ts

@ -142,7 +142,7 @@ const startup = async () => {
if (typeof (window as any)['FCX'] != "undefined")
appState.set({ ...cappState, is4chanX: true });
await Promise.all([...document.querySelectorAll('.postContainer')].filter(e => e.textContent?.includes("191 KB")).map(e => processPost(e as any)));
//await Promise.all([...document.querySelectorAll('.postContainer')].filter(e => e.textContent?.includes("191 KB")).map(e => processPost(e as any)));
// keep this to handle posts getting inlined
const mo = new MutationObserver(reco => {
@ -161,7 +161,7 @@ const startup = async () => {
});
document.querySelectorAll('.board').forEach(e => {
mo.observe(e!, { childList: true, subtree: true });
// mo.observe(e!, { childList: true, subtree: true });
});
const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
@ -184,12 +184,24 @@ const startup = async () => {
...cappState,
isCatalog: !!document.querySelector('.catalog-small') || !!location.pathname.match(/\/catalog$/),
});
const n = 8;
const range = ~~(posts.length / n) + 1;
await Promise.all([...new Array(n)].map(async (e, i) => {
// for (let i = 159; i < 160 ;++i)
// await processPost(posts[i] as any);
const n = 7;
const range = ~~(posts.length / n);
await Promise.all([...new Array(n + 1)].map(async (e, i) => {
console.log(i * range, (i + 1) * range, posts.length);
const postsslice = posts.slice(i * range, (i + 1) * range);
for (const post of postsslice)
let k = i * range;
for (const post of postsslice) {
if (i == 6)
console.log('before Thread' + i, k, post);
await processPost(post as any);
++k;
if (i == 6)
console.log('after Thread' + i, k, post);
}
console.log('Thread' + i, k, 'Completed', postsslice.slice(-1)[0]);
}));
//await Promise.all(posts.map(e => processPost(e as any)));
};

1
src/stores.ts

@ -22,6 +22,7 @@ export const settings = writable(localLoad('settingsv2', {
prev: false,
sh: false,
ep: false,
ho: false,
blacklist: ['guro', 'scat', 'ryona', 'gore'],
rsources: [{
name: 'Gelbooru',

2
src/thirdeye.ts

@ -33,7 +33,7 @@ function firstThatFor<T>(promises: Promise<T>[], pred: (v: T) => boolean) {
const gelquirk: (s: string) => tran = prefix => (a =>
(a.post || a).map((e: any) => ({
full_url: e.file_url,
preview_url: e.preview_url,
preview_url: e.preview_url || e.preview_url,
source: e.source,
ext: e.file_ext || e.file_url.substr(e.file_url.lastIndexOf('.') + 1),

Loading…
Cancel
Save