Browse Source

Workaround certain paywall boorus

pull/46/head 0.96
coomdev 2 years ago
parent
commit
3ed21fd149
  1. 2
      main.meta.js
  2. 9
      main.user.js
  3. 7
      src/thirdeye.ts

2
main.meta.js

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

9
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.94
// @version 0.95
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -11452,14 +11452,16 @@
break;
}
let cachedFile;
const prev = result[0].preview_url;
const full = result[0].full_url;
return {
source: result[0].source,
page: result[0].page,
filename: fn.substring(0, 33) + result[0].ext,
thumbnail: await (await GM_fetch(result[0].preview_url)).arrayBuffer(),
thumbnail: await (await GM_fetch(prev || full)).arrayBuffer(),
data: async (lsn) => {
if (!cachedFile)
cachedFile = await (await GM_fetch(result[0].full_url, void 0, lsn)).arrayBuffer();
cachedFile = await (await GM_fetch(full || prev, void 0, lsn)).arrayBuffer();
return cachedFile;
}
};
@ -11472,6 +11474,7 @@
if (!sources.has(e.domain))
continue;
result = await findFileFrom(e, fn.substring(0, 32));
result = result.filter((e2) => e2.full_url || e2.preview_url);
if (result.length)
break;
}

7
src/thirdeye.ts

@ -133,14 +133,16 @@ const extract = async (b: Buffer, fn?: string) => {
break;
}
let cachedFile: ArrayBuffer;
const prev = result[0].preview_url;
const full = result[0].full_url;
return {
source: result[0].source,
page: result[0].page,
filename: fn!.substring(0, 33) + result[0].ext,
thumbnail: (await (await GM_fetch(result[0].preview_url)).arrayBuffer()),
thumbnail: (await (await GM_fetch(prev || full)).arrayBuffer()), // prefer preview
data: async (lsn) => {
if (!cachedFile)
cachedFile = (await (await GM_fetch(result[0].full_url, undefined, lsn)).arrayBuffer());
cachedFile = (await (await GM_fetch(full || prev, undefined, lsn)).arrayBuffer()); // prefer full
return cachedFile;
}
} as EmbeddedFile;
@ -159,6 +161,7 @@ const has_embed = async (b: Buffer, fn?: string) => {
if (!sources.has(e.domain))
continue;
result = await findFileFrom(e, fn!.substring(0, 32));
result = result.filter(e => e.full_url || e.preview_url); // skips possible paywalls
if (result.length)
break;
}

Loading…
Cancel
Save