Skip to content

Commit

Permalink
fix: notification dots in tab title
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Mar 1, 2023
1 parent 508d46b commit 88d4416
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ window.onload = () => {
});

new MutationObserver(function (mutations) {
let title = mutations[0].target.innerText;
let title = document.querySelector("title").textContent;
let title_regex = /([0-9]+)/;
let messageCount = title_regex.exec(title)
? parseInt(title_regex.exec(title)[0])
? parseInt(title_regex.exec(title)[0])
: null
: null;
let tabId = document.body.id;
let tabId = document.body.dataset.tabId;
ipcRenderer.send("message-indicator", {
messageCount,
tabId,
Expand All @@ -92,10 +92,12 @@ window.onload = () => {
// Check when WhatsApp is done loading
if (mutations[0].removedNodes[0]?.innerHTML.includes("progress")) {
// Remove "Update available" message
const updateAvailableElement = document.querySelector("._3z9_h");
if (
document.querySelector("._3z9_h").innerText.includes("Update available")
updateAvailableElement &&
updateAvailableElement.innerText.includes("Update available")
) {
document.querySelector("._3z9_h").firstChild.remove();
updateAvailableElement.firstChild.remove();
}
}
}).observe(document.querySelector("#app"), {
Expand All @@ -115,6 +117,10 @@ const appendTheme = (css) => {
}
};

ipcRenderer.on("set-id", (e, id) => {
document.body.dataset.tabId = id;
});

ipcRenderer.on("set-theme", (e, theme) => {
// Reset classes
document.body.className = "web";
Expand Down

0 comments on commit 88d4416

Please sign in to comment.