0

I am failing to get a trivial page_action to work in Edge. It becomes active, but does not pop up popup html the same way a browser action does.

mainifest.json

        {
        "manifest_version" : 2,

        "name": "Page action",
        "version": "0.1",
        "description": "Hello World",

        "page_action": {
            "default_icon": "icon16.png", 
            "default_title": "PageActioner",
            "default_popup": "popup.html"
          },

        "background": {
            "scripts": ["background.js"]
         }             
         }

background.js

        console.log("This goes nowhere would be good to get working.");

        chrome.tabs.query({currentWindow: true, active: false}, function(tabs) {
               chrome.pageAction.show(tabs[0].id);  // Colored in first tab, hacky but works
         });


        // This can work, but should not be needed and pops up in the wrong place
       // let winUrl = chrome.extension.getURL("popup.html");
        // chrome.pageAction.onClicked.addListener(function (tab) { 
        //   let wd=window.open(winUrl,  "_blank",  width=500,height=200,left=1,top=1,location=1");
        // });
                        

Could there be a permission problem? Is there a way to say all_permissions while developing? (I am side loading this from a file.)

Also, console.log() seems to disappear, but alerts seem to work.

Any help appreciated.

Tuntable
  • 3,276
  • 1
  • 21
  • 26

1 Answers1

-1

For reasons that make no sense this started to magically work. I'll leave it here as a trivial page_action example that might help someone.

Tuntable
  • 3,276
  • 1
  • 21
  • 26
  • Your background script is conceptually incorrect as it doesn't use events (see [this answer](https://stackoverflow.com/a/63966400) for more info) so it's a bad example, there are better ones [linked in the documentation](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/mv2-archive/api/pageAction). – wOxxOm Jun 16 '21 at 09:48