From e8d76fea7fc5cb810b13cff7177ee94cb28b36be Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Thu, 26 May 2016 01:23:57 +0200 Subject: [PATCH] Don't call getBetterUrl for the pageAction checks getBetterUrl is rather expensive (especially for Pixiv URLs), and there is no real reason to call it before calling isCoolUrl if isCoolUrl is made to check if the URL is a Pixiv URL. --- background.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/background.js b/background.js index 000aec8..39b0c94 100644 --- a/background.js +++ b/background.js @@ -229,14 +229,13 @@ function isCoolUrl(url, callback) { console.log('blacklist disabled!'); } - callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isSkypeUrl(url)); + callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isPixivUrl(url) || isSkypeUrl(url)); }); } chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if(tab.active) { - getBetterUrl(tab.url, function(betterUrl) { - isCoolUrl(betterUrl, function (cool) { + isCoolUrl(tab.url, function (cool) { if(cool) { chrome.pageAction.show(tabId); } @@ -247,8 +246,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.onActivated.addListener(function(activeInfo) { chrome.tabs.get(activeInfo.tabId, function(tab) { - getBetterUrl(tab.url, function(betterUrl) { - isCoolUrl(betterUrl, function(cool) { + isCoolUrl(tab.url, function(cool) { if (cool) { chrome.pageAction.show(activeInfo.tabId); }