Skip to content

Commit

Permalink
Merge pull request #1 from DicyRoll/gmail_support
Browse files Browse the repository at this point in the history
Gmail support
  • Loading branch information
DicyRoll committed Sep 28, 2022
2 parents 02c2f6f + c2b6916 commit b8e9883
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ by downloading the zip of the repo, enabling **'Developer mode'** in the top lef
## Currently Supported Sites

- YouTube
- Gmail

---

Expand Down
23 changes: 23 additions & 0 deletions gmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
new MutationObserver(function () {
let title = document.title;
let regex = /^.+\(\d*?\)\s-\s.+$/;

//remove thousands separator
title = title.split(',').join('');

if (title.match(regex)) {
let arrayTitle = title.split(" ");
let notificationRegex = /^\(\d*?\)$/

arrayTitle.forEach(function (titleItem, index, arrayTitle) {
if (titleItem.match(notificationRegex)) {
arrayTitle.splice(index, 1);
}
});

document.title = arrayTitle.join(" ");
}
}).observe(
document.querySelector('title'),
{ subtree: true, characterData: true, childList: true }
);
12 changes: 10 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{
"name": "Clean Title",
"description": "Clean Title clears the tab title from those annoying notification numbers.",
"version": "0.1.0",
"version": "0.2.0",
"manifest_version": 3,
"content_scripts": [
{
"matches": [
"https://www.youtube.com/*"
],
"js": [
"notificationStart.js"
"youtube.js"
]
},
{
"matches": [
"https://mail.google.com/*"
],
"js": [
"gmail.js"
]
}
],
Expand Down
File renamed without changes.

0 comments on commit b8e9883

Please sign in to comment.