Skip to content

Instantly share code, notes, and snippets.

@mimonelu
Created June 17, 2024 13:03
Show Gist options
  • Save mimonelu/401fab5810165d595bc5f91e2ae68f30 to your computer and use it in GitHub Desktop.
Save mimonelu/401fab5810165d595bc5f91e2ae68f30 to your computer and use it in GitHub Desktop.
テキストの強制コピーブックマークレット
javascript: (() => { let enabled = true, target = null; window.addEventListener('mouseover', (e) => { if (!enabled) return; target = e.target; target.style.outline = '4px solid #ff0000'; }); window.addEventListener('mouseout', (e) => { if (!enabled) return; target.style.outline = 'none'; target = null; }); window.addEventListener('click', (e) => { if (!enabled) return; e.preventDefault(); if (target) { navigator.clipboard.writeText(e.target.innerText) } }); window.addEventListener('keyup', (e) => { if (!enabled) return; if (e.keyCode === 27) { enabled = false; if (target) { target.style.outline = 'none'; } } }); })(); void 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment