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/*
10
// @creator Brian Murray <brian@ubuntu.com>
13
// ------ User settable data -------------
15
// Color for the comment heading
17
var color = 'lightgrey';
19
// ------- End of User settable data -------/
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);
31
var reporter = xpath("//*[@class='registering']/a[@class='sprite person']").snapshotItem(0);
34
GM_log( "reporter href " + reporter );
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']");
42
for ( var i = 0; i < commenters.snapshotLength; i++ ) {
43
var commenter = commenters.snapshotItem(i);
45
GM_log( "commenter href " + commenter );
48
if ( String(commenter) == String(reporter) ) {
50
GM_log( "Found a match" );
53
var css_style = "background:" + color + ";";
54
commenter.parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute('style', css_style);
60
var actors = xpath("//div[@class='boardCommentDetails']/a[@class='sprite person']");
62
for ( var i = 0; i < actors.snapshotLength; i++ ) {
63
var actor = actors.snapshotItem(i);
65
GM_log( "actor href " + commenter );
68
if ( String(actor) == String(reporter) ) {
70
GM_log( "Found a match" );
73
var css_style = "background:" + color + ";";
74
actor.parentNode.setAttribute('style', css_style);