mirror of
https://git.coom.tech/fuckjannies/lolipiss.git
synced 2024-06-29 05:52:35 +00:00
Fixed FF catbox embeds and restricted embeds to catbox
This commit is contained in:
parent
d82b6d8665
commit
0afd9162cd
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.126
|
// @version 0.127
|
||||||
// @description uhh
|
// @description uhh
|
||||||
// @author You
|
// @author You
|
||||||
// @match https://boards.4channel.org/*
|
// @match https://boards.4channel.org/*
|
||||||
|
|
96
main.user.js
96
main.user.js
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.126
|
// @version 0.127
|
||||||
// @description uhh
|
// @description uhh
|
||||||
// @author You
|
// @author You
|
||||||
// @match https://boards.4channel.org/*
|
// @match https://boards.4channel.org/*
|
||||||
|
@ -11303,7 +11303,10 @@
|
||||||
resolve(resp);
|
resolve(resp);
|
||||||
},
|
},
|
||||||
ontimeout: () => reject("fetch timeout"),
|
ontimeout: () => reject("fetch timeout"),
|
||||||
onerror: () => reject("fetch error"),
|
onerror: (...args) => {
|
||||||
|
debugger;
|
||||||
|
reject("fetch error");
|
||||||
|
},
|
||||||
onabort: () => reject("fetch abort")
|
onabort: () => reject("fetch abort")
|
||||||
};
|
};
|
||||||
xmlhttprequest(gmopt);
|
xmlhttprequest(gmopt);
|
||||||
|
@ -11392,50 +11395,53 @@
|
||||||
return new Blob([ret]);
|
return new Blob([ret]);
|
||||||
};
|
};
|
||||||
var decodeCoom3Payload = async (buff) => {
|
var decodeCoom3Payload = async (buff) => {
|
||||||
const pees = buff.toString().split(" ").slice(0, 5).filter((e) => e.startsWith("http"));
|
const pees = buff.toString().split(" ").slice(0, 5).filter((e) => e.startsWith("https://files.catbox.moe/"));
|
||||||
return Promise.all(pees.map(async (pee) => {
|
return (await Promise.all(pees.map(async (pee) => {
|
||||||
const headers = headerStringToObject(await GM_head(pee));
|
try {
|
||||||
const res = await GM_fetch(pee, {
|
const headers = headerStringToObject(await GM_head(pee));
|
||||||
headers: { ranges: "bytes=0-2048" },
|
const res = await GM_fetch(pee, {
|
||||||
mode: "cors",
|
headers: { ranges: "bytes=0-2048", "user-agent": "" },
|
||||||
referrerPolicy: "no-referrer"
|
mode: "cors",
|
||||||
});
|
referrerPolicy: "no-referrer"
|
||||||
const size = +headers["content-size"] || 0;
|
});
|
||||||
const header = import_buffer2.Buffer.from(await res.arrayBuffer());
|
const size = +headers["content-length"] || 0;
|
||||||
let hptr = 0;
|
const header = import_buffer2.Buffer.from(await res.arrayBuffer());
|
||||||
if (header.slice(0, 4).toString() == "PEE\0")
|
let hptr = 0;
|
||||||
hptr += 4;
|
if (header.slice(0, 4).toString() == "PEE\0")
|
||||||
const flags = header[hptr];
|
hptr += 4;
|
||||||
const hasFn = !!(flags & 1);
|
const flags = header[hptr];
|
||||||
const hasTags = !!(flags & 2);
|
const hasFn = !!(flags & 1);
|
||||||
const hasThumbnail = !!(flags & 4);
|
const hasTags = !!(flags & 2);
|
||||||
let [ptr, ptr2] = [hptr + 1, hptr + 1];
|
const hasThumbnail = !!(flags & 4);
|
||||||
let fn = "embedded";
|
let [ptr, ptr2] = [hptr + 1, hptr + 1];
|
||||||
let tags = [];
|
let fn = "embedded";
|
||||||
let thumb = import_buffer2.Buffer.from(hasembed_default);
|
let tags = [];
|
||||||
if (hasFn) {
|
let thumb = import_buffer2.Buffer.from(hasembed_default);
|
||||||
while (header[ptr2] != 0)
|
if (hasFn) {
|
||||||
ptr2++;
|
while (header[ptr2] != 0)
|
||||||
fn = header.slice(ptr, ptr2).toString();
|
ptr2++;
|
||||||
ptr = ++ptr2;
|
fn = header.slice(ptr, ptr2).toString();
|
||||||
|
ptr = ++ptr2;
|
||||||
|
}
|
||||||
|
if (hasTags) {
|
||||||
|
while (header[ptr2] != 0)
|
||||||
|
ptr2++;
|
||||||
|
tags = header.slice(ptr, ptr2).toString().split(/\s+/);
|
||||||
|
}
|
||||||
|
let thumbsize = 0;
|
||||||
|
if (hasThumbnail) {
|
||||||
|
thumbsize = header.readInt32LE(ptr);
|
||||||
|
thumb = import_buffer2.Buffer.from(await (await GM_fetch(pee, { headers: { "user-agent": "", range: `bytes=${ptr + 4}-${ptr + 4 + thumbsize}` } })).arrayBuffer());
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
filename: fn,
|
||||||
|
data: async (lsn) => import_buffer2.Buffer.from(await (await GM_fetch(pee, { headers: { "user-agent": "", range: `bytes=${ptr + 4 + thumbsize}-${size - 1}` } }, lsn)).arrayBuffer()),
|
||||||
|
thumbnail: thumb
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e);
|
||||||
}
|
}
|
||||||
if (hasTags) {
|
}))).map((e) => e);
|
||||||
while (header[ptr2] != 0)
|
|
||||||
ptr2++;
|
|
||||||
tags = header.slice(ptr, ptr2).toString().split(/\s+/);
|
|
||||||
}
|
|
||||||
let thumbsize = 0;
|
|
||||||
if (hasThumbnail) {
|
|
||||||
thumbsize = header.readInt32LE(ptr);
|
|
||||||
console.log("Thumbnail size of ", thumbsize);
|
|
||||||
thumb = import_buffer2.Buffer.from(await (await GM_fetch(pee, { headers: { range: `bytes=${ptr + 4}-${ptr + 4 + thumbsize}` } })).arrayBuffer());
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
filename: fn,
|
|
||||||
data: async (lsn) => import_buffer2.Buffer.from(await (await GM_fetch(pee, { headers: { range: `bytes=${ptr + 4 + thumbsize}-${size - 1}` } }, lsn)).arrayBuffer()),
|
|
||||||
thumbnail: thumb
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
var fireNotification = (level, text2, lifetime = 3) => {
|
var fireNotification = (level, text2, lifetime = 3) => {
|
||||||
document.dispatchEvent(new CustomEvent("CreateNotification", {
|
document.dispatchEvent(new CustomEvent("CreateNotification", {
|
||||||
|
|
|
@ -76,7 +76,10 @@ export let GM_fetch = (...[url, opt, lisn]: [...Parameters<typeof fetch>, EventT
|
||||||
resolve(resp as any);
|
resolve(resp as any);
|
||||||
},
|
},
|
||||||
ontimeout: () => reject("fetch timeout"),
|
ontimeout: () => reject("fetch timeout"),
|
||||||
onerror: () => reject("fetch error"),
|
onerror: (...args) => {
|
||||||
|
debugger;
|
||||||
|
reject("fetch error");
|
||||||
|
},
|
||||||
onabort: () => reject("fetch abort")
|
onabort: () => reject("fetch abort")
|
||||||
};
|
};
|
||||||
xmlhttprequest(gmopt);
|
xmlhttprequest(gmopt);
|
||||||
|
|
92
src/utils.ts
92
src/utils.ts
|
@ -74,51 +74,55 @@ rest: [X bytes of thumbnail data])[file bytes]
|
||||||
&4 => has thumbnail
|
&4 => has thumbnail
|
||||||
*/
|
*/
|
||||||
export const decodeCoom3Payload = async (buff: Buffer) => {
|
export const decodeCoom3Payload = async (buff: Buffer) => {
|
||||||
const pees = buff.toString().split(' ').slice(0, 5).filter(e => e.startsWith("http"));
|
const pees = buff.toString().split(' ').slice(0, 5).filter(e => e.startsWith("https://files.catbox.moe/"));
|
||||||
return Promise.all(pees.map(async pee => {
|
return (await Promise.all(pees.map(async pee => {
|
||||||
const headers = headerStringToObject(await GM_head(pee));
|
try {
|
||||||
const res = await GM_fetch(pee, {
|
const headers = headerStringToObject(await GM_head(pee));
|
||||||
headers: { ranges: 'bytes=0-2048' },
|
const res = await GM_fetch(pee, {
|
||||||
mode: 'cors',
|
headers: { ranges: 'bytes=0-2048', 'user-agent': '' },
|
||||||
referrerPolicy: 'no-referrer',
|
mode: 'cors',
|
||||||
});
|
referrerPolicy: 'no-referrer',
|
||||||
const size = +headers['content-size'] || 0;
|
});
|
||||||
const header = Buffer.from(await res.arrayBuffer());
|
const size = +headers['content-length'] || 0;
|
||||||
let hptr = 0;
|
const header = Buffer.from(await res.arrayBuffer());
|
||||||
if (header.slice(0, 4).toString() == "PEE\0")
|
let hptr = 0;
|
||||||
hptr += 4;
|
if (header.slice(0, 4).toString() == "PEE\0")
|
||||||
const flags = header[hptr];
|
hptr += 4;
|
||||||
const hasFn = !!(flags & 1);
|
const flags = header[hptr];
|
||||||
const hasTags = !!(flags & 2);
|
const hasFn = !!(flags & 1);
|
||||||
const hasThumbnail = !!(flags & 4);
|
const hasTags = !!(flags & 2);
|
||||||
let [ptr, ptr2] = [hptr + 1, hptr + 1];
|
const hasThumbnail = !!(flags & 4);
|
||||||
let fn = 'embedded';
|
let [ptr, ptr2] = [hptr + 1, hptr + 1];
|
||||||
let tags = [];
|
let fn = 'embedded';
|
||||||
let thumb: EmbeddedFile['thumbnail'] = Buffer.from(thumbnail);
|
let tags = [];
|
||||||
if (hasFn) {
|
let thumb: EmbeddedFile['thumbnail'] = Buffer.from(thumbnail);
|
||||||
while (header[ptr2] != 0)
|
if (hasFn) {
|
||||||
ptr2++;
|
while (header[ptr2] != 0)
|
||||||
fn = header.slice(ptr, ptr2).toString();
|
ptr2++;
|
||||||
ptr = ++ptr2;
|
fn = header.slice(ptr, ptr2).toString();
|
||||||
|
ptr = ++ptr2;
|
||||||
|
}
|
||||||
|
if (hasTags) {
|
||||||
|
while (header[ptr2] != 0)
|
||||||
|
ptr2++;
|
||||||
|
tags = header.slice(ptr, ptr2).toString().split(/\s+/);
|
||||||
|
}
|
||||||
|
let thumbsize = 0;
|
||||||
|
if (hasThumbnail) {
|
||||||
|
thumbsize = header.readInt32LE(ptr);
|
||||||
|
thumb = Buffer.from(await (await GM_fetch(pee, { headers: { 'user-agent': '', range: `bytes=${ptr + 4}-${ptr + 4 + thumbsize}` } })).arrayBuffer());
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
filename: fn,
|
||||||
|
data: async (lsn) =>
|
||||||
|
Buffer.from(await (await GM_fetch(pee, { headers: { 'user-agent': '', range: `bytes=${ptr + 4 + thumbsize}-${size - 1}` } }, lsn)).arrayBuffer()),
|
||||||
|
thumbnail: thumb,
|
||||||
|
} as EmbeddedFile;
|
||||||
|
} catch (e) {
|
||||||
|
// niggers trying to fuck with bad links
|
||||||
|
console.warn(e);
|
||||||
}
|
}
|
||||||
if (hasTags) {
|
}))).map(e => e);
|
||||||
while (header[ptr2] != 0)
|
|
||||||
ptr2++;
|
|
||||||
tags = header.slice(ptr, ptr2).toString().split(/\s+/);
|
|
||||||
}
|
|
||||||
let thumbsize = 0;
|
|
||||||
if (hasThumbnail) {
|
|
||||||
thumbsize = header.readInt32LE(ptr);
|
|
||||||
console.log("Thumbnail size of ", thumbsize);
|
|
||||||
thumb = Buffer.from(await (await GM_fetch(pee, { headers: { range: `bytes=${ptr + 4}-${ptr + 4 + thumbsize}` } })).arrayBuffer());
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
filename: fn,
|
|
||||||
data: async (lsn) =>
|
|
||||||
Buffer.from(await (await GM_fetch(pee, { headers: { range: `bytes=${ptr + 4 + thumbsize}-${size - 1}` } }, lsn)).arrayBuffer()),
|
|
||||||
thumbnail: thumb,
|
|
||||||
} as EmbeddedFile;
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fireNotification = (level: 'success' | 'error' | 'info' | 'warning', text: string, lifetime = 3) => {
|
export const fireNotification = (level: 'success' | 'error' | 'info' | 'warning', text: string, lifetime = 3) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user