userscript-socket-io
code:mod.ts
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="dom" />
import type {
Socket, Manager, ManagerOptions, SocketOptions,
export type { Socket, Manager, ManagerOptions, SocketOptions };
declare function io(uri: string, opts?: Partial<ManagerOptions & SocketOptions>): Socket;
const version = "4.2.0";
export async function socketIO(): Promise<Socket> {
const io = await importSocketIO();
}
function importSocketIO(): Promise<typeof io> {
const url = https://cdnjs.cloudflare.com/ajax/libs/socket.io/${version}/socket.io.min.js;
if (document.querySelector(script[src="${url}"])) {
return Promise.resolve(io);
}
const script = document.createElement("script");
script.src = url;
return new Promise((resolve, reject) => {
script.onload = () => resolve(io);
script.onerror = (e) => reject(e);
document.head.append(script);
});
}
code:mod.js
const s="4.2.0";async function n(){return(await i())("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]})}function i(){const e=https://cdnjs.cloudflare.com/ajax/libs/socket.io/${s}/socket.io.min.js;if(document.querySelector(script[src="${e}"]))return Promise.resolve(io);const o=document.createElement("script");return o.src=e,new Promise((t,c)=>{o.onload=()=>t(io),o.onerror=r=>c(r),document.head.append(o)})}export{n as socketIO}; //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiPHN0ZGluPiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiY29uc3QgdmVyc2lvbiA9IFwiNC4yLjBcIjtcbmFzeW5jIGZ1bmN0aW9uIHNvY2tldElPMSgpIHtcbiAgICBjb25zdCBpbyA9IGF3YWl0IGltcG9ydFNvY2tldElPKCk7XG4gICAgcmV0dXJuIGlvKFwiaHR0cHM6Ly9zY3JhcGJveC5pb1wiLCB7XG4gICAgICAgIHJlY29ubmVjdGlvbkRlbGF5OiA1MDAwLFxuICAgICAgICB0cmFuc3BvcnRzOiBbXG4gICAgICAgICAgICBcIndlYnNvY2tldFwiXG4gICAgICAgIF1cbiAgICB9KTtcbn1cbmZ1bmN0aW9uIGltcG9ydFNvY2tldElP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