~minos-archive/minos/firefox-minos-settings

« back to all changes in this revision

Viewing changes to mozilla/firefox/h5xyzl6e.default/gm_scripts/LP_Reporter_Comments/lp_reporter_comments.user.js

  • Committer: Javier Lopez
  • Date: 2015-07-08 01:10:19 UTC
  • Revision ID: git-v1:d8c3500bae00a8a67d74f8f96235ec11d75231be
rename mozilla-minos-settings -> firefox-minos-settings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ==UserScript==
2
 
// @name           LP_Reporter_Comments
3
 
// @namespace      http://murraytwins.com/greasemonkey/
4
 
// @description    (Launchpad) Identify comments from the reporter
5
 
// @include        https://launchpad.net/*
6
 
// @include        https://*.launchpad.net/*
7
 
// @include        https://*.edge.launchpad.net/*
8
 
// @include        https://launchpad.net/*
9
 
// @date           2008-08-24
10
 
// @creator        Brian Murray <brian@ubuntu.com>
11
 
// ==/UserScript==
12
 
 
13
 
// ------  User settable data  -------------
14
 
 
15
 
// Color for the comment heading
16
 
 
17
 
var color = 'lightgrey';
18
 
 
19
 
// ------- End of User settable data -------/
20
 
 
21
 
function xpath(query, context) {
22
 
//    GM_log('xpath running');
23
 
    context = context ? context : document;
24
 
    return document.evaluate(query, context, null,
25
 
                            XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
26
 
}
27
 
 
28
 
(function() {
29
 
    var debug = 0;
30
 
 
31
 
    var reporter = xpath("//*[@class='registering']/a[@class='sprite person']").snapshotItem(0);
32
 
 
33
 
    if (debug) {
34
 
        GM_log( "reporter href " + reporter );
35
 
    }
36
 
 
37
 
    // comments appear differently depending on whether or not they are an action comment or a regular comment
38
 
    // using a separate variable, commenters and actors, for each one to properly set the sytle's color
39
 
    // probably not the most efficient but it works
40
 
    var commenters = xpath("//div[@class='boardCommentDetails']/table/tbody/tr/td/a[@class='sprite person']");
41
 
     
42
 
    for ( var i = 0; i < commenters.snapshotLength; i++ ) {
43
 
        var commenter = commenters.snapshotItem(i);
44
 
        if (debug) {
45
 
            GM_log( "commenter href " + commenter );
46
 
        } 
47
 
 
48
 
        if ( String(commenter) == String(reporter) ) {
49
 
            if (debug) {
50
 
                GM_log( "Found a match" );
51
 
            }
52
 
 
53
 
            var css_style = "background:" + color + ";";
54
 
            commenter.parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute('style', css_style);
55
 
 
56
 
        }
57
 
    }
58
 
 
59
 
 
60
 
    var actors = xpath("//div[@class='boardCommentDetails']/a[@class='sprite person']");
61
 
     
62
 
    for ( var i = 0; i < actors.snapshotLength; i++ ) {
63
 
        var actor = actors.snapshotItem(i);
64
 
        if (debug) {
65
 
            GM_log( "actor href " + commenter );
66
 
        } 
67
 
 
68
 
        if ( String(actor) == String(reporter) ) {
69
 
            if (debug) {
70
 
                GM_log( "Found a match" );
71
 
            }
72
 
 
73
 
            var css_style = "background:" + color + ";";
74
 
            actor.parentNode.setAttribute('style', css_style);
75
 
 
76
 
        }
77
 
    }
78
 
 
79
 
})();