Skip to content

Instantly share code, notes, and snippets.

@swinton
Last active July 18, 2026 18:44
Show Gist options
  • Select an option

  • Save swinton/3a4f3dc032ef513f89bdcf7b161889d6 to your computer and use it in GitHub Desktop.

Select an option

Save swinton/3a4f3dc032ef513f89bdcf7b161889d6 to your computer and use it in GitHub Desktop.
Standalone JavaScript function that removes JavaScript and HTML restrictions that block pasting, editing, or autofilling text fields (like email or password inputs) on a web page.

restore-paste.js — Bookmarklet

Standalone JavaScript that removes JavaScript/HTML restrictions blocking paste, edit, or autofill on input and textarea fields (e.g. password fields that block pasting).

This version is packaged as a bookmarklet — a bookmark you click to instantly run the script on whatever page you're viewing. No extension required.

Install (one-time, Firefox)

  1. Show the bookmarks toolbar: Ctrl+Shift+B (or right-click any toolbar → Bookmarks Toolbar).
  2. Right-click the toolbar → New Bookmark…
  3. Name: Restore Paste
  4. Location: paste the code below exactly as-is.
  5. Click Save.
javascript:(function(){document.querySelectorAll('input, textarea').forEach(function(el){el.removeAttribute('onpaste');el.onpaste=null;el.removeAttribute('readonly');el.removeAttribute('disabled');el.addEventListener('paste',function(e){e.stopImmediatePropagation();},true);});console.log('All paste restrictions removed!');})();

Note: Paste this into the bookmark's Location field in the dialog above — not directly into the address bar. Firefox strips javascript: URLs typed/pasted straight into the URL bar as an anti-pastejacking safeguard, but the bookmark dialog is unaffected.

Use

Navigate to any page with a stubborn paste-blocked field, then click Restore Paste in your bookmarks toolbar. Check the console for confirmation: All paste restrictions removed!

Source

Unminified version, for reference:

(function() {
    document.querySelectorAll('input, textarea').forEach(el => {
        el.removeAttribute('onpaste');
        el.onpaste = null;
        el.removeAttribute('readonly');
        el.removeAttribute('disabled');
        el.addEventListener('paste', function(e) {
            e.stopImmediatePropagation();
        }, true);
    });
    console.log('All paste restrictions removed!');
})();
javascript:(function(){document.querySelectorAll('input, textarea').forEach(function(el){el.removeAttribute('onpaste');el.onpaste=null;el.removeAttribute('readonly');el.removeAttribute('disabled');el.addEventListener('paste',function(e){e.stopImmediatePropagation();},true);});console.log('All paste restrictions removed!');})();
(function() {
document.querySelectorAll('input, textarea').forEach(el => {
el.removeAttribute('onpaste');
el.onpaste = null;
el.removeAttribute('readonly');
el.removeAttribute('disabled');
el.addEventListener('paste', function(e) {
e.stopImmediatePropagation();
}, true);
});
console.log('All paste restrictions removed!');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment