~ken-vandine/unity-webapps-mail-ru/lp1369208

1 by Alexandre Abreu
first
1
// ==UserScript==
2
// @include       http://*.mail.ru/*
3
// @include       http://mail.ru/
4
// @require       utils.js
5
// ==/UserScript==
6
23 by Robert Bruce Park
Add gettext tooling for localisation.
7
// This placeholder gets munged with real data at build time.
34.2.2 by Robert Bruce Park
Replace const with var.
8
var WebappsGettextDict = JSON.parse(unescape(
23 by Robert Bruce Park
Add gettext tooling for localisation.
9
    "%7B%22GETTEXT%22%3A%22PLACEHOLDER%22%7D"
10
));
11
1 by Alexandre Abreu
first
12
window.Unity = external.getUnityObject(1);
13
14
function isCorrectPage() {
15
    var i, ids = ['g_mail_events'];
16
17
    for (i = 0; i < ids.length; i++) {
18
        if (!document.getElementById(ids[i])) {
19
            return false;
20
        }
21
    }
22
23
    return true;
24
}
25
26
function messagingIndicatorSetup() {
27
    var countElement = document.getElementById('g_mail_events');
33 by Robert Bruce Park
Fix typo, s/checkMessangesCount/checkMessagesCount/
28
    function checkMessagesCount() {
1 by Alexandre Abreu
first
29
        var count = countElement.textContent;
30
31
        Unity.MessagingIndicator.showIndicator(_("Inbox"), { count: count });
32
    }
33
33 by Robert Bruce Park
Fix typo, s/checkMessangesCount/checkMessagesCount/
34
    countElement.addEventListener('DOMSubtreeModified', wrapCallback(checkMessagesCount), false);
1 by Alexandre Abreu
first
35
33 by Robert Bruce Park
Fix typo, s/checkMessangesCount/checkMessagesCount/
36
    checkMessagesCount();
1 by Alexandre Abreu
first
37
}
38
39
if (isCorrectPage()) {
40
    Unity.init({ name: _("mail.ru"),
23 by Robert Bruce Park
Add gettext tooling for localisation.
41
                 domain: 'mail.ru',
42
                 homepage: 'http://mail.ru/',
10 by Alexandre Abreu
Update/fix installed icons; update copyright
43
                 iconUrl: "icon://unity-webapps-mail-ru",
1 by Alexandre Abreu
first
44
                 onInit: wrapCallback(messagingIndicatorSetup) });
45
}