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