Skip to content

Instantly share code, notes, and snippets.

@mimonelu
Created March 5, 2021 12:29
Show Gist options
  • Select an option

  • Save mimonelu/0303cb5d035e8cecaa0ce9168df511fd to your computer and use it in GitHub Desktop.

Select an option

Save mimonelu/0303cb5d035e8cecaa0ce9168df511fd to your computer and use it in GitHub Desktop.
Font Changer Bookmarklet
javascript: (() => { const fonts = [ '-', 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded', '-', 'Arial', 'Arial Black', 'Bookman', 'Comic Sans MS', 'Courier', 'Courier New', 'Garamond', 'Georgia', 'Impact', 'Palatino', 'Tahoma', 'Times', 'Times New Roman', 'Trebuchet MS', 'Verdana' ]; const select = document.createElement('select'); select.style.cssText = 'position: fixed; top: 1rem; right: 1rem; z-index: 65535;'; fonts.forEach((font) => { const option = document.createElement('option'); option.innerText = font; select.appendChild(option); }); select.onchange = () => { let font = fonts[select.selectedIndex]; if (font === '-') font = ''; document.body.style.fontFamily = font; }; document.body.appendChild(select); select.focus(); })(); void 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment