aboutsummaryrefslogtreecommitdiffstats
path: root/skip-process-bug.js
blob: 045eb8d2af96a7b35e0d1b23ceb3b3513f6da251 (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
jetpack.future.import("pageMods");

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);
//        jetpack.notifications.show('Bug ' + bugNo);
        var emailsSent = $("#bugzilla-body > dl:first",document).text();
        emailsSent = emailsSent.replace(/^(\s*)$/mg,"");
        console.log(emailsSent); // to be sent to jetpack.notifications.show when available
        document.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
    }
};

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

//     "https://bugzilla.redhat.com/attachment.cgi", 
//  http://code.google.com/chrome/extensions/match_patterns.html sucks, we don't have $

//      paths = pages.map(function(p) root + p + '.cgi'),
//      collision = 'Mid-air collision!';
//  if (paths.some(function(p) doc.location == p) && doc.title != collision) {
//    var $doc = $(doc),
//        mail = $doc.find('#bugzilla-body > dl').text(),
//        bug = $($doc.find('.bz_alias_short_desc_container > a'));
//    /* Bail if we sense a disturbance. */
//    if (bug.size() != 0) {
//      jetpack.notifications.show({title: 'Mail sent for ' + bug.text(), body: mail});
//      doc.location = root + bug.attr('href');
//    }
//  }
//});