pageAction
page actionの実験
google内でいくつかアイコンを変えてみる
manifest.json
{ "name":"page action実験", "version":"1.0", "icons":{ "48":"48.png", "128":"128.png" }, "background_page":"b.html", "page_action":{"default_icon":"g.png"}, "permissions":["http://*.google.co.jp/*","http://*.google.com/*","tabs"] }
b.html
<script> var icon={code:"code.png",maps:"map.png",mail:"mail.png",news:"news.png"}; window.onload=function(){ chrome.tabs.onUpdated.addListener(function(tabid,info,tab){ if(info.status==="complete"){ if(tab.url!="chrome://newtab/"){ with(chrome.pageAction){ var host=tab.url.split("/")[2]; if(host.indexOf(".google.")==-1){ hide(tabid); }else{ setTitle({tabId:tabid,title:host}); var label=host.split(".")[0]; setIcon({tabId:tabid,path:icon[label]}); show(tabid) } } } } }) }; </script>
- permissionsにtabsがないと動かない?
- 他hostに飛んでもhideで消さないと以前のが残ってしまうみたい…permissionsの立場は?
さて表示中のページにごにょごにょするにはどうすればいいのかな?