Skip to content

Instantly share code, notes, and snippets.

@evanreichard
Created January 26, 2025 16:10
Show Gist options
  • Save evanreichard/df124524d8b20b79508afd35bcc42e08 to your computer and use it in GitHub Desktop.
Save evanreichard/df124524d8b20b79508afd35bcc42e08 to your computer and use it in GitHub Desktop.
enable-paste.user.js
// ==UserScript==
// @name Paste Enabler
// @version 0.0.1
// @description Re-enables paste functionality on websites
// @author Evan Reichard
// @match *://*/*
// @grant GM.registerMenuCommand
// @noframes
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const enablePasteFunction = function() {
const events = ['paste', 'copy', 'cut'];
events.forEach(function(event) {
document.addEventListener(event, function(e) {
e.stopImmediatePropagation();
return true;
}, true);
});
document.querySelectorAll('input, textarea').forEach(function(el) {
el.setAttribute('oncopy', 'return true');
el.setAttribute('onpaste', 'return true');
el.setAttribute('oncut', 'return true');
el.removeAttribute('readonly');
});
};
// Register the menu command
GM.registerMenuCommand("Enable Paste", enablePasteFunction, "p");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment