This file contains hidden or 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 css from './modal.css'; | |
export class DuplicateModalError extends Error {} | |
export type ModalOptions = { content?: string | Node, loading?: string | Node | boolean, padding?: string, footer?: string | Node, style?: string, onClose?: () => void }; | |
const node = (v: string | Node): Node => typeof v === 'string' ? document.createRange().createContextualFragment(v) : v; | |
export default class Modal { | |
dialogElement: HTMLDialogElement; | |
containerElement: HTMLDivElement; |
This file contains hidden or 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
// bookmarklet-title: ESM Imports | |
// bookmarklet-about: Test esbuild custom module resolution | |
// The following dependencies use static imports | |
// They are bundled with the bookmarklet (thereby increasing bundle size) | |
// Relative imports will resolve to files within the same gist | |
import { v4 as uuidRemoteStatic } from 'https://esm.sh/[email protected]'; | |
console.log('UUID from remote static:', uuidRemoteStatic()); |
This file contains hidden or 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
// bookmarklet-title: DOOM | |
// bookmarklet-about: Take a break. Kill some demons. The entirety of the 1993 classic DOOM shoehorned into a bookmarklet. Some browsers are snobby about executing nearly 10 MB of raw JS from the favorites bar 🙄 in which case you can opt to fetch the DOOM binary rather than embed it. | |
import Modal from '/ashtonmeuser/0613e3aeff5a4692d8c148d7fcd02f34/raw/d6dd01eaab665a14bded5487a8c03b6bb7197388/Modal.ts'; | |
import binary from 'https://cdn.jsdelivr.net/gh/ashtonmeuser/godot-wasm-doom/doom.wasm'; | |
const embed = false; // bookmarklet-var(boolean): embed | |
const uuid: string = ''; // bookmarklet-var(uuid): uuid | |
type Size = { x: number, y: number }; |
This file contains hidden or 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
// bookmarklet-title: Summarize | |
// bookmarklet-about: A simple bookmarklet that uses OpenAI’s ChatGPT to summarize the current webpage. Note that an OpenAI API key is required. Please inspect the bookmarklet source (via the “show editor” or “view gist” buttons) and the bookmarkl.ink project source (github.com/ashtonmeuser/bookmarklet-platform) to ensure that your private data is neither logged nor stored and does not leave your browser. | |
import Modal from '/ashtonmeuser/0613e3aeff5a4692d8c148d7fcd02f34/raw/7804c7276e855db7a4b2d9ae6801ac6447198810/Modal.ts'; | |
import style from './content.css'; | |
const OPENAI_API_KEY: string = ''; // bookmarklet-var(password): OPENAI_API_KEY | |
const UUID: string = ''; // bookmarklet-var(uuid): UUID | |
const errorHtml = (message: string) => `<h1>Error</h1><p>${message}</p>`; |
This file contains hidden or 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
//bookmarklet-title: Canvas DL | |
//bookmarklet-about: When playing skribbl.io and someone has made a nice drawing, this lets you download the current drawing as a PNG. | |
var w = window.wdq || (window.wdq = document.createElement("a")); | |
var p = /The word was '([^']*)'/g, | |
pp = /<span>([^<>]+) is drawing now!/g, | |
tt = document.body.innerHTML; | |
var mm, nn, xx; | |
while (mm = p.exec(tt)) nn = mm; | |
while (mm = pp.exec(tt)) xx = mm; |
This file contains hidden or 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
//bookmarklet_title: Outline | |
javascript:(function(){window.location = 'https://outline.com/' + window.location})() |
This file contains hidden or 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
// bookmarklet-title: Unhide | |
// bookmarklet-about: Toggle hidden elements. Credit to u/jcunews1 via https://www.reddit.com/r/bookmarklets/comments/nowz0j/toggle_hidden_elements | |
if (window.unhiddens_bmkl) { | |
unhiddens_bmkl.forEach(o => o[0].style.cssText = o[1]); | |
unhiddens_bmkl = undefined; | |
} else { | |
window.unhiddens_bmkl = []; | |
document.body.querySelectorAll('*:not(script,style)').forEach(e => { | |
if (getComputedStyle(e).display === 'none') { |
This file contains hidden or 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
package hasher | |
import ( | |
"crypto/sha1" | |
"encoding/hex" | |
"hash" | |
"io" | |
) | |
// HasherReader calculates the hash of a byte stream |
This file contains hidden or 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
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Launch Program", |
This file contains hidden or 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
// bookmarklet-title: Eno | |
// bookmarklet-about: Plays demoscene interpretation of Brian Eno's 1/2 from the album Ambient 1. Original code by Mathieu Henri (http://www.p01.org/music_for_tiny_airports). | |
const k = 8192; | |
let t = 0; | |
const AudioContext = window.AudioContext || window.webkitAudioContext; | |
const ac = new AudioContext(); | |
const sp = ac.createScriptProcessor(k, 0, 1); | |
sp.connect(ac.destination); | |
sp.onaudioprocess = pe => { |