Page Action on click

28 views
Skip to first unread message

pedro rijo

unread,
Apr 18, 2017, 5:54:32 PM4/18/17
to Chromium-Extensions-Announce
Question described (and well formatted on StackOverflow: http://stackoverflow.com/questions/43482479/chrome-extension-page-action-defining-pages)

I'm trying to build a somehow dummy Chrome extension. I want it to run only in specific pages, so I'm using a Page Action.

Let's say I want the page action to run on the Instagram website, then (accordingly [the docs](https://developer.chrome.com/extensions/match_patterns)), I would need something like this on my `manifest.json` right?

    {
      "manifest_version": 2,
      "name": "Some name",
      "version": "0.0.3",
      "description": "Some description",
      "content_scripts": [
        {
          "matches": [
            "https://www.instagram.com/*"
          ],
          "js": ["content.js"]
        }
      ],
      "page_action": {
        "default_icon": "icon.png"
      },
      "background": {
        "scripts": ["background.js"]
      }
    }

while the content script runs only on instagram pages as one would expect, the browser extension is not clickable (gray look, and when I click most options are not clickable).

this makes impossible to act upon extension button click. In my `background.js` I have:


    function click(tab) {
      console.log('click from ' + tab);
    }
    
    chrome.pageAction.onClicked.addListener(click);

that never gets called.

So, what's wrong that makes impossible to act upon extension click on some pages?

Note: I saw this question/answer, but couldn't find the problem/solution http://stackoverflow.com/questions/15711369/how-can-i-add-a-click-for-pageaction
Reply all
Reply to author
Forward
0 new messages