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
// bookmarklet-title: Stay Here | |
// bookmarklet-about: Prevent leaving current page. See https://river.me/blog/bookmarklet-stay-here/. | |
window.addEventListener('beforeunload', function (e) { | |
e.preventDefault(); | |
}); |
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
// bookmarklet-title: Kill Sticky | |
// See https://alisdair.mcdiarmid.org/kill-sticky-headers/ | |
var i, elements = document.querySelectorAll('body *'); | |
for (i = 0; i < elements.length; i++) { | |
if (getComputedStyle(elements[i]).position === 'fixed') { | |
elements[i].parentNode.removeChild(elements[i]); | |
} | |
} |
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
// bookmarklet-title: Playback Speed | |
// bookmarklet-about: Toggle video playback speed | |
const video = document.querySelector('video'); | |
if (video) { | |
const rates = [1.0, 1.5, 2.0]; | |
const rate = video.playbackRate; | |
const index = rates.indexOf(rate); | |
video.playbackRate = index >= 0 ? rates[(index + 1) % rates.length] : rates[0]; |
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
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard |
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
// bookmarklet-title: Reader | |
// bookmarklet-about: Mozilla's readability (https://github.com/mozilla/readability) piped into a modal. | |
import Modal from '/ashtonmeuser/0613e3aeff5a4692d8c148d7fcd02f34/raw/d6dd01eaab665a14bded5487a8c03b6bb7197388/Modal.ts'; | |
import { Readability } from 'https://esm.sh/@mozilla/readability'; | |
const id = ''; // bookmarklet-var(uuid): id | |
const reader = new Readability(document.cloneNode(true)).parse(); | |
const content = `<h1>${reader.title}</h1>${reader.content}`; |
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 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 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 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 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 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; |
NewerOlder