Skip to content

Instantly share code, notes, and snippets.

@michaelwestphal
Last active July 30, 2025 19:26
Show Gist options
  • Select an option

  • Save michaelwestphal/b081847a0c03601813b6ccec5e9c2486 to your computer and use it in GitHub Desktop.

Select an option

Save michaelwestphal/b081847a0c03601813b6ccec5e9c2486 to your computer and use it in GitHub Desktop.
Re-enable paste
//
// For when those pesky sites decide that you shouldn't be allowed to paste into an input...
//
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
document.addEventListener('paste', (e) => {
e.stopImmediatePropagation();
return true;
}, true);
// Ditto: copy
// https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event
document.addEventListener('copy', (e) => {
e.stopImmediatePropagation();
return true;
}, true);
// Documentation:
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
// https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment