Extension for Chrome - How to use the DOM on the site that is open

Asked

Viewed 76 times

0

How do I use the DOM of a page that is open in the browser by the code in my extension?

Ex: In the popup of my extension has a button, which I hope when clicking, the value of a div on the open site changes.

Can you do this? I can only access the DOM of the popup extension, but I can’t access the DOM of the open page

1 answer

0

I have an extension for Chrome and I did something like this:

document.addEventListener('DOMContentLoaded', function () {
  var btnLoginCI = createButton('Login CI');

  btnLoginCI.addEventListener('click', function () {
    alert('clicked'); // code here!!!
  });
});
  • Not quite what I want, apparently this way will create the button in the extension popup and the alert will not be displayed

Browser other questions tagged

You are not signed in. Login or sign up in order to post.