This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __append (el, children) { | |
for (let child of children) { | |
if (!child) continue; | |
if (Array.isArray(child)) __append(el, child); | |
else if (child instanceof HTMLElement || child instanceof DocumentFragment) el.append(child); | |
else el.append(document.createTextNode(child)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from 'preact'; | |
import { useRef, useState } from 'preact/hooks'; | |
function useReactive (initialState) { | |
let [, forceUpdate] = useState({}); | |
let reactive = useRef(null); | |
if (!reactive.current) { | |
reactive.current = new Proxy(initialState, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A teacher told us to submit the same form multiple times as sort of memory strengthening. | |
// I don't like that though, so here's a script that creates a Forms URL that contains the answers I've already filled. | |
location.origin + location.pathname + '?' + | |
Array.from(document.querySelectorAll('input[name^="entry."]')) | |
.filter((el) => el.value) | |
.map((el) => `${el.name}=${encodeURIComponent(el.value)}`) | |
.join('&'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as ed from './noble-ed25519'; | |
let encoder = new TextEncoder(); | |
let commands = new Map(); | |
export function define (name, handler) { | |
commands.set(name, handler); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Queue<V = any> { | |
head?: Node<V>; | |
tail?: Node<V>; | |
size!: number; | |
constructor () { | |
this.clear(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createDeferred<V> (): Deferred<V> { | |
let deferred: Deferred<V> = {} as any; | |
deferred.promise = new Promise((resolve, reject) => ( | |
Object.assign(deferred, { resolve, reject }) | |
)); | |
return deferred; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep (ms: number): Promise<void> { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createLazyPromise (executor) { | |
let promise; | |
function ensure () { | |
return promise || (promise = new Promise(executor)); | |
} | |
return { | |
then (onfulfilled, onrejected) { | |
return ensure().then(onfulfilled, onrejected); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getPlatformInfo } from '../utils/platform'; | |
import { noop } from '../utils/util'; | |
import * as http from '../lib/http'; | |
import { GATEWAY_VERSION } from '../constants/endpoints'; | |
import { GATEWAY } from '../constants/api'; | |
import { GatewayOP, ConnectionStatus } from '../constants/gateway'; | |
import { Inflate } from '@intrnl/pako-esm/inflate'; | |
import { Z_SYNC_FLUSH } from '@intrnl/pako-esm/constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
let random = (min, max) => ~~(Math.random() * (max - min) + min); | |
let form_data = new FormData(); | |
form_data.append('csrf_token', document.querySelector('meta[name=csrf_token]').content); | |
let elements = Array.from(document.querySelectorAll('.animetitle')); | |
console.log(`${elements.length} to delete`); |