Skip to content

Instantly share code, notes, and snippets.

@haridsv haridsv/bookmarklet
Last active Jun 16, 2017

Embed
What would you like to do?
Paste Enabler, remove attributes from form text fields that restrict copy and paste operations. Tested to be working on many financial websites, though on some it causes duplication (workaround: undo).
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://goo.gl/OrQlxL';void(0);
attrs = ["onpaste", "oncopy", "onfocus", "onblur", "onkeyup", "onkeydown", "onkeypress", "ondrag", "ondrop", "onclick", "onmousemove", "onmouseout", "onmouseover", "onchange"];
for (var i = 0; i< attrs.length; ++i) {
var it = document.evaluate("//input[string-length(@"+attrs[i]+")!=0 and (@type='text' or @type='password')]" , document, null, XPathResult.ANY_TYPE , null );
var l = []; var t;
while (t = it.iterateNext()) {
l.push(t);
};
for (t in l) {
for (var j = 0; j < attrs.length; ++j ) {
l[t].removeAttribute(attrs[j]);
}
l[t].onpaste = function(e) {
e.target.value = e.clipboardData.getData('text/plain');
}
}
};
undefined;
@earthsound

This comment has been minimized.

Copy link

earthsound commented Mar 23, 2016

@haridsv, I was testing your bookmarklet on https://jsfiddle.net/lesson8/ZxKdp/, but it didn't work. The console spit out these two errors:

  • VM2940:1
    Uncaught ReferenceError: Raw is not defined
    (anonymous function) @ VM2940:1
  • pasteEnabler.js:10
    Uncaught TypeError: l[t].removeAttribute is not a function
    (anonymous function) @ pasteEnabler.js:10

This is in chromium 51.0.2674.0 on Windows 7. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.