I know that I can use copy()
function on the console to add content to the clipboard.
When I am on any other page copy('test')
works.
When I am on youtube I get:
Uncaught TypeError: copy is not a function
How can I fix this. E.g. Is there a way to prevent a site from overriding specific functions using devtools?
Strangely on firefox copy()
works on youtube, so could this be a chrome bug?
The issue is that there is an element on that page with id="copy". If you type copy
in the console, you should get a element printed out like this:
$ copy
<g id="copy"></g>
So, you'll have to remove that element before using the copy
function:
document.querySelector('#copy').remove();
Running it in console again should show it's a function:
$ copy
ƒ copy() { [native code] }
Then use copy()
as normal, e.g. copy(myVariable)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With