From d53a1024d7abc4b94979a50f3114c54a2ae226c4 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Tue, 16 Sep 2014 15:35:10 +0400 Subject: [PATCH] Improve code readability --- background.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/background.js b/background.js index be9852d..9138fc7 100644 --- a/background.js +++ b/background.js @@ -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();