Skip to content

Instantly share code, notes, and snippets.

View ashtonmeuser's full-sized avatar

Ashton Meuser ashtonmeuser

  • Dialpad
  • Vancouver, BC
View GitHub Profile
@ashtonmeuser
ashtonmeuser / captions.js
Last active April 20, 2025 15:36
Scrape TikTok captions
(() => {
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, '""')}"`
);
@ashtonmeuser
ashtonmeuser / StateManager.ts
Last active April 4, 2025 16:17
Set loop points on HTML video elements
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);
};
@ashtonmeuser
ashtonmeuser / Xcode.md
Created March 27, 2025 15:42
Xcode notes

Xcode Notes

Reset Preview Data

From project root.

xcrun simctl --set previews delete all
// 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]);
}
}
@ashtonmeuser
ashtonmeuser / playbackSpeed.js
Created January 24, 2025 22:17
Toggle the playback speed of a video
// 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];
@ashtonmeuser
ashtonmeuser / ChatGPT Canvas HTML Renderer from Clipboard.url
Last active January 23, 2025 03:55 — forked from rmtbb/ChatGPT Canvas HTML Renderer from Clipboard.url
Bookmarklet that lets you render a full HTML page with any included css and javascript that is currently copied to your clipboard. Also works for SVG code. Useful with ChatGPT Canvas
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
@ashtonmeuser
ashtonmeuser / reader.ts
Last active February 2, 2025 23:14
Reader view using Mozilla's readability
// 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}`;
@ashtonmeuser
ashtonmeuser / Modal.ts
Last active February 12, 2025 22:32
A simple reusable modal
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;