Fix #4256: add mode indicator to title

This commit is contained in:
Oliver Blanthorn 2022-06-19 15:48:15 +02:00
parent 01a5cbfba7
commit 261ba9dfe5
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -323,15 +323,23 @@ config.getAsync("modeindicator").then(mode => {
window.addEventListener("mousemove", onMouseOut)
})
async function setWindowModePrefix(mode) {
webext.browserBg.windows.update(await webext.activeWindowId(), {
titlePreface: "[ " + mode + " ] ",
})
}
try {
// On quick loading pages, the document is already loaded
statusIndicator.textContent = contentState.mode || "normal"
setWindowModePrefix(contentState.mode || "normal")
document.body.appendChild(statusIndicator)
document.head.appendChild(style)
} catch (e) {
// But on slower pages we wait for the document to load
window.addEventListener("DOMContentLoaded", () => {
statusIndicator.textContent = contentState.mode || "normal"
setWindowModePrefix(contentState.mode || "normal")
document.body.appendChild(statusIndicator)
document.head.appendChild(style)
})
@ -350,6 +358,8 @@ config.getAsync("modeindicator").then(mode => {
}
}
setWindowModePrefix(mode)
const privateMode = browser.extension.inIncognitoContext
? "TridactylPrivate"
: ""