From project root.
xcrun simctl --set previews delete all
(() => { | |
const matchingDivs = Array.from(document.querySelectorAll('div')).filter(div => | |
Array.from(div.classList).some(cls => | |
['DivDescriptionContentContainer', 'DivDesContainer', 'DivVideoDescription'].some(sub => cls.includes(sub)) | |
) | |
); | |
const lines = matchingDivs.map(div => | |
`"${div.innerText.trim().replace(/"/g, '""')}"` | |
); |
export default class StateManager<T> { | |
private static _instance: StateManager<any> | null; | |
private readonly type = 'StateManager'; | |
state!: T; | |
constructor(id: string, constructor: new () => T) { | |
if (StateManager._instance) return StateManager._instance; | |
if (typeof globalThis === 'object' && id in globalThis && (globalThis as any)[id]?.type === 'StateManager') { | |
StateManager._instance = (globalThis as any)[id]; | |
return StateManager._instance!; |
import Toastify from 'https://cdn.jsdelivr.net/npm/toastify-js'; | |
import css from 'https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css'; | |
const injectStylesheet = (id: string) => { | |
if (document.getElementById(id)) return; | |
let style = document.createElement('style'); | |
style.innerHTML = css; | |
style.id = id; | |
document.head.appendChild(style); | |
}; |
// 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(); | |
}); |
// 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]); | |
} | |
} |
// 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]; |
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 |
// 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}`; |
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; |