Browse Source

Handle edge case where the booru doesn't generate previews

pull/46/head
coomdev 2 years ago
parent
commit
b3db37da89
  1. 2
      main.meta.js
  2. 6
      main.user.js
  3. 2
      src/thirdeye.ts

2
main.meta.js

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

6
main.user.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.191 // @version 0.192
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*
@ -81,7 +81,7 @@
var define_BUILD_VERSION_default; var define_BUILD_VERSION_default;
var init_define_BUILD_VERSION = __esm({ var init_define_BUILD_VERSION = __esm({
"<define:BUILD_VERSION>"() { "<define:BUILD_VERSION>"() {
define_BUILD_VERSION_default = [0, 191]; define_BUILD_VERSION_default = [0, 192];
} }
}); });
@ -16500,6 +16500,8 @@
break; break;
} }
if (result && result.length != 0 && phashEn && prevlink) { if (result && result.length != 0 && phashEn && prevlink) {
if (!result[0].preview_url)
return true;
const getHash = async (l) => { const getHash = async (l) => {
const ogreq = await ifetch(l); const ogreq = await ifetch(l);
const origPreview = await ogreq.arrayBuffer(); const origPreview = await ogreq.arrayBuffer();

2
src/thirdeye.ts

@ -215,6 +215,8 @@ const has_embed = async (b: Buffer, fn?: string, prevlink?: string) => {
} }
if ((result && result.length != 0) && phashEn && prevlink) { if ((result && result.length != 0) && phashEn && prevlink) {
if (!result[0].preview_url)
return true;
const getHash = async (l: string) => { const getHash = async (l: string) => {
const ogreq = await ifetch(l); const ogreq = await ifetch(l);
const origPreview = await ogreq.arrayBuffer(); const origPreview = await ogreq.arrayBuffer();

Loading…
Cancel
Save