From c54522c089247b2155b42d1dc5afa533f9f72cdb Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 31 Jan 2015 13:31:32 -0500 Subject: [PATCH] support for more sites --- dist/script.js | 9 ++++++--- dist/script.js.map | 2 +- dist/style.css | 7 +------ dist/style.css.map | 2 +- src/script.coffee | 9 +++++---- src/style.scss | 4 +++- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/dist/script.js b/dist/script.js index ad290bd..2b3caf1 100644 --- a/dist/script.js +++ b/dist/script.js @@ -9,7 +9,7 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { mention = _ref[_i]; $mention = $(mention); - if ($mention.text() === ("@" + this.username)) { + if ($mention.text() === ("@" + (this.username()))) { mentions.push($mention); } } @@ -39,7 +39,7 @@ })(this) }); } - if ($.inArray(this.username, members) !== -1) { + if ($.inArray(this.username(), members) !== -1) { mentions.push($mention); } } @@ -50,9 +50,12 @@ return $.merge(this.userMentions(), this.teamMentions()); }; + GitHubMentionHighlighter.prototype.username = function() { + return this._username || (this._username = $(".supportocat a, #user-links .name, .header-right .logged-in a").text().trim().replace("@", "")); + }; + function GitHubMentionHighlighter() { var $mention, _i, _len, _ref; - this.username = $(".supportocat a, #user-links .name").text().trim(); _ref = this.mentions(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { $mention = _ref[_i]; diff --git a/dist/script.js.map b/dist/script.js.map index a18ec0e..9109077 100644 --- a/dist/script.js.map +++ b/dist/script.js.map @@ -6,5 +6,5 @@ "script.coffee" ], "names": [], - "mappings": "AAAA;AAAA,MAAA,wBAAA;;AAAA,EAAM;AAEJ,uCAAA,YAAA,GAAc,SAAA,GAAA;AACZ,UAAA,2CAAA;AAAA,MAAA,QAAA,GAAW,EAAX,CAAA;AACA;AAAA,WAAA,2CAAA;2BAAA;AACE,QAAA,QAAA,GAAW,CAAA,CAAE,OAAF,CAAX,CAAA;AACA,QAAA,IAA0B,QAAQ,CAAC,IAAT,CAAA,CAAA,KAAmB,CAAC,GA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AA8F,EAA9F,GADP;IAAA,CA5BV,CAAA;;AA+Ba,IAAA,kCAAA,GAAA;AACX,UAAA,wBAAA;AAAA;AAAA,WAAA,2CAAA;4BAAA;AACE,QAAA,QAAQ,CAAC,QAAT,CAAkB,WAAlB,CAAA,CAAA;AAAA,QACA,QAAQ,CAAC,OAAT,CAAiB,oCAAjB,CAAsD,CAAC,QAAvD,CAAgE,WAAhE,CADA,CADF;AAAA,OADW;IAAA,CA/Bb;;oCAAA;;MAFF,CAAA;;AAAA,EAsCA,CAAA,CAAE,SAAA,GAAA;WACI,IAAA,wBAAA,CAAA,EADJ;EAAA,CAAF,CAtCA,CAAA;AAAA" } \ No newline at end of file diff --git a/dist/style.css b/dist/style.css index f10fd33..98fa90c 100644 --- a/dist/style.css +++ b/dist/style.css @@ -1,7 +1,2 @@ -.timeline-comment:not(.current-user) .user-mention.highlight, .timeline-comment:not(.current-user) .team-mention.highlight, .timeline-entry .member-mention.highlight, .timeline-entry .team-mention.highlight { background: yellow !important; } - -.timeline-comment.highlight:not(.current-user), .timeline-entry.highlight { border-color: yellow !important; } - -.timeline-comment.highlight:not(.current-user):before, .timeline-entry.highlight .comment-header:before { border-right-color: yellow !important; } - +.timeline-comment:not(.current-user) .user-mention.highlight,.timeline-comment:not(.current-user) .team-mention.highlight,.timeline-entry .member-mention.highlight,.timeline-entry .team-mention.highlight,.markdown-body .user-mention.highlight,.markdown-body .user-mention.highlight{background:yellow !important}.timeline-comment.highlight:not(.current-user),.timeline-entry.highlight{border-color:yellow !important}.timeline-comment.highlight:not(.current-user):before,.timeline-entry.highlight .comment-header:before{border-right-color:yellow !important} /*# sourceMappingURL=style.css.map */ diff --git a/dist/style.css.map b/dist/style.css.map index 9fc39db..1ebe1ea 100644 --- a/dist/style.css.map +++ b/dist/style.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,8MAGyC,GACvC,UAAU,EAAE,iBAAiB;;AAG/B,yEAC0B,GACxB,YAAY,EAAE,iBAAiB;;AAGjC,uGACiD,GAC/C,kBAAkB,EAAE,iBAAiB", +"mappings": "AAAA,yRAKuC,CACrC,UAAU,CAAE,iBAAiB,CAG/B,wEAC0B,CACxB,YAAY,CAAE,iBAAiB,CAGjC,sGACiD,CAC/C,kBAAkB,CAAE,iBAAiB", "sources": ["../src/style.scss"], "names": [], "file": "style.css" diff --git a/src/script.coffee b/src/script.coffee index 56e2098..ee9aa95 100644 --- a/src/script.coffee +++ b/src/script.coffee @@ -4,7 +4,7 @@ class GitHubMentionHighlighter mentions = [] for mention in $(".user-mention, .member-mention") $mention = $(mention) - mentions.push $mention if $mention.text() == "@#{@username}" + mentions.push $mention if $mention.text() == "@#{@username()}" mentions teamMentions: -> @@ -22,15 +22,16 @@ class GitHubMentionHighlighter cache: true success: (data) => members = data["members"] - mentions.push $mention if $.inArray(@username, members) != -1 + mentions.push $mention if $.inArray(@username(), members) != -1 mentions mentions: -> $.merge @userMentions(), @teamMentions() - constructor: -> - @username = $(".supportocat a, #user-links .name").text().trim() + username: -> + @_username ||= $(".supportocat a, #user-links .name, .header-right .logged-in a").text().trim().replace("@", "") + constructor: -> for $mention in @mentions() $mention.addClass("highlight") $mention.parents(".timeline-comment, .timeline-entry").addClass("highlight") diff --git a/src/style.scss b/src/style.scss index 0bb1502..da2b152 100644 --- a/src/style.scss +++ b/src/style.scss @@ -1,7 +1,9 @@ .timeline-comment:not(.current-user) .user-mention.highlight, .timeline-comment:not(.current-user) .team-mention.highlight, .timeline-entry .member-mention.highlight, -.timeline-entry .team-mention.highlight { +.timeline-entry .team-mention.highlight, +.markdown-body .user-mention.highlight, +.markdown-body .user-mention.highlight { background: yellow !important; }