74

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.

7
  • Its very unlikely. They don't put in that for no reason, so they'll also block any kind of way to circumvent it.
    – LPChip
    Commented May 26, 2015 at 10:49
  • 1
    There are lots of way of circumventing such scripts and a dedicated browser extension should solve many wariants of this issue.
    – syntagma
    Commented May 26, 2015 at 10:54
  • 2
    If you already know this, why do you post the question?
    – LPChip
    Commented May 26, 2015 at 10:56
  • 1
    I know it is doable, I don't know about any such extension.
    – syntagma
    Commented May 26, 2015 at 10:57
  • 2
    If you were using Firefox, you could go to about:config and change dom.event.clipboardevents.enabled to false. I don't know if something similar exists in Chrome.
    – user276648
    Commented Jul 18, 2017 at 3:05

13 Answers 13

90

Simply highlight the text and drag it into the text field. Try it here!

This works for me in Firefox and Chrome.

7
  • 4
    Great solution! In chrome you can put this string into the address bar "data:text/html, <html contenteditable>" (without the quotes) to get a blank canvas. I created a bookmark to that. Now I can paste my text into this blank page, then drag it into the fields that need filling.
    – thin
    Commented Oct 4, 2018 at 18:08
  • This is the best. Trying to run js in the developer console was giving me a headache. Many thanks!
    – Millar248
    Commented Feb 9, 2019 at 1:35
  • Cool, man? thank you.. You saved my time. Commented Dec 4, 2019 at 8:12
  • 6
    This doesn't work when the &*@(!$ web developers disable ondrag too. 😞
    – Dan
    Commented May 3, 2020 at 23:38
  • Awesome, in my case it was an application acting as a browser wrapper. I couldn't do a drag & drop of the string from a notepad file, but it worked from a wordpad file!
    – Wadih M.
    Commented Jul 23, 2021 at 20:32
47

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);
3
  • This didn't work for me with Chrome Version 101.0.4951.64 (Official Build) (64-bit) to try to paste into the password field of Super Auto Pets. Commented Jun 2, 2022 at 22:58
  • Works for me in 2024 on latest Chrome on a MacOS. Many thanks @Ahmad
    – Gray Ayer
    Commented Apr 18 at 0:36
  • Works with Copy too: var allowCopy = function(e){ e.stopImmediatePropagation(); return true; }; document.addEventListener('copy', allowCopy, true); Commented May 1 at 21:21
19

If you're using Firefox, I found the following solution. Not sure what minimum version is required, however.

  1. Go to about:config
  2. Search for dom.event.clipboardevents.enabled
  3. Double-click it to change the value to false

This allowed me to paste immediately after changing it. I didn't even have to restart the browser.

12

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

2
  • 1
    This should be the correct answer. Don't Fuck With Paste has 465 stars on Github and practically a 5 star rating on the Chrome Store - with 413 reviews. This really helped me. Thanks!
    – Ben
    Commented Jun 24, 2018 at 13:48
  • For me, this extension helps, but does not work on all sites.
    – thin
    Commented Oct 4, 2018 at 18:10
10

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.

4

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

AllowCopyAndPaste

1
  • Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
    – DavidPostill
    Commented Oct 30, 2017 at 18:19
2

The easiest workaround (in terms of user-friendliness) for Google Chrome would be adding Allow Copy extension.

1
  • 3
    Carefully vet that extension before installing. Reviewers are claiming it's malware.
    – George
    Commented Jan 19, 2017 at 21:48
1

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.

0

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
1
  • 1
    I like this one: ^Q:: SendInput, {Raw}%clipboard% CTRL-Q sends the contents of the keyboard as input (similar to typing it in)
    – nijave
    Commented Aug 16, 2018 at 1:25
0

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.

0

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

enter image description here

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:

enter image description here

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.

0

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .