aboutsummaryrefslogtreecommitdiffstats
path: root/lib/skip-process-bug.js
blob: f4e98cc7e7a1f366859566ae8e4ae5f7955886a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
jetpack.future.import("pageMods");

// http://maymay.net/blog/2008/06/15/\
// ridiculously-simple-javascript-version-string-to-object-parser/
function parseVersionString (str) {
    if (typeof(str) != 'string') { return false; }
    var x = str.split('.');
    // parse from string or default to 0 if can't parse
    var maj = parseInt(x[0]) || 0;
    var min = parseInt(x[1]) || 0;
    var pat = parseInt(x[2]) || 0;
    return {
        major: maj,
        minor: min,
        patch: pat
    };
}

var callback = function(document){
    var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
    var titleStr = $("title",document).text();
    var REArr = RegExp("[0-9]+").exec(titleStr);
    var REHostname = RegExp("\/\/([^/]+)\/").exec(document.location.toString());
    if (REArr) {
        var bugNo = REArr[0];
        var hostname = REHostname[1];
        console.log("bugNo = " + bugNo + ", hostname = " + hostname);
        var currentFFVersion = parseVersionString(jetpack.__parent__.navigator.vendorSub);
        console.log("currentFFVersion = " + currentFFVersion.toSource());
        if ((currentFFVersion.major >= 3) && (currentFFVersion.minor >= 6)) {
        	var emailsSent = $("#bugzilla-body > dl:first",document).text();
        	emailsSent = emailsSent.replace(/^(\s*)$/mg,"");
        	jetpack.notifications.show(emailsSent);
        }
        document.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
    }
};

var options = {};
options.matches = [
    "https://bugzilla.redhat.com/process_bug.cgi",
    "https://bugzilla.redhat.com/post_bug.cgi",
    "https://bugzilla.mozilla.org/post_bug.cgi",
    "https://bugzilla.mozilla.org/process_bug.cgi"
    ];
jetpack.pageMods.add(callback, options);