-3

I am new to coding therefore have no idea how to do this and need some help please.

What I am trying to do is a chrome extension that adds a button which has a certain function

the function is- A button in a place that when pressed, copies Address link (i think its Copy address link. I would like this to be done with 1 press of a button. Is this even possible? but i think it is

I think it has to be an extension as the page is often refreshed and pasting something into chrome console would have to be done every time the page is refreshed?

I made a small image to show what it looks like. enter image description here

I found some w3schools code

I tried to find some code it might be useful but its not quiet what I am after.

function Copy()
{
    //var Url = document.createElement("textarea");
    urlCopied.innerHTML = window.location.href;
    //Copied = Url.createTextRange();
    //Copied.execCommand("Copy");
}

Every help is appreciated. Thank you

Barmar
  • 669,327
  • 51
  • 454
  • 560
Arek123
  • 3
  • 1
  • [Java != JavaScript](http://javascriptisnotjava.com). – Jack Bashford Jun 28 '19 at 23:22
  • You mean you want to copy the URL in the regular address bar of the browser? You can just type Ctrl-L Ctrl-C to do that. – Barmar Jun 28 '19 at 23:41
  • 2
    Welcome to Stack Overflow! StackOverflow is not a free coding service. You're expected to [try to solve the problem first](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users). Please update your question to show what you have already tried in a [mcve]. For further information, please see [ask], and take the [tour] :) – Barmar Jun 28 '19 at 23:44

1 Answers1

0

Are you familiar with TamperMonkey? The TamperMonkey Chrome extension allows you to inject javascript code onto any desired webpage. It can certainly do something like you are requesting.

See these other SO references regarding TamperMonkey and how to use it.

How to add a script code in my html in real time on browser open it

Using TamperMonkey vs Writing a Chrome Extension

A simple example of what TM can do for you

cssyphus
  • 34,778
  • 18
  • 87
  • 102