1
0
Fork 0

Improve code readability

This commit is contained in:
Gregory Eremin 2014-09-16 15:35:10 +04:00
parent ad6b3c6466
commit d53a1024d7
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
1 changed files with 11 additions and 11 deletions

View File

@ -5,7 +5,7 @@ chrome.runtime.getPlatformInfo(function(info) {
}
});
var update = function(info) {
function updateTab(info) {
// Ignore pinned tabs
if (info.pinned) {
return;
@ -17,12 +17,12 @@ var update = function(info) {
}
// Ignore chrome pages
if (!info.url.match(/^http/)) {
if (!info.url.indexOf('http') === 0) {
return;
}
// Ignore Chrome Web Store (restricted)
if (info.url.indexOf("https://chrome.google.com/webstore/") === 0) {
if (info.url.indexOf('https://chrome.google.com/webstore/') === 0) {
return;
}
@ -34,25 +34,25 @@ var update = function(info) {
title = m[1];
}
title = sym + (info.index + 1) +' ' + title;
title = sym + (info.index + 1) + ' ' + title;
chrome.tabs.executeScript(info.id, {
code: "document.title = '" + title + "';"
});
};
function updateAll() {
function updateAllTabs() {
chrome.tabs.query({}, function(tabs) {
for (var i = 0, tab; tab = tabs[i]; i++) {
update(tab);
for (var i = 0; i < tabs.length; i++) {
updateTab(tabs[i]);
}
});
}
chrome.tabs.onMoved.addListener(updateAll);
chrome.tabs.onRemoved.addListener(updateAll);
chrome.tabs.onMoved.addListener(updateAllTabs);
chrome.tabs.onRemoved.addListener(updateAllTabs);
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tabInfo) {
update(tabInfo);
updateTab(tabInfo);
});
updateAll();
updateAllTabs();