Skip to content
Advertisement

page_action click does not work while browser_action click works in Chrome Extension?

I want to make a simple browser extension like Font Face Ninja which toggles UI when page_action or browser_action is clicked.

The following code using browser_action works –

background.js

JavaScript

manifest.json

JavaScript

While the following code using page_action does not work –

background.js

JavaScript

manifest.json

JavaScript

According to MDN docs,

Page actions are like browser actions, except that they are associated with particular web pages rather than with the browser as a whole. If an action is only relevant on certain pages, then you should use a page action and display it only on relevant pages. If an action is relevant to all pages or to the browser itself, use a browser action.

Which confirms I want to use page_action but its not working.

How do I make it work using page_action?

Advertisement

Answer

Page Action

A way to make page_action work can be found on my Github → https://github.com/deadcoder0904/insert-remove-ui-chrome-extension/tree/page_action

background.js

JavaScript

contentScript.js

JavaScript

Browser Action

It also has a solution for browser_action on the master branch → https://github.com/deadcoder0904/insert-remove-ui-chrome-extension/

background.js

JavaScript

contentScript.js

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement