No 'addListener' functions are firing chrome extension Manifest v. 3

I am trying to make a chrome extension that alerts you in the tab that you are currently moving or highlighting. I have tried reading the chrome migrating to V.3 documentation and have come up with the following code, however, the alerts never appear. Does anybody know what I need to change or add?

My ‘manifest.json’ file:

{
    "manifest_version": 3,
    "name": "Alert",
    "version": "0.1",
    "description": "alerts you when doing tab functions",
    "permissions": ["tabs", "activeTab"],
    "host_permissions": ["<all_urls>"],
    "background": {
        "service_worker": "background.js"
    }
}

My ‘background.js’ file:

chrome.tabs.onMoved.addListener(function () {
    alert("You moved this tab");
});

chrome.tabs.onHighlighted.addListener(function () {
    alert("You highlighted this tab");
});

My working directory:

.
├── background.js
├── manifest.json

11 thoughts on “No 'addListener' functions are firing chrome extension Manifest v. 3”

  1. I figured it out. Alert is not defined in javascript. Also, I was looking in the wrong place for the alert messages. I needed to look at the service worker link in my unpacked extension page. enter image description here

    Reply

Leave a Comment