mirror of
https://git.coom.tech/fuckjannies/lolipiss.git
synced 2024-06-26 12:42:38 +00:00
dame da ne
This commit is contained in:
parent
a07a118d68
commit
d48fe73b4f
|
@ -22,6 +22,10 @@ export const extheader = `// ==UserScript==
|
||||||
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
// @grant GM.xmlHttpRequest
|
// @grant GM.xmlHttpRequest
|
||||||
|
// @grant GM_getValue
|
||||||
|
// @grant GM.getValue
|
||||||
|
// @grant GM_setValue
|
||||||
|
// @grant GM.setValue
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
// @grant GM.openInTab
|
// @grant GM.openInTab
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
|
@ -32,5 +36,6 @@ export const extheader = `// ==UserScript==
|
||||||
// @connect *
|
// @connect *
|
||||||
// @icon https://coom.tech/resources/assets/1449696017588.png
|
// @icon https://coom.tech/resources/assets/1449696017588.png
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
const _DOMParser = DOMParser;
|
||||||
|
|
||||||
`;
|
`;
|
1
main.d.ts
vendored
1
main.d.ts
vendored
|
@ -59,3 +59,4 @@ declare const BUILD_VERSION: [number, number];
|
||||||
declare const execution_mode: 'userscript' | 'chrome_api' | 'ff_api';
|
declare const execution_mode: 'userscript' | 'chrome_api' | 'ff_api';
|
||||||
declare const isBackground: boolean;
|
declare const isBackground: boolean;
|
||||||
declare const chrome: typeof browser;
|
declare const chrome: typeof browser;
|
||||||
|
declare const _DOMParser: typeof DOMParser;
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.202
|
// @version 0.203
|
||||||
// @description uhh
|
// @description uhh
|
||||||
// @author You
|
// @author You
|
||||||
// @match https://boards.4channel.org/*
|
// @match https://boards.4channel.org/*
|
||||||
|
@ -17,6 +17,10 @@
|
||||||
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
// @grant GM.xmlHttpRequest
|
// @grant GM.xmlHttpRequest
|
||||||
|
// @grant GM_getValue
|
||||||
|
// @grant GM.getValue
|
||||||
|
// @grant GM_setValue
|
||||||
|
// @grant GM.setValue
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
// @grant GM.openInTab
|
// @grant GM.openInTab
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
|
@ -27,4 +31,5 @@
|
||||||
// @connect *
|
// @connect *
|
||||||
// @icon https://coom.tech/resources/assets/1449696017588.png
|
// @icon https://coom.tech/resources/assets/1449696017588.png
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
const _DOMParser = DOMParser;
|
||||||
|
|
||||||
|
|
137
main.user.js
137
main.user.js
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.202
|
// @version 0.203
|
||||||
// @description uhh
|
// @description uhh
|
||||||
// @author You
|
// @author You
|
||||||
// @match https://boards.4channel.org/*
|
// @match https://boards.4channel.org/*
|
||||||
|
@ -17,6 +17,10 @@
|
||||||
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
// @require https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
// @grant GM.xmlHttpRequest
|
// @grant GM.xmlHttpRequest
|
||||||
|
// @grant GM_getValue
|
||||||
|
// @grant GM.getValue
|
||||||
|
// @grant GM_setValue
|
||||||
|
// @grant GM.setValue
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
// @grant GM.openInTab
|
// @grant GM.openInTab
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
|
@ -27,6 +31,7 @@
|
||||||
// @connect *
|
// @connect *
|
||||||
// @icon https://coom.tech/resources/assets/1449696017588.png
|
// @icon https://coom.tech/resources/assets/1449696017588.png
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
const _DOMParser = DOMParser;
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
var __create = Object.create;
|
var __create = Object.create;
|
||||||
|
@ -83,7 +88,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, 202];
|
define_BUILD_VERSION_default = [0, 203];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23429,25 +23434,90 @@
|
||||||
copyTextToClipboard(text3);
|
copyTextToClipboard(text3);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var startup = async (is4chanX = true) => {
|
var cleanupHTML = async (s) => {
|
||||||
const observer = new MutationObserver((mutations) => {
|
const ndom = new _DOMParser().parseFromString(s, "text/html");
|
||||||
if (document.body.textContent.startsWith("Please disable")) {
|
const evalWhenReady = [];
|
||||||
(async () => {
|
const addFromSource = async (elem, url) => {
|
||||||
const k = await GM_fetch(location.href);
|
try {
|
||||||
const src = await k.text();
|
const code = await (await GM_fetch(url)).text();
|
||||||
const ndom = new DOMParser().parseFromString(src, "text/html");
|
evalWhenReady.push(code);
|
||||||
[...ndom.head.children].filter((e) => e.tagName == "SCRIPT" && e.textContent?.includes("-0x")).forEach((e) => e.remove());
|
} catch (e) {
|
||||||
unsafeWindow.document.documentElement.innerHTML = ndom.documentElement.innerHTML;
|
console.error(e);
|
||||||
startup(is4chanX);
|
debugger;
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
const addFromCode = (elem, sr) => {
|
||||||
|
evalWhenReady.push(sr);
|
||||||
|
};
|
||||||
|
[...ndom.head.children].filter((e) => e.tagName == "SCRIPT").forEach((e) => e.remove());
|
||||||
|
[...ndom.body.children].filter((e) => e.tagName == "SCRIPT").forEach((e) => e.remove());
|
||||||
|
unsafeWindow["isEventSupported"] = () => false;
|
||||||
|
await addFromSource(ndom.body, "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
|
||||||
|
await addFromSource(ndom.head, "https://based.coom.tech/highlight.pack.js");
|
||||||
|
addFromCode(ndom.body, `
|
||||||
|
document.documentElement.className = "";
|
||||||
|
document.documentElement.lang = "en";
|
||||||
|
document.documentElement.dataset.site = "arch.b4k.co";`);
|
||||||
|
addFromCode(ndom.body, `
|
||||||
|
hljs.configure({
|
||||||
|
tableReplace: ' '
|
||||||
});
|
});
|
||||||
observer.observe(document.documentElement, { childList: true, subtree: true });
|
$('pre,code').each(function(i, block) {
|
||||||
observer.observe(document.head, { childList: true, subtree: true });
|
hljs.highlightBlock(block);
|
||||||
const meta2 = document.querySelector('meta[name="referrer"]');
|
});
|
||||||
if (meta2) {
|
|
||||||
meta2.setAttribute("name", "referrer");
|
var backend_vars = {"user_name":false,"user_email":false,"user_pass":"9fOK4K8","site_url":"https://arch.b4k.co/","default_url":"https://arch.b4k.co/","archive_url":"https://arch.b4k.co/","system_url":"https://arch.b4k.co/","api_url":"https://arch.b4k.co/","cookie_domain":null,"cookie_prefix":"foolfuuka_a2e7d4_","selected_theme":"foolz/foolfuuka-theme-foolfuuka","csrf_token_key":"csrf_token","images":{"banned_image":"https://arch.b4k.co/foolfuuka/foolz/foolfuuka-theme-foolfuuka/assets-1.2.28/images/banned-image.png","banned_image_width":150,"banned_image_height":150,"missing_image":"https://arch.b4k.co/foolfuuka/foolz/foolfuuka-theme-foolfuuka/assets-1.2.28/images/missing-image.jpg","missing_image_width":150,"missing_image_height":150},"gettext":{"submit_state":"Submitting","thread_is_real_time":"This thread is being displayed in real time.","update_now":"Update now","ghost_mode":"This thread has entered ghost mode. Your reply will be marked as a ghost post and will only affect the ghost index."},"board_shortname":"v"};`);
|
||||||
meta2.setAttribute("content", "no-referrer");
|
{
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/bootstrap.min.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/plugins.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/board.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/fuuka.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/lazyload.js");
|
||||||
|
}
|
||||||
|
return [ndom.documentElement.innerHTML, evalWhenReady];
|
||||||
|
};
|
||||||
|
var gmo;
|
||||||
|
var ispostreload = false;
|
||||||
|
var earlystartup = async () => {
|
||||||
|
if (location.host == "arch.b4k.co") {
|
||||||
|
if (GM.info.version == "2.13.0") {
|
||||||
|
alert(`Due to b4k's admin being a faggot, PEE will get you banned if you're not using Greasemonkey Beta and enabled "Synchronous page mode" or TamperMonkey with Instant Injection`);
|
||||||
|
alert("Because you use the regular GM, PEE will disable itself on this domain");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!GM_getValue("warning_seen", false)) {
|
||||||
|
alert(`Due to b4k's admin being a faggot, PEE will get you banned if you're not using Greasemonkey Beta and enabled "Synchronous page mode" or TamperMonkey with Instant Injection`);
|
||||||
|
alert('Make sure you have enabled "Synchronous page mode" on VM Beta or Instant Injection on TM');
|
||||||
|
if (!confirm("Proceed?")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GM_setValue("warning_seen", true);
|
||||||
|
}
|
||||||
|
document.documentElement.innerHTML = "";
|
||||||
|
const k = await GM_fetch(location.href);
|
||||||
|
const src = await k.text();
|
||||||
|
gmo.disconnect();
|
||||||
|
ispostreload = true;
|
||||||
|
const [code, scripts] = await cleanupHTML(src);
|
||||||
|
unsafeWindow.document.documentElement.innerHTML = code;
|
||||||
|
await new Promise((r) => setTimeout(r, 500));
|
||||||
|
for (const s of scripts)
|
||||||
|
unsafeWindow.eval(s);
|
||||||
|
unsafeWindow.dispatchEvent(new CustomEvent("load"));
|
||||||
|
document.querySelectorAll("img[data-src]").forEach((i) => {
|
||||||
|
i.src = i.getAttribute("data-src");
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var startup = async (is4chanX = true) => {
|
||||||
|
const meta = document.querySelector('meta[name="referrer"]');
|
||||||
|
const customStyles = document.createElement("style");
|
||||||
|
customStyles.appendChild(document.createTextNode(global_default));
|
||||||
|
document.documentElement.insertBefore(customStyles, null);
|
||||||
|
if (meta) {
|
||||||
|
meta.setAttribute("name", "referrer");
|
||||||
|
meta.setAttribute("content", "no-referrer");
|
||||||
}
|
}
|
||||||
appState.set({ ...cappState, is4chanX });
|
appState.set({ ...cappState, is4chanX });
|
||||||
const lqp = getQueryProcessor(is4chanX);
|
const lqp = getQueryProcessor(is4chanX);
|
||||||
|
@ -23557,8 +23627,25 @@
|
||||||
document.addEventListener("4chanXInitFinished", () => startup(true));
|
document.addEventListener("4chanXInitFinished", () => startup(true));
|
||||||
document.addEventListener("4chanParsingDone", () => startup(false), { once: true });
|
document.addEventListener("4chanParsingDone", () => startup(false), { once: true });
|
||||||
if (supportedAltDomain(location.host)) {
|
if (supportedAltDomain(location.host)) {
|
||||||
window.addEventListener("load", () => {
|
if (location.host == "arch.b4k.co") {
|
||||||
startup(false);
|
gmo = new MutationObserver((m) => {
|
||||||
|
for (const r of m) {
|
||||||
|
if (ispostreload)
|
||||||
|
debugger;
|
||||||
|
r.addedNodes.forEach((e) => {
|
||||||
|
if (e.tagName == "SCRIPT") {
|
||||||
|
if (e.parentElement?.tagName == "HEAD" || e.parentElement?.tagName == "BODY")
|
||||||
|
e.parentElement?.removeChild(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gmo.observe(document.documentElement, { subtree: true, childList: true });
|
||||||
|
}
|
||||||
|
const proceed = earlystartup();
|
||||||
|
window.addEventListener("load", async () => {
|
||||||
|
if (await proceed)
|
||||||
|
startup(false);
|
||||||
}, { once: true });
|
}, { once: true });
|
||||||
}
|
}
|
||||||
document.addEventListener("4chanThreadUpdated", (e) => {
|
document.addEventListener("4chanThreadUpdated", (e) => {
|
||||||
|
@ -23604,14 +23691,6 @@
|
||||||
obs.observe(filesinp, { attributes: true });
|
obs.observe(filesinp, { attributes: true });
|
||||||
}
|
}
|
||||||
}, { once: !cappState.is4chanX });
|
}, { once: !cappState.is4chanX });
|
||||||
var customStyles = document.createElement("style");
|
|
||||||
customStyles.appendChild(document.createTextNode(global_default));
|
|
||||||
document.documentElement.insertBefore(customStyles, null);
|
|
||||||
var meta = document.querySelector('meta[name="referrer"]');
|
|
||||||
if (meta) {
|
|
||||||
meta.setAttribute("name", "referrer");
|
|
||||||
meta.setAttribute("content", "no-referrer");
|
|
||||||
}
|
|
||||||
function processAttachments(post, ress) {
|
function processAttachments(post, ress) {
|
||||||
if (ress.length == 0)
|
if (ress.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
1009
package-lock.json
generated
1009
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,7 @@
|
||||||
"file-type": "^17.0.2",
|
"file-type": "^17.0.2",
|
||||||
"image-hash": "^5.0.1",
|
"image-hash": "^5.0.1",
|
||||||
"jpeg-js": "^0.4.3",
|
"jpeg-js": "^0.4.3",
|
||||||
|
"jsdom": "^19.0.0",
|
||||||
"linkify-string": "^3.0.4",
|
"linkify-string": "^3.0.4",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"png-js": "^1.0.0",
|
"png-js": "^1.0.0",
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^3.0.0",
|
||||||
|
"@types/jsdom": "^16.2.14",
|
||||||
"@types/lodash": "^4.14.181",
|
"@types/lodash": "^4.14.181",
|
||||||
"@types/tampermonkey": "^4.0.5",
|
"@types/tampermonkey": "^4.0.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
||||||
|
|
153
src/main.ts
153
src/main.ts
|
@ -317,23 +317,112 @@ const scrapeBoard = async (self: HTMLButtonElement) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const startup = async (is4chanX = true) => {
|
const cleanupHTML = async (s: string) => {
|
||||||
const observer = new MutationObserver((mutations) => {
|
const ndom = new _DOMParser().parseFromString(s, "text/html");
|
||||||
if (document.body!.textContent!.startsWith("Please disable")) {
|
const evalWhenReady: string[] = [];
|
||||||
(async () => {
|
const addFromSource = async (elem: HTMLElement, url: string) => {
|
||||||
const k = await GM_fetch(location.href);
|
/* const scr = document.createElement('script');
|
||||||
const src = await k.text();
|
scr.type = 'text/javascript';
|
||||||
const ndom = new DOMParser().parseFromString(src, "text/html");
|
scr.src = url;
|
||||||
[...ndom.head.children].filter(e => e.tagName == "SCRIPT" && e.textContent?.includes('-0x')).forEach(e => e.remove());
|
scr.addEventListener("load", e => console.log('url loaded', e));
|
||||||
unsafeWindow.document.documentElement.innerHTML = ndom.documentElement.innerHTML;
|
elem.append(scr);*/
|
||||||
startup(is4chanX);
|
try {
|
||||||
})();
|
const code = await (await GM_fetch(url)).text();
|
||||||
}
|
evalWhenReady.push(code);
|
||||||
});
|
} catch (e) {
|
||||||
observer.observe(document.documentElement, { childList: true, subtree: true });
|
console.error(e);
|
||||||
observer.observe(document.head, { childList: true, subtree: true });
|
debugger;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const addFromCode = (elem: HTMLElement, sr: string) => {
|
||||||
|
/* const scr = document.createElement('script');
|
||||||
|
scr.type = 'text/javascript';
|
||||||
|
scr.innerText = sr;
|
||||||
|
scr.addEventListener("load", e => console.log('code loaded', e));
|
||||||
|
elem.append(scr);*/
|
||||||
|
//eval(sr);
|
||||||
|
evalWhenReady.push(sr);
|
||||||
|
};
|
||||||
|
|
||||||
|
[...ndom.head.children].filter(e => e.tagName == "SCRIPT").forEach(e => e.remove());
|
||||||
|
[...ndom.body.children].filter(e => e.tagName == "SCRIPT").forEach(e => e.remove());
|
||||||
|
|
||||||
|
unsafeWindow['isEventSupported'] = () => false;
|
||||||
|
|
||||||
|
await addFromSource(ndom.body, "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
|
||||||
|
await addFromSource(ndom.head, "https://based.coom.tech/highlight.pack.js");
|
||||||
|
addFromCode(ndom.body, `
|
||||||
|
document.documentElement.className = "";
|
||||||
|
document.documentElement.lang = "en";
|
||||||
|
document.documentElement.dataset.site = "arch.b4k.co";`);
|
||||||
|
addFromCode(ndom.body, `
|
||||||
|
hljs.configure({
|
||||||
|
tableReplace: ' '
|
||||||
|
});
|
||||||
|
$('pre,code').each(function(i, block) {
|
||||||
|
hljs.highlightBlock(block);
|
||||||
|
});
|
||||||
|
|
||||||
|
var backend_vars = {"user_name":false,"user_email":false,"user_pass":"9fOK4K8","site_url":"https://arch.b4k.co/","default_url":"https://arch.b4k.co/","archive_url":"https://arch.b4k.co/","system_url":"https://arch.b4k.co/","api_url":"https://arch.b4k.co/","cookie_domain":null,"cookie_prefix":"foolfuuka_a2e7d4_","selected_theme":"foolz/foolfuuka-theme-foolfuuka","csrf_token_key":"csrf_token","images":{"banned_image":"https://arch.b4k.co/foolfuuka/foolz/foolfuuka-theme-foolfuuka/assets-1.2.28/images/banned-image.png","banned_image_width":150,"banned_image_height":150,"missing_image":"https://arch.b4k.co/foolfuuka/foolz/foolfuuka-theme-foolfuuka/assets-1.2.28/images/missing-image.jpg","missing_image_width":150,"missing_image_height":150},"gettext":{"submit_state":"Submitting","thread_is_real_time":"This thread is being displayed in real time.","update_now":"Update now","ghost_mode":"This thread has entered ghost mode. Your reply will be marked as a ghost post and will only affect the ghost index."},"board_shortname":"v"};`);
|
||||||
|
// head
|
||||||
|
//body
|
||||||
|
{
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/bootstrap.min.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/plugins.js");
|
||||||
|
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/board.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/fuuka.js");
|
||||||
|
await addFromSource(ndom.body, "https://based.coom.tech/lazyload.js");
|
||||||
|
}
|
||||||
|
return [ndom.documentElement.innerHTML, evalWhenReady] as [string, string[]];
|
||||||
|
};
|
||||||
|
|
||||||
|
let gmo: MutationObserver;
|
||||||
|
let ispostreload = false;
|
||||||
|
|
||||||
|
const earlystartup = async () => {
|
||||||
|
if (location.host == 'arch.b4k.co') {
|
||||||
|
if (GM.info.version == "2.13.0") {
|
||||||
|
alert(`Due to b4k's admin being a faggot, PEE will get you banned if you're not using Greasemonkey Beta and enabled "Synchronous page mode" or TamperMonkey with Instant Injection`);
|
||||||
|
alert("Because you use the regular GM, PEE will disable itself on this domain");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!GM_getValue("warning_seen", false)) {
|
||||||
|
alert(`Due to b4k's admin being a faggot, PEE will get you banned if you're not using Greasemonkey Beta and enabled "Synchronous page mode" or TamperMonkey with Instant Injection`);
|
||||||
|
alert("Make sure you have enabled \"Synchronous page mode\" on VM Beta or Instant Injection on TM");
|
||||||
|
if (!confirm("Proceed?")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GM_setValue("warning_seen", true);
|
||||||
|
}
|
||||||
|
document.documentElement.innerHTML = '';
|
||||||
|
const k = await GM_fetch(location.href);
|
||||||
|
const src = await k.text();
|
||||||
|
gmo.disconnect();
|
||||||
|
ispostreload = true;
|
||||||
|
const [code, scripts] = await cleanupHTML(src);
|
||||||
|
unsafeWindow.document.documentElement.innerHTML = code;
|
||||||
|
await new Promise(r => setTimeout(r, 500));
|
||||||
|
//unsafeWindow.document.documentElement.replaceWith(unsafeWindow.document.documentElement.cloneNode(true));
|
||||||
|
for (const s of scripts)
|
||||||
|
unsafeWindow.eval(s);
|
||||||
|
unsafeWindow.dispatchEvent(new CustomEvent("load"));
|
||||||
|
// out of spite:
|
||||||
|
document.querySelectorAll<HTMLImageElement>('img[data-src]').forEach(i => {
|
||||||
|
i.src = i.getAttribute('data-src')!;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const startup = async (is4chanX = true) => {
|
||||||
const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement;
|
const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement;
|
||||||
|
const customStyles = document.createElement('style');
|
||||||
|
//return;
|
||||||
|
customStyles.appendChild(document.createTextNode(globalCss));
|
||||||
|
document.documentElement.insertBefore(customStyles, null);
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
meta.setAttribute('name', 'referrer');
|
meta.setAttribute('name', 'referrer');
|
||||||
|
@ -466,13 +555,31 @@ const startup = async (is4chanX = true) => {
|
||||||
}));
|
}));
|
||||||
//await Promise.all(posts.map(e => processPost(e as any)));
|
//await Promise.all(posts.map(e => processPost(e as any)));
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('4chanXInitFinished', () => startup(true));
|
document.addEventListener('4chanXInitFinished', () => startup(true));
|
||||||
document.addEventListener('4chanParsingDone', () => startup(false), { once: true });
|
document.addEventListener('4chanParsingDone', () => startup(false), { once: true });
|
||||||
if (supportedAltDomain(location.host)) {
|
if (supportedAltDomain(location.host)) {
|
||||||
window.addEventListener('load', () => {
|
if (location.host == 'arch.b4k.co') {
|
||||||
startup(false);
|
gmo = new MutationObserver(m => {
|
||||||
|
for (const r of m) {
|
||||||
|
if (ispostreload) debugger;
|
||||||
|
r.addedNodes.forEach(e => {
|
||||||
|
if ((e as any).tagName == "SCRIPT") {
|
||||||
|
if (e.parentElement?.tagName == "HEAD" || e.parentElement?.tagName == "BODY")
|
||||||
|
e.parentElement?.removeChild(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gmo.observe(document.documentElement, { subtree: true, childList: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const proceed = earlystartup();
|
||||||
|
|
||||||
|
window.addEventListener('load', async () => {
|
||||||
|
if (await proceed)
|
||||||
|
startup(false);
|
||||||
}, { once: true });
|
}, { once: true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('4chanThreadUpdated', ((e: CustomEvent<{ count: number }>) => {
|
document.addEventListener('4chanThreadUpdated', ((e: CustomEvent<{ count: number }>) => {
|
||||||
|
@ -526,16 +633,6 @@ document.addEventListener('QRDialogCreation', <any>((e: CustomEvent<HTMLElement>
|
||||||
|
|
||||||
}), { once: !cappState!.is4chanX }); // 4chan's normal extension destroys the QR form everytime
|
}), { once: !cappState!.is4chanX }); // 4chan's normal extension destroys the QR form everytime
|
||||||
|
|
||||||
const customStyles = document.createElement('style');
|
|
||||||
customStyles.appendChild(document.createTextNode(globalCss));
|
|
||||||
document.documentElement.insertBefore(customStyles, null);
|
|
||||||
const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement;
|
|
||||||
|
|
||||||
if (meta) {
|
|
||||||
meta.setAttribute('name', 'referrer');
|
|
||||||
meta.setAttribute('content', 'no-referrer');
|
|
||||||
}
|
|
||||||
|
|
||||||
function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) {
|
function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) {
|
||||||
if (ress.length == 0)
|
if (ress.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user