how to display icon only when you are within the site using page action by url

1,448 views
Skip to first unread message

Weiller Santos

unread,
Jan 5, 2015, 11:33:38 AM1/5/15
to chromium-...@chromium.org

I'm writing a chrome extension page action that works on certain URLs, more I realized that the URL specifies the icon shows in situations like this www.google.com/urlespecifies, I want the icon to appear only when the User is within the site.

My background file is thus

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {

if (~tab.url.indexOf('urlespecifies.com')) {
chrome.pageAction.show(tabId);
}

});

my manifest

{
  "name": "Compra Protegida",
  "version": "1.6",
  "description": "Alerta usuários ao acessar sites de compras virtuais não recomendado pelo Reclame Aqui ou presentes na Lista do Procon. ",
  "background" :  { 
  "scripts" :  [ "background.js" ] 
} , 
  "page_action": {
  "default_icon": "19.png",
  "default_title":"Site não recomendado",
  "default_popup":"popup.html"
},
  "permissions" : [
     "tabs"
],
  "icons" : {
    "48" : "48.png",
    "128" : "128.png"
},
"manifest_version": 2
}
Message has been deleted

Wolf War

unread,
Jan 5, 2015, 8:44:22 PM1/5/15
to chromium-...@chromium.org
I think you also need to declare path to your icon, something like this:

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (tab.url.indexOf('urlespecifies.com') > -1) {
chrome.pageAction.setIcon({tabId: tabId, path:"myExtensionIcon.png"});
chrome.pageAction.setTitle({tabId: tabId, title: "my page action text"});
chrome.pageAction.show(tabId);
}
});

Mats David Vincent Patzke

unread,
Jan 7, 2015, 2:59:34 AM1/7/15
to Wolf War, chromium-...@chromium.org

Hey, I'm not sure if I unterstand you completly but you should also check the activated tab with chrome.tabs.onActivated


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/32ab02ce-2b38-4c9e-8320-357ed1aafb66%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
Reply all
Reply to author
Forward
0 new messages