Browse Source

Fixes for tampermonkey

pull/46/head
coomdev 2 years ago
parent
commit
6f895f7def
  1. 2
      main.meta.js
  2. 37
      main.user.js
  3. 7
      src/requests.ts
  4. 16
      src/thirdeye.ts

2
main.meta.js

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

37
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.171
// @version 0.172
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -81,7 +81,7 @@
var define_BUILD_VERSION_default;
var init_define_BUILD_VERSION = __esm({
"<define:BUILD_VERSION>"() {
define_BUILD_VERSION_default = [0, 171];
define_BUILD_VERSION_default = [0, 172];
}
});
@ -13579,8 +13579,11 @@
}
var GM_fetch = (...[url, opt, lisn]) => {
function blobTo(to, blob) {
if (to == "arrayBuffer" && blob.arrayBuffer)
return blob.arrayBuffer();
if (to == "arrayBuffer" && blob.arrayBuffer) {
const ret = blob.arrayBuffer();
if (ret)
return ret;
}
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = function(event) {
@ -14460,14 +14463,20 @@
settings.subscribe((b) => {
csettings3 = b;
});
var gelquirk = (prefix) => (a) => (a.post || a.data || a).map((e) => ({
full_url: e.file_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 || e.parent_id}`,
tags: (e.tag_string || (e.tags && (Array.isArray(e.tags) && (typeof e.tags[0] == "string" ? e.tags.join(" ") : e.tags.map((e2) => e2.name_en).join(" "))) || e.tags) || "").split(" ")
})) || [];
var gelquirk = (prefix) => (a) => {
let base = a.post || a.data || a;
if (!Array.isArray(base))
return [];
base = base.filter((e) => e.file_url);
return base.map((e) => ({
full_url: e.file_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 || e.parent_id}`,
tags: (e.tag_string || (e.tags && (Array.isArray(e.tags) && (typeof e.tags[0] == "string" ? e.tags.join(" ") : e.tags.map((e2) => e2.name_en).join(" "))) || e.tags) || "").split(" ")
})) || [];
};
var experimentalApi = false;
var black = /* @__PURE__ */ new Set();
var phashEn = false;
@ -14499,7 +14508,9 @@
cache[b.domain] = {};
cache[b.domain][hex] = tran;
return tran;
} catch {
} catch (e) {
console.error("The following error might be expected");
console.error(e);
return [];
}
};

7
src/requests.ts

@ -35,8 +35,11 @@ export function GM_head(...[url, opt]: Parameters<typeof fetch>) {
export let GM_fetch = (...[url, opt, lisn]: [...Parameters<typeof fetch>, EventTarget?]) => {
function blobTo(to: string, blob: Blob) {
if (to == "arrayBuffer" && blob.arrayBuffer)
return blob.arrayBuffer();
if (to == "arrayBuffer" && blob.arrayBuffer) {
const ret = blob.arrayBuffer(); // Fuck TM
if (ret)
return ret;
}
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = function (event) {

16
src/thirdeye.ts

@ -38,18 +38,22 @@ function firstThatFor<T>(promises: Promise<T>[], pred: (v: T) => boolean) {
}));
}
const gelquirk: (s: string) => tran = prefix => (a =>
(a.post || a.data || a).map((e: any) => ({
const gelquirk: (s: string) => tran = prefix => (a => {
let base = (a.post || a.data || a);
if (!Array.isArray(base))
return [];
base = base.filter(e => e.file_url);
return base.map((e: any) => ({
full_url: e.file_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 || e.parent_id)}`,
tags: (e.tag_string || (e.tags
&& (Array.isArray(e.tags)
&& (typeof e.tags[0] == "string" ? e.tags.join(' ') : e.tags.map((e: any) => e.name_en).join(' '))) || e.tags) || '').split(' ')
} as BooruMatch)) || []);
} as BooruMatch)) || [];
});
let experimentalApi = false;
let black = new Set<string>();
@ -137,7 +141,9 @@ const findFileFrom = async (b: Booru, hex: string, abort?: EventTarget) => {
cache[b.domain] = {};
cache[b.domain][hex] = tran;
return tran;
} catch {
} catch(e) {
console.error('The following error might be expected');
console.error(e);
return [];
}
};

Loading…
Cancel
Save