Skip to content

Instantly share code, notes, and snippets.

@swinton
Last active October 28, 2025 15:18
Show Gist options
  • Save swinton/3a4f3dc032ef513f89bdcf7b161889d6 to your computer and use it in GitHub Desktop.
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

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.

(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!');
})();
(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