Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a page_action chrome extension

I am trying to create a page action chrome extension. It installs fine and I get the icon working when it's a browser action, however not with page action. So how do I debug it when I cannot right-click "inspect popup".

Added the following to the manifest and removed browser action:

"page_action": {
  "default_icon":  "icons/icon19.png", // optional
  "default_title": "Switch",     // optional; shown in tooltip
  "default_popup": "src/popup.html"    // optional
},

Thanks

like image 280
James Baxter Avatar asked Oct 22 '25 07:10

James Baxter


1 Answers

The difference between a page action and a browser action:

Browser action is always displayed, while a page action is only displayed on some pages where it makes sense.

Therefore, after declaring your page action in the manifest, you have to actually show it in a given tab with chrome.pageAction.show(tabId) (from the background script).

// Most primitive way to show the page action - on every tab update
chrome.tabs.onUpdated.addListener( function(tabId) {
  chrome.pageAction.show(tabId);
});

If the icon is shown, you can debug its popup as normally - Inspect Popup will be available.

like image 148
Xan Avatar answered Oct 25 '25 01:10

Xan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!