Comment 5 for bug 1055832

Revision history for this message
Tomek Nowak (tomnow1990) wrote :

Same here. Only OMG Ubuntu is working. And only in Firefox.

When I log in to my GMail in Firefox, I got this (in error console): Error in parsing value for 'display'. Declaration dropped.

In /usr/share/unity-webapps/userscripts/webapps-gmail I have two files: GMail.user.js and manifest.json

In GMail.user.js I have this:
// ==UserScript==
// @include https://mail.google.com/*
// @require utils.js
// @require google-common.js
// ==/UserScript==

window.Unity = external.getUnityObject(1);
var doc = null, pane = null;

function isCorrectPage() {
    var i, ids = ['canvas_frame', 'hist_frame', 'js_frame'];

    for (i = 0; i < ids.length; i++) {
        if (!document.getElementById(ids[i])) {
            return false;
        }
    }

    return true;
}

function getNumber(str) {
    try {
        var onlyNumber = str.match(/\(([0-9]|,)+\)/)[0].match(/([0-9]|,)+/)[0];

        return onlyNumber.replace(/,/g, "");
    } catch (x) {
        return '0';
    }
}

function getLabels() {
    var i, res = [];

    var snapshot = doc.evaluate('//div[2]/div/div/div[5]/div/*/div/div/div[2]/span/a',
                                pane, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

    for (i = 0; i < snapshot.snapshotLength; i++) {
        var node = snapshot.snapshotItem(i);

        res.push({ name: node.textContent.match(/^[^(]+/)[0],
                   count: getNumber(node.textContent),
                   link: node.href });
    }

    return res;
}

function doMatrixIntegration() {
    doMainMenuIntegration(doc);

    var i, labels = getLabels();
    for (i = 0; i < labels.length; i++) {
        Unity.addAction('/' + labels[i].name, makeRedirector(labels[i].link));
    }
}

function checkMessangesCount() {
    var inboxLink = doc.evaluate('//div[@role="navigation"]/div/div/div/div/div/div/div/div/div/span/a', doc, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
    var numMessanges = getNumber(inboxLink.text);

    Unity.MessagingIndicator.clearIndicators();

    Unity.MessagingIndicator.showIndicator(_("Inbox"), { count: numMessanges,
                                                         callback: makeRedirector(inboxLink.href) });
    var i, labels = getLabels();
    for (i = 0; i < labels.length; i++) {
        Unity.MessagingIndicator.showIndicator(labels[i].name, { count: labels[i].count,
                                                                 callback: makeRedirector(labels[i].link) });
    }
    Unity.Launcher.setCount(Number(numMessanges));
}

function unityLoaded() {
    var composeNewMessage = wrapCallback(function () {
        var compose = doc.evaluate('//div[@role="navigation"]/div[1]/div[1]/div[1][@role="button"]', doc, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;

        click(compose);
    });

    Unity.MessagingIndicator.addAction(_("Compose New Message"),
                                       composeNewMessage);
    Unity.Launcher.addAction(_("Compose New Message"),
        composeNewMessage);

    setInterval(wrapCallback(checkMessangesCount), 2000);
    checkMessangesCount();

    doMatrixIntegration();
}

if (isCorrectPage()) {
    setTimeout(wrapCallback(function wait() {
        doc = document.getElementById('canvas_frame').contentDocument;

        pane = doc.evaluate('//div[@role="navigation"]',
                            doc, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;

        if (!pane || !doc.getElementsByClassName("nU")) {
            setTimeout(wait, 1000);
            return;
        }
        var login = doc.evaluate('//div[@role="navigation"]/div/div[1]/div[3]/div/ol/li[4]/div/div/div/div[2]/span[2]', doc, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue.textContent;
        if (login.indexOf("@") === -1) {
            login = "";
        }

        Unity.init({ name: "GMail",
                     login: login,
       iconUrl: "icon://unity-webapps-gmail",
       homepage: 'https://mail.google.com',
       domain: 'mail.google.com',
                     onInit: wrapCallback(unityLoaded) });
    }), 2000);
}

In manifest.json I have this:
{"includes":["https://mail.google.com/*"],"requires":["utils.js","google-common.js"],"name":"GMail","scripts":["GMail.user.js"],"maintainer":"Webapps Team <email address hidden>","manifest-version":"1.0","integration-version":"2.2","package-name":"GMail","icons":{"128":"128/unity-webapps-gmail.png","48":"48/unity-webapps-gmail.png","52":"52/unity-webapps-gmail.png","64":"64/unity-webapps-gmail.png"},"domain":"mail.google.com","homepage":"https://mail.google.com","license":"GPL-3"}