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?
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?
-
3
Run
copy
in console and you'll see it's a DOM element with idcopy
. Once you remove this element you can use the built-in API. – woxxom Commented Jun 5, 2020 at 10:39 -
1
@wOxxOm Thank you for the feedback. indeed
document.querySelector('#copy').remove()
works. I wonder why does this happen? Are ids supposed to be accessible as variables? I try to access a differrent id by its name but I cannot. And why this does not work on firefox? – Jannis Ioannou Commented Jun 5, 2020 at 11:15 - 2 1) see Do DOM tree elements with ids bee global variables?, 2) dunno, but google is known to serve different sites to non-chrome browsers. – woxxom Commented Jun 5, 2020 at 11:25
-
Is there anyway to reinstate
copy
? – Jikku Jose Commented Sep 27, 2020 at 6:42
1 Answer
Reset to default 16The 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)