views:

32

answers:

2

I am trying to create a simple extension in chrome that appends the tab index number to the tab title. This is my first attempt at creating an extension so I don't have much experience. I would appreciate it if someone could point out what I am doing wrong.

{
  //My manifest.json
  "name": "Tab Selector",
  "version": "1.0",
  "description": "Overlays tab index on tab title",
  "permissions": ["tabs", "http://*/*"
  ]
}
<script>  
//My background.html
chrome.tabs.onUpdated.addListener(function(tabid, changeInfo, tab)
{
  var name = tab.title + " " + tab.index;
  chrome.tabs.executeScript(tabid, {code: 'document.title = "'+ name'";'}, null);
});
</script>
A: 

unless theres a copy and paste error, it looks like you are midding a + after the name

your code:

chrome.tabs.executeScript(tabid, {code: 'document.title = "'+ name'";'}, null);

changed code

chrome.tabs.executeScript(tabid, {code: 'document.title = "'+ name + '";'}, null);

Mauro
A: 
{ code: 'document.title = "'+ name + '";' }

I think above (+ after name) will do it.

N 1.1