update changeFavicon to only change the href attribute

This commit is contained in:
sinyo-matu 2023-05-06 18:12:54 +09:00
parent 5dfc80b2f2
commit be6161d02e
No known key found for this signature in database
GPG key ID: 247A7D2762CDC85F
2 changed files with 3 additions and 13 deletions

View file

@ -76,16 +76,6 @@ function init(reconnectDelay) {
} }
const changeFavicon = function (iconURL) { const changeFavicon = function (iconURL) {
const head = document.getElementsByTagName("head")[0]; const faviconLink = document.getElementById("favicon-link");
const newLink = document.createElement("link"); faviconLink.href = iconURL;
newLink.rel = "icon";
newLink.href = iconURL;
removeExistingFavicons();
head.appendChild(newLink);
};
const removeExistingFavicons = function () {
const links = document.getElementsByTagName("link");
Array.from(links)
.filter((link) => /\bicon\b/i.test(link.getAttribute("rel")))
.forEach((link) => link.remove());
}; };

View file

@ -429,7 +429,7 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) {
<title>%s</title> <title>%s</title>
<script src="./static/watch.js"></script> <script src="./static/watch.js"></script>
<link rel="stylesheet" href="./static/watch.css"> <link rel="stylesheet" href="./static/watch.css">
<link rel="icon" href="./static/favicon.ico"> <link id="favicon-link" rel="icon" href="./static/favicon.ico">
</head> </head>
<body data-d2-dev-mode=%t> <body data-d2-dev-mode=%t>
<div id="d2-err" style="display: none"></div> <div id="d2-err" style="display: none"></div>