Skip to content

Commit 35d8320

Browse files
committed
content_js_updated
1 parent 7f19042 commit 35d8320

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

content.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function checkNotifications() {
2+
var notificationIndicator = document.querySelector('.notification-indicator');
3+
if (notificationIndicator && notificationIndicator.getAttribute('data-ga-click') === 'Header, notification') {
4+
var notificationCount = parseInt(notificationIndicator.getAttribute('data-count'));
5+
if (notificationCount > 0) {
6+
var options = {
7+
body: 'You have ' + notificationCount + ' new notifications on GitHub.',
8+
icon: 'icon.png'
9+
};
10+
var notification = new Notification('GitHub Notification', options);
11+
}
12+
}
13+
}
14+
15+
if (Notification.permission === 'granted') {
16+
checkNotifications();
17+
} else if (Notification.permission !== 'denied') {
18+
Notification.requestPermission().then(function(permission) {
19+
if (permission === 'granted') {
20+
checkNotifications();
21+
}
22+
});
23+
}
24+
25+
setInterval(checkNotifications, 30000);
26+

0 commit comments

Comments
 (0)