On many webpages they are blocking copy/paste using JavaScript.
Is there any way for making such inputs work as the should (e.g. enable copy/paste)?
I’m using Google Chrome.
On many webpages they are blocking copy/paste using JavaScript.
Is there any way for making such inputs work as the should (e.g. enable copy/paste)?
I’m using Google Chrome.
Simply highlight the text and drag it into the text field. Try it here!
This works for me in Firefox and Chrome.
ondrag
too. 😞
Press F12 Or Open the Browser Developer Panel and paste the following code into the console.
var allowPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
If you're using Firefox, I found the following solution. Not sure what minimum version is required, however.
about:config
dom.event.clipboardevents.enabled
false
This allowed me to paste immediately after changing it. I didn't even have to restart the browser.
Here's an open source Chrome Extention
https://chrome.google.com/webstore/detail/dont-fuck-with-paste/nkgllhigpcljnhoakjkgaieabnkmgdkb
If you're interested in the code https://github.com/jswanner/DontFuckWithPaste
It's hacky and won't work always but a lot of the time there is just a listener set for CTRL+C / CTRL+V and you can get around it by using CTRL+INS / SHIFT+INS instead of copy / paste.
If they are doing something goofy like using flash to write an empty string to the clipboard in a loop (twitch) then you are out of luck.
Decide to add my solution to this (making a bookmarklet inspired from this repo and extension https://github.com/jswanner/DontFuckWithPaste) This bookmarklet will also allow copying on documents that disable that using javascript.
javascript:(function(){
allowCopyAndPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('copy', allowCopyAndPaste, true);
document.addEventListener('paste', allowCopyAndPaste, true);
document.addEventListener('onpaste', allowCopyAndPaste, true);
})();
The easiest workaround (in terms of user-friendliness) for Google Chrome would be adding Allow Copy extension.
You could simply disable JavaScript on the page using a simple bookmarklet. From. http://javascript.about.com/library/bldis.htm
If you create a bookmark that contains the following script as the link (or even paste this code into the address bar and press enter) then it will rip all the JavaScript off of the current page:
javascript:void(d=document);if(frames.length){alert('Script%20doesn/'t%20work%20in%20frames');}else{while((el=d.getElementsByTagName('script')).length){el[0].parentNode.removeChild(el[0]);};onerror=function(){};d.close();}
The problem of course is that while you will now be able to paste into that text box if the form used JavaScript to submit the form then that too will be broken.
There have been multiple solutions for Windows listed here. This one is for Linux
desktops. The approach is the same - emulate keystrokes for the clipboard contents.
Create a shell script with the following lines and bind it to a key sequence (e.g. Strl+Super+V):
#!/bin/sh
clip_text="$(xclip -o -sel clipboard)"
sleep 0.5
xdotool type --clearmodifiers --delay 200 "$clip_text"
Both xclip
and xdotool
are present in any Linux distribution repository.
On windows you can use AutoHotkey
syntax:
::whatever::
Send [....text… Use {enter} for line breaks]
return
example: if you type xyz
it will write the text below (as if it was written)
::xyz::
Send hi {enter} This a new line {enter}. Another new line {enter} whatsoever. {enter}
return
For Windows, I maintain an open-source app DevComrade which, amongst other things, simulates typing of the current clipboard text upon hitting Win+Ins. Perfect for those pesky websites and desktop apps messing with the paste functionality.
On Microsoft Windows, I use a voice command in Dragon NaturallySpeaking to paste text from the clipboard into input fields that block it copy-pasting:
Sub Main
SendKeys Clipboard
Rem originalClipboard = Clipboard
Rem Clipboard("str(" & originalClipboard & ")")
Rem SendKeys "originalClipboard"
Rem Wait(1)
Rem Clipboard(originalClipboard)
End Sub
I've used that solution for many years with Dragon NaturallySpeaking 12.5 + Windows 7 + mostly Chrome, it works on all websites. The only limitation is if the copied text is very long, in which case one gets the following error message:
I've never bothered improving the script to accept a very long text input, since fields expecting a long input text pretty much always accept copy-pasting, but that should be straightforward if needs be.
https://github.com/tddschn/dont-fuck-with-paste
I made a script that uses pyautogui
to simulate the pasting that works for text fields in any app, including browsers.
You can install the tool using pipx install dont-fuck-with-paste
and use software like Alfred / Keyboard Maestro / Raycast to invoke the simulated pasting by running dfwp
or ~/.local/bin/dfwp
.