0

Probably I'm having a misunderstanding about how to use the browser_action, but basically I need to trigger an action on the actual tab opened on the browser via the popup.html opened when I click my extension icon and inside of this html I have a button for this trigger.

This is my code below, what I'm doing wrong?

manifest.json

{
  "name": "Test",
  "description": "Test",
  "version": "1.0.0",
  "manifest_version": 2,
  "minimum_chrome_version": "46",
  
  "permissions": ["tabs", "<all_urls>"],
 
  "background":{
    "scripts":["script.js"]
  },
  "browser_action": {
    "default_title": "Test",
    "default_popup": "popup.html",  
    "default_icon": {
      "16": "/images/icon-16.png",
      "48": "/images/icon-48.png",
      "128": "/images/icon-128.png"
    }
  },
  
}

script.js

document.getElementById("myButton").addEventListener("click", test);
function test() {
  alert("Message")
}

popup.html

<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-    scale=1.0">
    <title>Document</title>
  </head>
<body>
  <h1>Ruiz Careca</h1>
  <button id="myButton"> Show password</button>

  <script type="text/javascript" src="./script.js" ></script>
</body>
</html>
  • Replace `test()` with `test` in the first line of script.js. – wOxxOm Jun 15 '22 at 04:45
  • This isnt the problem, the thing is im not getting my console.log on the tab opened, the console.log is displaying on the html opened in my extension. – Guilherme Gonzalez Jun 15 '22 at 14:31
  • I really dont know why the stackoverflow tagged my question as duplicated, so i create a new one -> https://stackoverflow.com/questions/72633389/how-to-trigger-an-action-on-the-opened-tab-via-my-popup-html-extension – Guilherme Gonzalez Jun 15 '22 at 14:41

0 Answers0