Handle user impersonation using bold filter differently

This commit is contained in:
calzoneman 2013-08-08 10:57:46 -04:00
parent c7501bfd50
commit 9256928d82
2 changed files with 56 additions and 3 deletions

View File

@ -88,7 +88,7 @@ var Channel = function(name, Server) {
}; };
this.filters = [ this.filters = [
new Filter("monospace", "`([^`]+)`", "g", "<code>$1</code>"), new Filter("monospace", "`([^`]+)`", "g", "<code>$1</code>"),
new Filter("bold", "(.)\\*([^\\*]+)\\*", "g", "$1<strong>$2</strong>"), new Filter("bold", "(^|\\s)\\*([^\\*]+)\\*", "g", "$1<strong>$2</strong>"),
new Filter("italic", "(^| )_([^_]+)_", "g", "$1<em>$2</em>"), new Filter("italic", "(^| )_([^_]+)_", "g", "$1<em>$2</em>"),
new Filter("strikethrough", "~~([^~]+)~~", "g", "<s>$1</s>"), new Filter("strikethrough", "~~([^~]+)~~", "g", "<s>$1</s>"),
new Filter("inline spoiler", "\\[spoiler\\](.*)\\[\\/spoiler\\]", "ig", "<span class=\"spoiler\">$1</span>"), new Filter("inline spoiler", "\\[spoiler\\](.*)\\[\\/spoiler\\]", "ig", "<span class=\"spoiler\">$1</span>"),

View File

@ -272,6 +272,42 @@ function calcUserBreakdown() {
return breakdown; return breakdown;
} }
function sortUserlist() {
var slice = Array.prototype.slice;
var list = slice.call($("#userlist .userlist_item"));
list.sort(function (a, b) {
var r1 = $(a).data("dropdown-info").rank;
var r2 = $(b).data("dropdown-info").rank;
var afk1 = $(a).find(".icon-time").length > 0;
var afk2 = $(b).find(".icon-time").length > 0;
var name1 = a.children[1].innerHTML.toLowerCase();
var name2 = b.children[1].innerHTML.toLowerCase();
if(USEROPTS.sort_afk) {
if(afk1 && !afk2)
return 1;
if(!afk1 && afk2)
return -1;
}
if(USEROPTS.sort_rank) {
if(r1 < r2)
return 1;
if(r1 > r2)
return -1;
}
return name1 === name2 ? 0 : (name1 < name2 ? -1 : 1);
});
list.forEach(function (item) {
$(item).detach();
});
list.forEach(function (item) {
$(item).appendTo($("#userlist"));
});
}
/* queue stuff */ /* queue stuff */
function scrollQueue() { function scrollQueue() {
@ -541,6 +577,18 @@ function showOptionsMenu() {
showts.prop("checked", USEROPTS.show_timestamps); showts.prop("checked", USEROPTS.show_timestamps);
addOption("Show timestamps", tscontainer); addOption("Show timestamps", tscontainer);
var srcontainer = $("<label/>").addClass("checkbox")
.text("Sort userlist by rank");
var sr = $("<input/>").attr("type", "checkbox").appendTo(srcontainer);
sr.prop("checked", USEROPTS.sort_rank);
addOption("Userlist sort", srcontainer);
var sacontainer = $("<label/>").addClass("checkbox")
.text("AFKers at bottom of userlist");
var sa = $("<input/>").attr("type", "checkbox").appendTo(sacontainer);
sa.prop("checked", USEROPTS.sort_afk);
addOption("Userlist sort", sacontainer);
var blinkcontainer = $("<label/>").addClass("checkbox") var blinkcontainer = $("<label/>").addClass("checkbox")
.text("Flash title on every incoming message"); .text("Flash title on every incoming message");
var blink = $("<input/>").attr("type", "checkbox").appendTo(blinkcontainer); var blink = $("<input/>").attr("type", "checkbox").appendTo(blinkcontainer);
@ -596,6 +644,9 @@ function showOptionsMenu() {
USEROPTS.qbtn_idontlikechange = oqbtn.prop("checked"); USEROPTS.qbtn_idontlikechange = oqbtn.prop("checked");
USEROPTS.ignore_channelcss = nocss.prop("checked"); USEROPTS.ignore_channelcss = nocss.prop("checked");
USEROPTS.ignore_channeljs = nojs.prop("checked"); USEROPTS.ignore_channeljs = nojs.prop("checked");
USEROPTS.sort_rank = sr.prop("checked");
USEROPTS.sort_afk = sa.prop("checked");
sortUserlist();
if(CLIENT.rank >= Rank.Moderator) { if(CLIENT.rank >= Rank.Moderator) {
USEROPTS.modhat = modhat.prop("checked"); USEROPTS.modhat = modhat.prop("checked");
USEROPTS.joinmessage = join.prop("checked"); USEROPTS.joinmessage = join.prop("checked");
@ -1237,9 +1288,11 @@ function formatChatMessage(data) {
} }
if(data.superadminflair) if(data.superadminflair)
skip = false; skip = false;
if(data.msgclass == "server-whisper") { if(data.msgclass == "server-whisper")
skip = true; skip = true;
} // Prevent impersonation by abuse of the bold filter
if(data.msg.match(/^\s*<strong>\w+\s*:\s*<\/strong>\s*/))
skip = false;
LASTCHATNAME = data.username; LASTCHATNAME = data.username;
LASTCHATTIME = data.time; LASTCHATTIME = data.time;
var div = $("<div/>"); var div = $("<div/>");