Find favicon once

This commit is contained in:
Ivan Grachev 2022-08-15 17:36:56 +03:00
parent 3133431fff
commit 58c19f1c4d

View File

@ -132,11 +132,16 @@ window.addEventListener("message", function(event) {
});
var getFavicon = function() {
if (document.favicon) {
return document.favicon;
}
var nodeList = document.getElementsByTagName("link");
for (var i = 0; i < nodeList.length; i++) {
if ((nodeList[i].getAttribute("rel") == "apple-touch-icon") || (nodeList[i].getAttribute("rel") == "icon") || (nodeList[i].getAttribute("rel") == "shortcut icon")) {
const favicon = nodeList[i].getAttribute("href");
if (!favicon.endsWith("svg")) {
document.favicon = favicon;
return favicon;
}
}