diff --git a/changelog.html b/changelog.html index 8ea4834c..36854f2d 100644 --- a/changelog.html +++ b/changelog.html @@ -1,4 +1,10 @@ -
@
) followed by usernames are clickable. Localized display names will not work.)@
) open the user\'s moderation card when clicked.',
+
+ on_update: utils.toggle_cls('ffz-clickable-mentions')
+}
+
+
// ---------------------
// Setup
// ---------------------
@@ -196,6 +210,7 @@ FFZ.prototype.setup_tokenization = function() {
this._link_data = {};
this.load_twitch_emote_data();
+ utils.toggle_cls('ffz-clickable-mentions')(this.settings.clickable_mentions);
try {
helpers = window.require && window.require("web-client/helpers/chat/chat-line-helpers");
@@ -843,6 +858,9 @@ FFZ.prototype.tokenize_chat_line = function(msgObject, prevent_notification, del
}
}
+ // Tokenize users last.
+ tokens = this.tokenize_users(tokens);
+
msgObject.cachedTokens = tokens;
return tokens;
}
@@ -872,6 +890,8 @@ FFZ.prototype.tokenize_line = function(user, room, message, no_emotes, no_emoji)
if ( this.settings.parse_emoji && ! no_emoji )
message = this.tokenize_emoji(message);
+ message = this.tokenize_users(message);
+
return message;
}
@@ -933,6 +953,9 @@ FFZ.prototype.render_token = function(render_links, warn_links, render_bits, tok
else if ( token.type === "raw" )
return token.html;
+ else if ( token.type === "user" )
+ return '' + utils.sanitize(token.text) + '';
+
else if ( token.type === "emoticon" ) {
var src = token.imgSrc, srcset, cls, extra;
if ( token.ffzEmote ) {
@@ -1134,6 +1157,42 @@ FFZ.prototype.tokenize_ctags = function(tokens, tags_only) {
// Emoticon Processing
// ---------------------
+FFZ.prototype.tokenize_users = function(tokens) {
+ "use strict";
+
+ if ( typeof tokens === "string" )
+ tokens = [tokens];
+
+ var new_tokens = [];
+ for(var i=0, l=tokens.length; i < l; i++) {
+ var token = tokens[i];
+ if ( ! token )
+ continue;
+
+ if ( typeof token !== "string" )
+ if ( token.type === "text" )
+ token = token.text;
+ else {
+ new_tokens.push(token);
+ continue;
+ }
+
+ var segments = token.split(/(@[a-z0-9][a-z0-9_]{3,24})/i);
+ for(var x=0, y = segments.length; x < y; x += 2) {
+ var text = segments[x] || '',
+ match = segments[x+1] || '';
+
+ if ( text.length )
+ new_tokens.push({type: 'text', text: text});
+
+ if ( match.length )
+ new_tokens.push({type: 'user', text: match, user: match.substr(1)});
+ }
+ }
+
+ return new_tokens;
+}
+
FFZ.prototype.tokenize_emotes = function(user, room, tokens, do_report) {
"use strict";
diff --git a/style.css b/style.css
index 695449b9..90324118 100644
--- a/style.css
+++ b/style.css
@@ -3726,8 +3726,8 @@ body:not(.ffz-channel-bar-bottom).ffz-small-player.ffz-minimal-channel-bar .js-p
.ban-tip { border-bottom: 1px dotted rgba(102,102,102,0.5); }
-.chat-display .chat-line .ban-target { font-weight: bold }
-.chat-display .chat-line .ban-target:hover {
+.ffz-clickable-mentions .chat-display .chat-line .user-token { font-weight: bold }
+.ffz-clickable-mentions .chat-display .chat-line .user-token:hover {
text-decoration: underline;
cursor: pointer;
}