Chrome New Tab Event

I want to fire an event when a new tab is created in Chrome. I thought the following would do it, but it doesn't seem to be. (beginning)

manifest.json

{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "background_page": "background.html",
  "permissions": [
    "tabs"
  ]
}

background.html

<html>
    <head>
        <script type="text/javascript">
            chrome.tabs.onCreated.addListener(function() {alert('hello new tab'});
        </script>
    </head>
    <body>
    </body>
</html>
+3
source share
1 answer

Are you just missing the closing parenthesis )?

...{alert('hello new tab'});
                         ^

Because besides this, your code works for me.

+2
source

Source: https://habr.com/ru/post/1765434/


All Articles