Skip to content

Commit

Permalink
Fix errors of fetching favicons for search engines
Browse files Browse the repository at this point in the history
  • Loading branch information
brookhong committed Dec 16, 2023
1 parent 119c110 commit ab8461e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/background/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,14 @@ function start(browser) {
text: canvas.toDataURL()
});
};

img.onerror = (e) => {
// retry without crossOrigin
if (img.crossOrigin) {
delete img.src;
img.crossOrigin = null;
img.src = message.url;
}
};
};
self.nextFrame = function(message, sender, sendResponse) {
var tid = sender.tab.id;
Expand Down
8 changes: 5 additions & 3 deletions src/content_scripts/ui/omnibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ function SearchEngine(omnibar, front) {
url: message.url,
suggestionURL: message.suggestionURL
};
const searchEngineIconStorageKey = `surfingkeys.searchEngineIcon.${message.alias}`;
const searchEngineIconStorageKey = `surfingkeys.searchEngineIcon.${message.prompt}`;
const searchEngineIcon = localStorage.getItem(searchEngineIconStorageKey);
if (searchEngineIcon) {
self.aliases[message.alias].prompt = `<img src="${searchEngineIcon}" alt=${message.prompt} style="width: 20px;" />`;
Expand All @@ -1300,8 +1300,10 @@ function SearchEngine(omnibar, front) {
RUNTIME('requestImage', {
url: iconUrl.href,
}, function(response) {
localStorage.setItem(searchEngineIconStorageKey, response.text);
self.aliases[message.alias].prompt = `<img src="${response.text}" alt=${message.prompt} style="width: 20px;" />`;
if (response) {
localStorage.setItem(searchEngineIconStorageKey, response.text);
self.aliases[message.alias].prompt = `<img src="${response.text}" alt=${message.prompt} style="width: 20px;" />`;
}
});
}
};
Expand Down

0 comments on commit ab8461e

Please sign in to comment.