\r\n" +
' ';
$("#standingsTableMonstrous").html(decoded);
}
});
}
};
//
// XHR that can cross same origin policy boundaries
//
function GM_XHR() {
this.type = null;
this.url = null;
this.async = null;
this.username = null;
this.password = null;
this.status = null;
this.headers = {};
this.readyState = null;
this.abort = function() { this.readyState = 0; };
this.getAllResponseHeaders = function(name) { return this.readyState != 4 ? "" : this.responseHeaders; };
this.getResponseHeader = function(name) {
var regexp = new RegExp('^'+name+': (.*)$','im');
var match = regexp.exec(this.responseHeaders);
if (match) { return match[1]; }
return '';
};
this.open = function(type, url, async, username, password) {
this.type = type ? type : null;
this.url = url ? url : null;
this.async = async ? async : null;
this.username = username ? username : null;
this.password = password ? password : null;
this.readyState = 1;
};
this.setRequestHeader = function(name, value) { this.headers[name] = value; };
this.send = function(data) {
this.data = data;
var that = this;
GM_xmlhttpRequest({
method: this.type,
url: this.url,
headers: this.headers,
data: this.data,
onload: function(rsp) { for (var k in rsp) { that[k] = rsp[k]; } that.onreadystatechange(); },
onerror: function(rsp) { for (var k in rsp) { that[k] = rsp[k]; } }
});
};
};
var standingsInterval = 0;
function startStandings() {
stopStandings();
standingsInterval = setInterval(grabStandings, 120000);
grabStandings();
}
function stopStandings() {
if (standingsInterval){
clearInterval(standingsInterval);
standingsInterval = 0;
}
}
function updateChannels()
{
// Sort the channels
var channels = [];
for(var channel in activeChannelsCounts){
if (activeChannelsCounts[channel] > 1){
channels.push(channel);
}
}
channels.sort(function(a,b) {return activeChannelsCounts[b] - activeChannelsCounts[a];});
// Build the table
var html = "
\r\n" +
"\r\n" +
"
#
Channel Name
Join Channel
\r\n" +
"\r\n" +
"\r\n";
var limit = 50;
if (channels.length < limit)
limit = channels.length;
for (var i = 0; i < limit; i++) {
html += "
" + (i+1) + "
" + channels[i] + "
Join Channel
\r\n";
}
html += "\r\n" +
"
\r\n" +
' ';
$("#activeChannelsTable").html(html);
$(".channelBtn").on("click", function joinChannel() {
var channel = $(this).parent().prev().contents().text();
var channels = getChannelList();
if (channel && $.inArray(channel, channels) < 0) {
settings.channel += "," + channel;
Settings.save(settings);
buildDropdown();
resetChannels();
}
});
}
var channelsInterval = 0;
function startChannels() {
stopChannels();
channelsInterval = setInterval(updateChannels, 30000);
updateChannels();
}
function stopChannels() {
if (channelsInterval){
clearInterval(channelsInterval);
channelsInterval = 0;
}
}
var currentUsersName = $('div#header span.user a').html();
// Settings begin
var $robinVoteWidget = $("#robinVoteWidget");
// IF the widget isn't there, we're probably on a reddit error page.
if (!$robinVoteWidget.length) {
// Don't overload reddit, wait a bit before reloading.
setTimeout(function() {
window.location.reload();
}, 300000);
return;
}
// Get version string (if available from script engine)
var versionString = "";
if (typeof GM_info !== "undefined") {
versionString = GM_info.script.version;
}
Settings.setupUI($robinVoteWidget);
var settings = Settings.load();
var userExtra = UserExtra.load();
startUserExtra();
function tryStoreUserExtra(){
console.log("storing lastseens");
UserExtra.save(userExtra);
}
var userExtraInterval = 0;
function startUserExtra() {
userExtraInterval = setInterval(listAllUsers, 10*1000);
userExtraInterval = setInterval(tryStoreUserExtra, 20*1000);
}
// bootstrap
tryHide();
// Options begin
Settings.addButton("settingContent", "update-script-button", "Update Parrot", function(){ window.open("https://github.com/5a1t/parrot/raw/master/robin.user.js?t=" + (+ new Date()), "_blank"); });
Settings.addButton("robinChatInput", "clear-chat-button", "Clear Chat", clearChat);
Settings.addBool("hideVote", "Hide voting panel", false, tryHide);
Settings.addBool("removeSpam", "Remove bot spam", true);
Settings.addInput("spamFilters", "", "spam example 1,John Madden");
Settings.addBool("enableUnicode", "Allow unicode characters. Unicode is considered spam and thus are filtered out", false);
Settings.addBool("sidebarPosition", "Left sidebar", false, toggleSidebarPosition);
Settings.addBool("force_scroll", "Force scroll to bottom", false);
Settings.addInput("cipherkey", "16 Character Cipher Key", "Example128BitKey");
Settings.addInput("maxprune", "Max messages before pruning", "500");
Settings.addBool("tableMode", "Toggle table-mode for the message list", false, toggleTableMode);
Settings.addInput("fontsize", "Chat font size", "12");
Settings.addInput("fontstyle", "Font Style (default Consolas)", "");
Settings.addBool("alignment", "Right align usernames", true);
Settings.addInput("username_bg", "Custom background color on usernames", "");
Settings.addBool("removeRobinMessages", "Hide [robin] messages everywhere", false, setRobinMessageVisibility);
Settings.addBool("removeChanMessageFromGlobal", "Hide channel messages in Global", false);
Settings.addBool("filterChannel", "Hide non-channel messages in Global", false, function() { buildDropdown(); });
Settings.addInput("channel", "", "%parrot", function() { buildDropdown(); resetChannels(); });
Settings.addInput("channel_exclude", "", "");
Settings.addBool("tabChanColors", "Use color on channel tabs", true);
Settings.addBool("twitchEmotes", "Twitch emotes (Normal, BTTV)", false);
Settings.addBool("youtubeVideo", "Inline youtube videos", false);
Settings.addBool("timeoutEnabled", "Reload page after inactivity timeout", true);
Settings.addInput("messageHistorySize", "Sent Message History Size", "50");
Settings.addBool("monstrousStats", "Show automated leaderboard on standings page (asks for permission)", false);
Settings.addBool("reportStats", "Contribute statistics to the Automated Leaderboard.", true);
Settings.addInput("statReportingInterval", "Report Statistics Interval (seconds) [above needs to be checked]", "300");
Settings.addInput("leaderboard_current_color", "Highlight color of current chat room in leaderboard standings", '#22bb45');
Settings.addBool("enableTabComplete", "Tab Autocomplete usernames", true);
Settings.addBool("enableQuickTabNavigation", "Keyboard channel-tabs navigation", true);
Settings.addBool("enableAdvancedNaviOptions", "Keyboard navigation key remapping. Use custom settings below for switching channels instead:", false, function(){
$('input[name^=setting-quickTabNavi]').prop('disabled',!$('input[name=setting-enableAdvancedNaviOptions]').prop('checked'));
});
Settings.addBool("quickTabNaviCtrlRequired", "Ctrl", true);
Settings.addBool("quickTabNaviShiftRequired", "Shift", false);
Settings.addBool("quickTabNaviAltRequired", "Alt", true);
Settings.addBool("quickTabNaviMetaRequired", "Meta", false);
Settings.addInput("quickTabNaviKeyLeft", "Key codes: Left = 37, Up = 38, Right = 39, Down = 40. See Mozilla.org's documentation for more key codes.
Navigate left tab final key code","37");
Settings.addInput("quickTabNaviKeyRight", "Navigate right tab final key code","39");
$('input[name^=setting-quickTabNavi]').prop('disabled',!settings.enableAdvancedNaviOptions);
$("#settingContent").append("