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.
This commit is contained in:
Les De Ridder 2016-05-26 01:23:57 +02:00
parent b6c39c0e6c
commit e8d76fea7f
1 changed files with 3 additions and 5 deletions

View File

@ -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);
}