Added window title/favicon script

This commit is contained in:
pythongosssss
2023-03-07 20:55:12 +00:00
parent aa2d47dc50
commit e4cf5893e3
3 changed files with 29 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

+29
View File
@@ -0,0 +1,29 @@
import { api } from "/scripts/api.js";
import { app } from "/scripts/app.js";
// Simple script that adds the current queue size to the window title
// Adds a favicon that changes color while active
app.registerExtension({
name: "pysssss.FaviconStatus",
setup() {
api.addEventListener("status", ({ detail }) => {
let title = "ComfyUI";
let favicon = "favicon";
if (detail && detail.exec_info.queue_remaining) {
favicon += "-active";
title = `(${detail.exec_info.queue_remaining}) ${title}`;
}
document.title = title;
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement("link");
link.rel = "icon";
document.head.appendChild(link);
}
link.href = new URL(`${favicon}.ico`, import.meta.url);
});
},
});