// ==UserScript==
// @name Kongregate One
// @namespace kongregate.com
// @author UnknownGuardian, AlphaOverall, Ruudiluca, Resterman
// @version 3.0.0
// @date 06/25/2020
// @include *://www.kongregate.com/*
// @description Kongregate One - One script to rule them all. Everything here.
// @grant GM_addStyle
// @downloadURL none
// ==/UserScript==
// SCRIPT VERSION (dom)
// ^^ UPDATE this value in header / README.md as well ^^
unsafeWindow.KongOneVersion = "3.0.0";
// UPDATE as needed per release
unsafeWindow.KongOneUpdateText = `
What's new in this update?
Some of us worked on a major refactor behind the scenes that theoretically didn't affect the script functionalities much.
It added a way to toggle scripts on and off (Settings Cog -> KongOne), and added a few items.
However, it was never released or fully completed.
Since a recent Kongregate update apparently broke the original Kongregate One scripts, I (AlphaOverall) did some updates on the refactor to fix the major scripts, did a little cleanup, and released this new version.
I would rather have done more testing, but since the script was broken anyway I thought this was a good time to push out the changes and then you all can tell me if something is broken! :D
Anyways, if you find issues, please log them on GitHub and I will try to fix them. I think I'm all alone now :(
Yours truly, --AlphaOverall
`;
"use strict";
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// Categories enum
var CATEGORIES = {
MISC: "Miscellaneous",
HIDDEN: "Hidden",
CHAT: "Chat",
FORUM: "Forum",
SITEWIDE: "Site-wide"
};
var Script = function () {
function Script(name, path, defaultEnabled, category) {
_classCallCheck(this, Script);
this.name = name;
this.path = path;
this.dom = null;
this.defaultEnabled = defaultEnabled;
this.category = category || Script.CATEGORIES.MISC;
}
_createClass(Script, [{
key: "checkPath",
value: function checkPath() {
var documentPath = document.location.pathname;
return this.path.test(documentPath);
}
}, {
key: "initialize",
value: function initialize() {
this.dom = typeof unsafeWindow === "undefined" ? window : unsafeWindow;
if (!this.defaultEnabled && GM_getValue("onescript-" + this.name, "null") == "null") //never been touched before
GM_setValue("onescript-" + this.name, "false");
if (this.checkPath() && GM_getValue("onescript-" + this.name, "true") == "true") {
console.log("[KongOne] Adding Script: " + this.name);
this.run();
this.added = true;
}
}
}, {
key: "run",
value: function run() {
throw "run() not implemented for #{this.name} script";
}
}], [{
key: "CATEGORIES",
get: function get() {
return CATEGORIES;
}
}]);
return Script;
}();
var HolodeckScript = function (_Script) {
_inherits(HolodeckScript, _Script);
function HolodeckScript(name, path, defaultEnabled, category) {
_classCallCheck(this, HolodeckScript);
var _this = _possibleConstructorReturn(this, (HolodeckScript.__proto__ || Object.getPrototypeOf(HolodeckScript)).call(this, name, path, defaultEnabled, category));
_this.holodeckCheckCounter = 0;
return _this;
}
_createClass(HolodeckScript, [{
key: "initialize",
value: function initialize() {
var _this2 = this;
// Don't load script if incorrect path
if (!this.checkPath()) return;
// Load script
this.holodeckCheckCounter++;
if (typeof holodeck !== 'undefined' && holodeck.ready) {
_get(HolodeckScript.prototype.__proto__ || Object.getPrototypeOf(HolodeckScript.prototype), "initialize", this).call(this);
return;
}
if (this.holodeckCheckCounter > HolodeckScript.COUNTER_LIMIT) {
console.log("[KongOne] " + this.name + " failed to load holodeck");
return;
}
setTimeout(function () {
return _this2.initialize();
}, 100);
}
}]);
return HolodeckScript;
}(Script);
HolodeckScript.COUNTER_LIMIT = 100;
var AfkCommand = function (_HolodeckScript) {
_inherits(AfkCommand, _HolodeckScript);
function AfkCommand() {
_classCallCheck(this, AfkCommand);
return _possibleConstructorReturn(this, (AfkCommand.__proto__ || Object.getPrototypeOf(AfkCommand)).call(this, 'Chat Afk Command', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(AfkCommand, [{
key: "run",
value: function run() {
var AUTOAFK = "kongregate_autoAFKTimeout";
var AUTOAFK_MSG = "kongregate_autoAFKMessage";
var dom = this.dom,
holodeck = dom.holodeck,
CDialogue = dom.ChatDialogue,
CRoom = dom.ChatRoom,
CWindow = dom.ChatWindow,
Base64 = dom.Base64;
if (holodeck && CDialogue) {
CDialogue.prototype = dom.CDprototype || dom.ChatDialogue.prototype;
CRoom.prototype = dom.CRprototype || dom.ChatRoom.prototype;
CWindow.prototype = dom.CWprototype || dom.ChatWindow.prototype;
if (!holodeck.__afk) {
holodeck.__afk = true;
if (!holodeck.setPresenceAwayOld) {
holodeck.setPresenceAwayOld = holodeck.setPresenceAway;
holodeck.setPresenceAway = function () {
this._afk = 1;
this.setPresenceAwayOld();
};
}
if (!holodeck.setPresenceChatOld) {
holodeck.setPresenceChatOld = holodeck.setPresenceChat;
holodeck.setPresenceChat = function () {
this._afk = 0;
this.setPresenceChatOld();
};
}
if (!CRoom.prototype.updateUserOld_AFK) {
CRoom.prototype.updateUserOld_AFK = CRoom.prototype.updateUser;
CRoom.prototype.updateUser = function (user) {
this.updateUserOld_AFK.apply(this, arguments);
if (user.username == this._chat_window.username()) {
if (this._presence != user.variables.presence) {
switch (user.variables.presence) {
case "chat":
if (!this._chat_window._holodeck._afktoggle) this._chat_window._holodeck._afk = 0;
break;
case "away":
this._chat_window._holodeck._afk = 1;
break;
}
}
}
};
}
holodeck._chat_commands.afk[0] = function (l, n) {
if (l._afk === 0) {
l.setPresenceAway();
} else {
l.setPresenceChat();
}
return false;
};
holodeck._chat_commands.back[0] = function (l, n) {
l.setPresenceChat();
return false;
};
holodeck.addChatCommand("afkmessage", function (l, n) {
var a = void 0;
var z = n.match(/^\/\S+\s+(.+)/);
if (z) {
a = z[1];
GM_setValue(AUTOAFK_MSG, a);
l._afkmessage = a;
l.activeDialogue().kongBotMessage("AFK-message set to: " + a);
} else {
l.activeDialogue().kongBotMessage("Current AFK-message: " + l._afkmessage);
}
return false;
});
holodeck.addChatCommand("afktoggle", function (l, n) {
if (l._afktoggle === 0) {
l._afktoggle = 1;
l.activeDialogue().kongBotMessage("Your AFK-flag won't get removed automatically");
} else {
l._afktoggle = 0;
l.activeDialogue().kongBotMessage("Your AFK-flag will be removed automatically");
}
return false;
});
holodeck.addChatCommand("autoafk", function (l, n) {
var match = n.match(/^\/autoafk\s+(\d+)/),
timeout = 15;
if (match && match[1]) {
timeout = parseInt(match[1], 10);
}
l._autoAFK = timeout * 60 * 1000;
window.setTimeout(function () {
GM_setValue(AUTOAFK, timeout);
}, 0);
if (l._autoAFKTimeout) {
clearTimeout(l._autoAFKTimeout);
}
if (timeout) {
l.activeDialogue().kongBotMessage("Set auto-AFK timeout to " + timeout + " minute" + (timeout > 1 ? "s" : ""));
l._autoAFKTimeout = setTimeout(function (a) {
a.setPresenceAway();
}, l._autoAFK, l);
} else {
l.activeDialogue().kongBotMessage("Disabled auto-AFK");
}
return false;
});
holodeck.checkAFK = function () {
if (!this._afktoggle) {
this._afk = 0;
}
if (this._autoAFKTimeout) {
clearTimeout(this._autoAFKTimeout);
}
if (this._autoAFK) {
this._autoAFKTimeout = setTimeout(function (a) {
a.setPresenceAway();
}, this._autoAFK, this);
}
};
holodeck.addOutgoingMessageFilter(function (message, nextFunction) {
holodeck.checkAFK();
nextFunction(message, nextFunction);
});
// Outgoing whispers aren't filtered (yet), so check them manually...
if (!CWindow.prototype.oldSendPrivateMessageAFK) {
CWindow.prototype.oldSendPrivateMessageAFK = CWindow.prototype.sendPrivateMessage;
CWindow.prototype.sendPrivateMessage = function (user, msg) {
if (msg.indexOf(this._holodeck._afkprefix) !== 0) {
this._holodeck.checkAFK();
}
this.oldSendPrivateMessageAFK(user, msg);
};
}
// Create setTimeout on session reconnect
if (!CWindow.prototype.onLoginOldAFK) {
CWindow.prototype.onLoginOldAFK = CWindow.prototype.onLogin;
CWindow.prototype.onLogin = function () {
this.onLoginOldAFK();
if (this._holodeck._afk) {
this._holodeck.setPresenceAway();
} else {
this._holodeck.setPresenceChat();
this._holodeck.checkAFK();
}
};
}
if (!CDialogue.prototype.reply) {
CDialogue.prototype.reply = function (a) {};
}
if (!CDialogue.prototype.showReceivedPM) {
CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
}
CDialogue.prototype.receivedPrivateMessage = function (a) {
this.showReceivedPM(a);
if (a.data.success) {
this.reply(a.data.from);
if (this._holodeck._afk && Base64.decode(a.data.message).indexOf(this._holodeck._afkprefix) !== 0) {
this.sendPrivateMessage(a.data.from, this._holodeck._afkprefix + this._holodeck._afkmessage);
}
}
};
holodeck._afk = 0;
holodeck._afktoggle = 0;
holodeck._afkmessage = GM_getValue(AUTOAFK_MSG, "I am currently AFK");
holodeck._afkprefix = "[AFK] ";
var autoAFK = 15;
try {
if (GM_setValue) {
autoAFK = GM_getValue(AUTOAFK, 15);
} else {
GM_setValue = function GM_setValue(a, b) {};
}
} catch (e) {
GM_setValue = function GM_setValue(a, b) {};
}
holodeck._autoAFK = autoAFK * 60 * 1000;
if (holodeck._autoAFK > 0) {
holodeck._autoAFKTimeout = setTimeout(function (a) {
a.setPresenceAway();
}, holodeck._autoAFK, holodeck);
}
}
}
}
}]);
return AfkCommand;
}(HolodeckScript);
//=require ../script.js
var BetterQuotes = function (_Script2) {
_inherits(BetterQuotes, _Script2);
function BetterQuotes() {
_classCallCheck(this, BetterQuotes);
return _possibleConstructorReturn(this, (BetterQuotes.__proto__ || Object.getPrototypeOf(BetterQuotes)).call(this, 'Better Quotes', /\/(topics|posts)/, true, Script.CATEGORIES.FORUM));
}
_createClass(BetterQuotes, [{
key: "run",
value: function run() {
// Make sure $ is jQuery. Kongregate should load jQuery by default
// But has weird $ assignment
var $ = jQuery;
//Add styles
GM_addStyle("\n .expandQuote {\n text-align: center;\n background-color: #9A7;\n color: #EFC;\n font-style: italic;\n margin-top: -1px;\n -webkit-border-bottom-right-radius: 5px;\n -webkit-border-bottom-left-radius: 5px;\n -moz-border-radius-bottomright: 5px;\n -moz-border-radius-bottomleft: 5px;\n border-bottom-right-radius: 5px;\n border-bottom-left-radius: 5px;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n cursor:pointer;\n }");
GM_addStyle("\n .posts .post .body blockquote {\n overflow:hidden;\n display: block;\n }\n ");
GM_addStyle(".forum--entry blockquote { margin: 0px; }"); //Fixes Kongregate's dodgy quote padding.
//Begin script
var quoteTotal = 0;
function addBetterQuotes() {
var quotes = document.querySelectorAll(".rendered_post > blockquote");
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = quotes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var quote = _step.value;
//Create the button
if ($(quote).height() > 205) {
quoteTotal++;
var qB = document.createElement("div");
qB.innerHTML = "Read more...";
qB.className = "expandQuote";
$(qB).prop = ("disabled", true);
var sB = document.createElement("span"); //stops 'closest' from getting confused
$(quote).after(sB);
$(quote).after(qB);
$(quote).find("blockquote").find("blockquote").remove();
//Insert fake quote
var fQ = document.createElement("blockquote");
fQ.className = "fakeQuote";
fQ.innerHTML = "[quote]";
$(fQ).css("margin", "5px 0px 5px 0px");
var hQ = $(quote).find("blockquote");
$(hQ).attr("class", "hiddenQuote");
$(hQ).css("display", "none");
$(hQ).before(fQ);
//Remove read more button if necessary
if ($(quote).height() <= 195) {
$(quote).closest(".expandQuote").remove();
} else {
$(quote).height(200);
}
}
}
//When the user clicks the expand button
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
$(".expandQuote").click(function () {
var state = $(this).data('state');
var dQ = $(this).prev();
if (!state) {
$(this).html("Read less...");
$(this).data('state', true);
//toggle quotes
dQ.find(".fakeQuote").css("display", "none");
dQ.find(".hiddenQuote").css("display", "inherit");
//toggle size
$(dQ).css("height", "auto");
} else {
$(this).html("Read more...");
$(this).data('state', false);
//toggle quotes
dQ.find(".fakeQuote").css("display", "inherit");
dQ.find(".hiddenQuote").css("display", "none");
//toggle size
$(dQ).css("height", dQ[0].scrollHeight + "px");
if ($(dQ).height() > 200) {
$(dQ).css("height", "200px");
}
}
});
}
var loadCheck = setInterval(function () {
if (document.getElementsByClassName('rendered_post').length > 0) {
addBetterQuotes();
}
if (quoteTotal > 0) {
clearInterval(loadCheck);
}
}, 100);
}
}]);
return BetterQuotes;
}(Script);
//=require ../holodeckScript.js
var ChatCharacterLimit = function (_HolodeckScript2) {
_inherits(ChatCharacterLimit, _HolodeckScript2);
function ChatCharacterLimit() {
_classCallCheck(this, ChatCharacterLimit);
return _possibleConstructorReturn(this, (ChatCharacterLimit.__proto__ || Object.getPrototypeOf(ChatCharacterLimit)).call(this, 'Chat Character-limit', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(ChatCharacterLimit, [{
key: "run",
value: function run() {
var dom = this.dom,
CDialogue = dom.ChatDialogue;
if (CDialogue) {
CDialogue.prototype = dom.CDprototype || dom.ChatDialogue.prototype;
if (!CDialogue.prototype.oldKeyPressLimit) {
CDialogue.prototype.oldKeyPressLimit = CDialogue.prototype.onKeyPress;
CDialogue.prototype.onKeyPress = function (a) {
var node = this._input_node.wrappedJSObject || this._input_node;
this.oldKeyPressLimit(a);
if (node.getValue().length > 249) {
var z = node.getValue();
var y = "";
var n = z.match(/^(\/\S+\s+\S*\s*)(.*)/);
if (n) {
y = n[2];
if (y.length > 249) {
node.setValue(n[1] + y.substr(0, 249));
}
} else {
node.setValue(node.getValue().substr(0, 249));
}
}
};
}
}
}
}]);
return ChatCharacterLimit;
}(HolodeckScript);
//=require ../holodeckScript.js
var ChatLineHighlight = function (_HolodeckScript3) {
_inherits(ChatLineHighlight, _HolodeckScript3);
function ChatLineHighlight() {
_classCallCheck(this, ChatLineHighlight);
return _possibleConstructorReturn(this, (ChatLineHighlight.__proto__ || Object.getPrototypeOf(ChatLineHighlight)).call(this, 'Chat Line Highlight', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(ChatLineHighlight, [{
key: "run",
value: function run() {
var dom = this.dom,
holodeck = dom.holodeck,
CDialogue = dom.ChatDialogue,
CRoom = dom.ChatRoom,
CWindow = dom.ChatWindow;
if (CRoom && CDialogue) {
CDialogue.prototype = dom.CDprototype || dom.ChatDialogue.prototype;
CRoom.prototype = dom.CRprototype || dom.ChatRoom.prototype;
CWindow.prototype = dom.CWprototype || dom.ChatWindow.prototype;
if (!CDialogue.prototype.searchWord) {
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+/, "").replace(/\s+$/, "");
};
}
CDialogue.prototype.searchWord = function (a, b) {
for (var i = 0; i < b.length; i++) {
var r = b[i].replace(/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g, '\\$1'),
reg = new RegExp("\\b" + r + "\\b");
if (reg.test(a)) return true;
}
return false;
};
CDialogue.prototype.searchUser = function (a) {
return this.searchWord(a, this._holodeck._hluser);
};
CDialogue.prototype.searchText = function (a) {
var l = this._holodeck,
z = l._highlighting.concat([l._username.toLowerCase()]);
return this.searchWord(a, z);
};
CWindow.prototype.hlFriend = function (a) {
return this._holodeck._hl_friends && this.isFriend(a);
};
CWindow.prototype.hlMod = function (a) {
if (!this._holodeck._hl_mods) return;
return this._rooms.any(function (roomArr) {
var room = roomArr[1];
var user = room.user(a);
return user && room.canUserModerate(user);
});
};
CWindow.prototype.friendOrMod = function (a) {
if (a.toLowerCase() == this._holodeck._username.toLowerCase()) return "";
var colors = [];
if (this.hlMod(a)) colors.push(" hlmod");
if (this.hlFriend(a)) colors.push(" hlfriend");
if (colors.length > 1) return colors[this._holodeck._hl_priority];
return colors[0] || "";
};
CDialogue.prototype.displayUnsanitizedMessageOldHighlight = CDialogue.prototype.displayUnsanitizedMessage;
CDialogue.prototype.displayUnsanitizedMessage = function (user, msg, attributes, options) {
if (!attributes) attributes = {};
var classes = attributes["class"] || "";
var isWhisper = classes.indexOf("whisper") >= 0;
if (!(options && options["private"])) classes += this._user_manager.friendOrMod(user.toLowerCase());
if (!isWhisper && !this._user_manager.isMuted(user.toLowerCase()) && (this.searchUser(user.toLowerCase()) || this.searchText(msg.toLowerCase()))) {
classes += " highlight";
if (typeof this.new_private_message === "function") {
var oldChime = holodeck._pm_chime;
holodeck._pm_chime = holodeck._hl_chime;
this.new_private_message();
holodeck._pm_chime = oldChime;
}
}
attributes["class"] = classes;
this.displayUnsanitizedMessageOldHighlight(user, msg, attributes, options);
};
holodeck.addChatCommand("highlight", function (l, n) {
var k = n.match(/^\/\S+\s+(.+)/),
z = "";
k && (z = k[1]);
if (z) {
z = z.replace(/\s+/g, ' ').trim();
window.setTimeout(function () {
GM_setValue("kong_highlighting", z.toLowerCase());
}, 0);
l.activeDialogue().kongBotMessage("Now highlighting: " + z + " " + l._username);
l._highlighting = z.toLowerCase().split(' ');
}
return false;
});
holodeck.addChatCommand("hluser", function (l, n) {
var k = n.match(/^\/\S+\s+(.+)/),
z = "";
k && (z = k[1]);
if (z) {
z = z.replace(/\s+/g, ' ').trim();
window.setTimeout(function () {
GM_setValue("kong_highlightuser", z.toLowerCase());
}, 0);
l.activeDialogue().kongBotMessage("Now highlighting user(s): " + z);
l._hluser = z.toLowerCase().split(' ');
}
return false;
});
var generateCallback = function generateCallback(name, stop, start) {
return function (l, n) {
if (l["_hl_" + name]) {
l["_hl_" + name] = 0;
l.activeDialogue().kongBotMessage(stop || "Stopped highlighting messages by " + name);
} else {
l["_hl_" + name] = 1;
l.activeDialogue().kongBotMessage(start || "Now highlighting messages by " + name);
}
window.setTimeout(function () {
GM_setValue("kong_highlight" + name, l["_hl_" + name]);
}, 0);
return false;
};
};
holodeck.addChatCommand("hlmods", generateCallback("mods"));
holodeck.addChatCommand("hlfriends", generateCallback("friends"));
holodeck.addChatCommand("hlchime", generateCallback("chime", "Stopped playing the chime for highlighted messages", "Now playing the chime for highlighted messages"));
holodeck.addChatCommand("hlpriority", generateCallback("priority", "Now prioritizing mods over friends", "Now prioritizing friends over mods"));
var generateColorCallback = function generateColorCallback(selector, rule, name, text, max) {
if (!max) max = 1;
return function (l, n) {
var k = n.match(/^\/\S+\s+#?([0-9a-f]{6})/i),
z = "",
count = 0;
if (k) z = "#" + k[1];
if (z) {
var f = function f() {
return GM_setValue("kong_" + name, z);
};
for (var i = 0; i < sheet.cssRules.length; i++) {
if (sheet.cssRules[i].selectorText.indexOf(selector) === 0) {
sheet.cssRules[i].style.setProperty(rule, z, "important");
if (++count == max) {
window.setTimeout(f, 0);
l.activeDialogue().kongBotMessage("New " + (text || name) + ": " + z);
return false;
}
}
}
} else {
l.activeDialogue().kongBotMessage("No valid color! Format is /" + name + " XXXXXX (X = hex character)");
}
return false;
};
};
holodeck.addChatCommand("whispercolor", generateColorCallback("#kong_game_ui .chat_message_window .whisper", "background-color", "whispercolor"));
holodeck.addChatCommand("friendcolor", generateColorCallback("#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username", "color", "friendcolor"));
holodeck.addChatCommand("hlcolor", generateColorCallback("#kong_game_ui .chat_message_window .highlight", "background-color", "hlcolor", "highlighting-color", 2));
holodeck.addChatCommand("modcolor", generateColorCallback("#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username", "color", "modcolor"));
holodeck.addChatCommand("hllist", function (l, n) {
var diag = l.activeDialogue();
function botMessage(msg) {
diag.displayUnsanitizedMessage("Kong Bot", msg, {
"class": "whisper received_whisper"
}, {
non_user: true
});
}
botMessage("Current highlighting settings:");
if (holodeck._hluser.length > 0) {
botMessage('Users:');
botMessage('Users: ' + holodeck._hluser.map(function (user) {
return ['', user, ''].join("");
}).join(" "));
} else {
botMessage("No users highlighted");
}
if (holodeck._highlighting.length > 0) {
botMessage('Words: ' + holodeck._highlighting.join(" "));
} else {
botMessage("No words highlighted");
}
botMessage('Highlight color: ' + color + '');
botMessage('Whisper color: ' + wcolor + '');
botMessage("Highlighting friends: " + (holodeck._hl_friends ? "Yes" : "No") + ' (color: ' + fcolor + ')');
botMessage("Highlighting mods: " + (holodeck._hl_mods ? "Yes" : "No") + ' (color: ' + mcolor + ')');
botMessage("Highlight priority: " + (holodeck._hl_priority ? "Friends over mods" : "Mods over friends"));
botMessage("Playing chime: " + (holodeck._hl_chime ? typeof holodeck._pm_chime !== "undefined" ? "Yes" : 'Script not installed' : "No"));
return false;
});
holodeck.addChatCommand("hlreset", function (l, n) {
var diag = l.activeDialogue();
diag.kongBotMessage("Resetting all highlighting preferences");
holodeck._chat_commands.hlcolor[0](holodeck, "/color #def6ea");
holodeck._chat_commands.whispercolor[0](holodeck, "/color #deeaf6");
holodeck._chat_commands.friendcolor[0](holodeck, "/color #006600");
holodeck._chat_commands.modcolor[0](holodeck, "/color #ba6328");
holodeck._hl_priority = 1;
holodeck._hl_friends = 1;
holodeck._hl_mods = 1;
holodeck._hl_chime = 1;
holodeck._highlighting = [];
holodeck._hluser = [];
["highlighting", "highlightuser", "hlcolor", "whispercolor", "friendcolor", "modcolor", "highlightfriends", "highlightpriority", "highlightmods", "highlightchime"].forEach(function (pref) {
window.setTimeout(function () {
GM_deleteValue("kong_" + pref);
}, 0);
});
return false;
});
holodeck._chat_commands.hl = holodeck._chat_commands.highlight;
holodeck._chat_commands.hlfriend = holodeck._chat_commands.hlfriends;
holodeck._highlighting = [];
holodeck._hluser = [];
var color = "#def6ea",
wcolor = "#deeaf6",
fcolor = "#006600",
mcolor = "#ba6328",
priority = 1,
friends = 1,
mods = 1,
chime = 1;
if (typeof GM_setValue !== "function") {
GM_setValue = GM_getValue = function GM_getValue() {};
} else {
// migrate old value
var temp = GM_getValue("kong_highlightcolor", "");
if (temp) {
GM_setValue("kong_hlcolor", temp);
if (typeof GM_deleteValue === "undefined") {
GM_setValue("kong_highlightcolor", "");
} else {
GM_deleteValue("kong_highlightcolor");
}
}
var list = GM_getValue("kong_highlighting"),
user = GM_getValue("kong_highlightuser");
color = GM_getValue("kong_hlcolor", "#def6ea") || "#def6ea";
wcolor = GM_getValue("kong_whispercolor", "#deeaf6") || "#deeaf6";
fcolor = GM_getValue("kong_friendcolor", "#006600") || "#006600";
mcolor = GM_getValue("kong_modcolor", "#ba6328") || "#ba6328";
friends = GM_getValue("kong_highlightfriends", 1);
priority = GM_getValue("kong_highlightpriority", 1);
mods = GM_getValue("kong_highlightmods", 1);
chime = GM_getValue("kong_highlightchime", 1);
if (list) {
holodeck._highlighting = list.trim().split(' ');
}
if (user) {
holodeck._hluser = user.trim().split(' ');
}
}
holodeck._hl_friends = friends;
holodeck._hl_mods = mods;
holodeck._hl_chime = chime;
holodeck._hl_priority = priority;
// guarantee we have a non-crossdomain stylesheet
var style = document.createElement("style");
var head = document.getElementsByTagName("head")[0];
(head || document.body).appendChild(style);
// now find it...
var sheet = null;
for (var s = document.styleSheets.length - 1; s >= 0; --s) {
try {
if (document.styleSheets[s].cssRules && document.styleSheets[s].cssRules.length) {
sheet = document.styleSheets[s];
break;
}
} catch (e) {/* no-op */}
}
if (!sheet) {
alert("Kongregate Chat Line Highlighting could not find a style sheet!\nPlease send a message to Ventero about this problem.");
return;
}
sheet.insertRule('#kong_game_ui .chat_message_window .whisper { background-color: ' + wcolor + ' !important; }', sheet.cssRules.length);
sheet.insertRule('#kong_game_ui .chat_message_window .highlight.even { background-color: ' + color + ' !important; }', sheet.cssRules.length);
sheet.insertRule('#kong_game_ui .chat_message_window .highlight { background-color: ' + color + ' !important; }', sheet.cssRules.length);
sheet.insertRule('#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username { color: ' + fcolor + ' !important; }', sheet.cssRules.length);
sheet.insertRule('#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username { color: ' + mcolor + ' !important; }', sheet.cssRules.length);
}
}
}
}]);
return ChatLineHighlight;
}(HolodeckScript);
//=require ../holodeckScript.js
var ChatLog = function (_HolodeckScript4) {
_inherits(ChatLog, _HolodeckScript4);
function ChatLog() {
_classCallCheck(this, ChatLog);
return _possibleConstructorReturn(this, (ChatLog.__proto__ || Object.getPrototypeOf(ChatLog)).call(this, 'ChatLog', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(ChatLog, [{
key: "run",
value: function run() {
holodeck.addChatCommand("chatlog", function (l, msg) {
var z = msg.match(/^\/\S+\s+(.+)/),
type = ".txt";
// Allow an optional html download
if (z && z[1] == "html") type = ".html";
// Get active chat message window and log
var element = jQuery(".chat_room_template:visible .chat_message_window")[0];
var log = element.innerText;
if (type === ".html") {
// Add styling to html files
// Just grabbed these from Kong, probably not comprehensive or all necessary
log = "\n ";
log += "
" + element.innerHTML + "
";
}
// Create link to download document
var download = document.createElement("a");
download.href = "data:text/html;charset=UTF-8," + encodeURIComponent(log);
download.target = "_blank";
// Set a unique name
download.download = "Log_" + new Date().toLocaleString() + type;
// Add element (needed for FF)
document.body.appendChild(download);
// Download it
download.click();
// Remove element
document.body.removeChild(download);
// Don't send command to chat window
return false;
});
// Add /log as an optional form of command
holodeck._chat_commands.log = holodeck._chat_commands.chatlog;
}
}]);
return ChatLog;
}(HolodeckScript);
//=require ../holodeckScript.js
var ChatMouseoverTimestamp = function (_HolodeckScript5) {
_inherits(ChatMouseoverTimestamp, _HolodeckScript5);
function ChatMouseoverTimestamp() {
_classCallCheck(this, ChatMouseoverTimestamp);
return _possibleConstructorReturn(this, (ChatMouseoverTimestamp.__proto__ || Object.getPrototypeOf(ChatMouseoverTimestamp)).call(this, 'Chat Mouseover Timestamp', /^\/games/, false, Script.CATEGORIES.CHAT));
}
_createClass(ChatMouseoverTimestamp, [{
key: "run",
value: function run() {
var dom = this.dom,
holodeck = dom.holodeck,
ChatDialogue = dom.ChatDialogue,
$ = dom.$;
function injectMouseover(dom, $, holodeck, ChatDialogue) {
var message_rollover_template = new dom.Element("div", {
id: "message_rollover_template",
"class": "user_rollover_container spritesite",
style: "display: none"
});
var message_rollover = new dom.Element("div", {
"class": "user_rollover spritesite"
});
var message_rollover_inner = new dom.Element("div", {
"class": "user_rollover_inner"
});
var rollover_private_message_holder = new dom.Element("p", {
"class": "rollover_message_private_message_link_message_link_holder"
});
var rollover_private_message_link = new dom.Element("a", {
id: "rollover_message_private_message_link",
"class": "rollover_message_private_message_link",
href: "#"
}).update("Private Message");
rollover_private_message_holder.appendChild(rollover_private_message_link);
var rollover_time_text = new dom.Element("p", {
id: "rollover_time_text"
});
message_rollover_inner.appendChild(rollover_time_text);
message_rollover_inner.appendChild(rollover_private_message_holder);
message_rollover.appendChild(message_rollover_inner);
message_rollover_template.appendChild(message_rollover);
$('chat_tab_pane').appendChild(message_rollover_template);
var MessageRollover = dom.MessageRollover = function (chat_dialogue) {
this.initialize(chat_dialogue);
return this;
};
MessageRollover.prototype = {
initialize: function initialize(chat_dialogue) {
this._active_dialogue = chat_dialogue;
this._holodeck = chat_dialogue._holodeck;
this._rollover_template_node = $('message_rollover_template');
this._private_message_node = $('rollover_message_private_message_link');
this._time_node = $('rollover_time_text');
this._private_message_observer = function () {};
if (this._rollover_template_node) {
var rollover = this;
this._rollover_template_node.observe('mouseover', function (event) {
rollover.stopHide();
dom.Event.stop(event);
});
this._rollover_template_node.observe('mouseout', function (event) {
rollover.beginHide();
dom.Event.stop(event);
});
}
},
show: function show(time, user, event) {
if (this._hideTimer) clearTimeout(this._hideTimer);
this.updatePrivateMessageLink(user);
this.updateTimeText(time);
this.setRolloverPosition(event);
this._rollover_template_node.show();
},
setRolloverPosition: function setRolloverPosition(event) {
var messagenode = event.target;
var current_scroll_top = this._active_dialogue._message_window_node.scrollTop;
var current_message_top = messagenode.positionedOffset()[1];
// nudge the user rollover up a little
current_message_top = current_message_top - 9;
var new_top_val = current_message_top;
if (current_scroll_top < current_message_top) {
new_top_val = current_message_top - current_scroll_top;
}
var top_style_str = new_top_val + 'px';
this._rollover_template_node.setStyle({
top: top_style_str
});
// set left position based on username length
var username_width = messagenode.getWidth();
var new_left_val = 20 + username_width;
var left_style_str = new_left_val + 'px';
this._rollover_template_node.setStyle({
left: left_style_str
});
},
updatePrivateMessageLink: function updatePrivateMessageLink(username) {
var cw = this._holodeck.chatWindow();
// replace observer
this._private_message_node.stopObserving('click');
this._private_message_observer = dom.CapturesToInlineRegistration.decorate(function (event) {
// just put /w in the chat input field
cw.insertPrivateMessagePrefixFor(username);
dom.Event.stop(event);
return false;
});
this._private_message_node.observe('click', this._private_message_observer);
},
updateTimeText: function updateTimeText(time) {
this._time_node.innerHTML = time;
},
beginHide: function beginHide() {
var rollover = this;
if (this._hideTimer) {
clearTimeout(this._hideTimer);
}
this._hideTimer = setTimeout(function () {
rollover.hide();
}, 500);
},
stopHide: function stopHide() {
clearTimeout(this._hideTimer);
},
hide: function hide() {
this._rollover_template_node.hide();
}
};
ChatDialogue.MESSAGE_TEMPLATE.template = '
#{prefix}#{username}: #{message}
';
ChatDialogue.MESSAGE_TEMPLATE.old_evaluate = ChatDialogue.MESSAGE_TEMPLATE.evaluate;
ChatDialogue.MESSAGE_TEMPLATE.evaluate = function (args) {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var time;
if (holodeck._timeFormat == 12) {
time = (hours < 10 ? hours === 0 ? "12" : "0" + hours : hours > 12 ? hours > 21 ? hours - 12 : "0" + (hours - 12) : hours) + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds + (hours > 11 ? " PM" : " AM"); // 12-hour clock
} else {
time = (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds; //24-hour clock
}
args.time = time;
return this.old_evaluate(args);
};
ChatDialogue.prototype.initialize = ChatDialogue.prototype.initialize.wrap(function (old, parent_node, onInputFunction, holodeck, user_manager) {
old(parent_node, onInputFunction, holodeck, user_manager);
this._message_rollover_manager = new MessageRollover(this);
// Establish references to re-used nodes
this._message_window_node = parent_node.down('.chat_message_window');
this._input_node = parent_node.down('.chat_input');
this._messages_to_retain = 200;
this._message_window_node.stopObserving();
this._message_window_node.observe('mouseover', function (event) {
var time = event.target.getAttribute("time"),
user = event.target.getAttribute("username");
if (time) {
holodeck.activeDialogue().showMessageRollover(time, user, event);
dom.Event.stop(event);
}
});
this._message_window_node.observe('mouseout', function (event) {
holodeck.activeDialogue().hideMessageRollover();
dom.Event.stop(event);
});
// Bind event listeners
var dialogue = this,
input_node = this._input_node;
this._input_node.observe('keypress', function (event) {
dialogue.onKeyPress(event);
});
this._input_node.observe('focus', function (event) {
dialogue.clearPrompt();
});
// Trigger mini-profile for clicks on usernames in chat.
this._message_window_node.observe('click', function (event) {
if (event.target) {
var username = event.target.getAttribute('username');
if (username) {
event.stop();
user_manager.showProfile(username);
}
}
});
});
ChatDialogue.prototype.showMessageRollover = function (time, user, event) {
this._message_rollover_manager.show(time, user, event);
};
ChatDialogue.prototype.hideMessageRollover = function () {
this._message_rollover_manager.beginHide();
};
}
if (holodeck && ChatDialogue) {
if (!ChatDialogue.prototype && dom.CDprototype) ChatDialogue.prototype = dom.CDprototype;
if (!holodeck.__mouseover) {
holodeck.__mouseover = true;
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + injectMouseover.toString() + ")(window, $, holodeck, ChatDialogue);";
document.body.appendChild(script);
setTimeout(function () {
document.body.removeChild(script);
}, 100);
holodeck.addChatCommand("timeformat", function (l, n) {
var k = n.match(/^\/\S+\s+(\d+)/),
m = "",
q = l.activeDialogue();
k && (m = k[1]);
if (m == 12 || m == 24) {
l._timeFormat = m;
window.setTimeout(function () {
GM_setValue("kong_timeformat", m);
}, 0);
q.displayMessage("Timeformat", "Set to " + m + "-hour clock (hh:mm:ss" + (m == 12 ? " AM/PM)" : ")"), {
"class": "whisper received_whisper"
}, {
non_user: true
});
} else {
q.displayMessage("Timeformat", "Allowed values: 12 and 24", {
"class": "whisper received_whisper"
}, {
non_user: true
});
}
return false;
});
var timeformat = 12;
if (typeof GM_setValue !== "undefined") {
timeformat = GM_getValue("kong_timeformat", 12) || 12;
} else {
GM_setValue = function GM_setValue() {};
}
holodeck._timeFormat = timeformat;
}
}
}
}]);
return ChatMouseoverTimestamp;
}(HolodeckScript);
//= require ../holodeckScript.js
var ChatResizer = function (_HolodeckScript6) {
_inherits(ChatResizer, _HolodeckScript6);
function ChatResizer() {
_classCallCheck(this, ChatResizer);
return _possibleConstructorReturn(this, (ChatResizer.__proto__ || Object.getPrototypeOf(ChatResizer)).call(this, 'Chat Resizer', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(ChatResizer, [{
key: "run",
value: function run() {
var _this10 = this;
var dom = this.dom;
dom.defaultWidth = 500;
dom.defaultHeight = 600;
dom.spaceLeft = 200;
dom.center = true;
dom.userListHeight = 100;
if (!$('maingamecontent')) return;
var initialOffsetTop = $('maingamecontent').offsetTop + $('chat_tab_pane').offsetTop;
var initialOffsetLeft = $('maingamecontent').offsetLeft + $('chat_tab_pane').offsetLeft;
var minimumHeight = parseInt($("game").style.height, 10) - parseInt($('main_tab_set').clientHeight, 10) - 16;
var minimumWidth = 300;
if (dom.holodeck) {
var holodeck = dom.holodeck;
holodeck.addChatCommand("size", function (l, n) {
var m = n.match(/^\/\S+\s+(\S+)/);
var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/);
if (m && m[1] == "reset") {
l.activeDialogue().kongBotMessage("Resetting size for this game to defaults.");
window.setTimeout(function () {
GM_deleteValue("kong_resize_" + location.pathname);
}, 0);
this.setWidth(window._defaultChatWidth);
this.setHeight(window._defaultChatHeight, window._defaultUserlistHeight, window._currentGameCentered);
return false;
} else if (m && m[1] == "show") {
l.activeDialogue().kongBotMessage("Current chat size: width: " + window._currentChatWidth + "px, height: " + window._currentChatHeight + "px, userlist-height: " + window._currentChatUserlistHeight + "px.");
return false;
} else if (!o) {
l.activeDialogue().kongBotMessage("Please specify a width and a height: /size width height. Example: /size 500 500");
return false;
}
var width = parseInt(o[1], 10);
var height = parseInt(o[2], 10);
var listHeight = parseInt(o[3] || 100, 10);
var gameHeight = parseInt($('game').style.height, 10);
if (width < 300) {
l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
width = 300;
}
if (height < gameHeight) {
l.activeDialogue().kongBotMessage("Minimum height is the game's height. Setting height to " + gameHeight + "px.");
height = gameHeight;
}
if (listHeight > height - 200) {
l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
listHeight = 100;
}
window.setTimeout(function () {
GM_setValue("kong_resize_" + location.pathname, width + "/" + height + "/" + listHeight);
}, 0);
l.activeDialogue().kongBotMessage("Resizing chat to " + width + "px/" + height + "px/" + listHeight + "px");
this.setWidth(width);
this.setHeight(height, listHeight, window._currentGameCentered);
return false;
});
holodeck.addChatCommand("defaultsize", function (l, n) {
var m = n.match(/^\/\S+\s+(\S+)/);
var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/);
if (m && m[1] == "reset") {
l.activeDialogue().kongBotMessage("Resetting default size to 500/600/100");
window.setTimeout(function () {
GM_deleteValue("kong_resize_default");
}, 0);
return false;
} else if (m && m[1] == "show") {
l.activeDialogue().kongBotMessage("Current chat size: width: " + window._defaultChatWidth + "px, height: " + window._defaultChatHeight + "px, userlist-height: " + window._defaultUserlistHeight + "px.");
return false;
} else if (!o) {
l.activeDialogue().kongBotMessage("Syntax /defaultsize width height userlist-height. userlist-height is optional. Example: /defaultsize 500 500 100");
}
var width = parseInt(o[1], 10);
var height = parseInt(o[2], 10);
var listHeight = parseInt(o[3] || 100, 10);
if (width < 300) {
l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
width = 300;
}
if (listHeight > height) {
l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
listHeight = 100;
}
window.setTimeout(function () {
GM_setValue("kong_resize_default", width + "/" + height + "/" + listHeight);
}, 0);
l.activeDialogue().kongBotMessage("Set default values to width: " + width + "px, height: " + height + "px, userlist-height: " + listHeight + "px.");
return false;
});
holodeck.addChatCommand("centergame", function (l, n) {
var center = !window._currentGameCentered;
if (center) {
l.activeDialogue().kongBotMessage("Now centering the game");
} else {
l.activeDialogue().kongBotMessage("Now aligning the game to the chat's bottom");
}
window.setTimeout(function () {
GM_setValue("kong_resize_center", center ? 1 : 0);
}, 0);
_this10.centerGame(center);
return false;
});
holodeck.addChatCommand("draggable", function (l, n) {
var chatwindow = document.getElementById("chat_container");
//chatwindow.style.overflow = "auto";
chatwindow.style.resize = "both";
chatwindow.onresize = function () {
var chatcontainer = document.getElementById("chat_window");
chatcontainer.style.width = chatwindow.style.width;
chatcontainer.style.height = chatwindow.style.height;
l.activeDialogue().kongBotMessage("Chat window is now resizeable");
};
return false;
});
}
var getString = "",
centerVal = -1,
defaults = "";
getString = GM_getValue("kong_resize_" + location.pathname, "");
centerVal = GM_getValue("kong_resize_center", -1);
defaults = GM_getValue("kong_resize_default", "");
var splitArr = void 0;
if (defaults) {
splitArr = defaults.split("/");
dom.defaultWidth = parseInt(splitArr[0], 10) || dom.defaultWidth;
dom.defaultHeight = parseInt(splitArr[1], 10) || dom.defaultHeight;
dom.userListHeight = parseInt(splitArr[2], 10) || dom.userListHeight;
}
window._defaultChatWidth = dom.defaultWidth;
window._defaultChatHeight = dom.defaultHeight;
window._defaultUserlistHeight = dom.userListHeight;
var x = dom.defaultWidth,
y = dom.defaultHeight,
l = dom.userListHeight,
cg = dom.center,
override = false;
if (centerVal != -1) {
cg = centerVal == 1;
}
if (getString) {
splitArr = getString.split("/");
x = parseInt(splitArr[0], 10) || dom.defaultWidth;
y = parseInt(splitArr[1], 10) || dom.defaultHeight;
l = parseInt(splitArr[2], 10) || dom.userListHeight;
override = true;
}
var gameWidth = parseInt($('game').style.width, 10);
var gameHeight = parseInt($('game').style.height, 10);
if (x > minimumWidth) {
if (override || gameWidth + x < screen.width - dom.spaceLeft) {
// enough place to resize to specified width
this.setWidth(x);
} else {
// resize as far as possible
var chatWidth = screen.width - gameWidth - dom.spaceLeft;
if (chatWidth > minimumWidth) this.setWidth(chatWidth);
}
}
if (y > minimumHeight && y > gameHeight) {
this.setHeight(y, l, cg);
} else {
this.setHeight(gameHeight, l, cg);
}
}
}, {
key: "centerGame",
value: function centerGame(center) {
window._currentGameCentered = center;
if (center) {
var gameHeight = parseInt($('game').style.height, 10);
var mainHeight = parseInt($("maingame").style.height, 10);
$('game').style.top = (mainHeight - gameHeight) / 2 + "px";
$('game').style.position = "relative";
} else {
$('game').style.bottom = "0px";
$('game').style.top = "";
$('game').style.position = "absolute";
}
}
}, {
key: "setHeight",
value: function setHeight(height, userListHeight, center) {
if (!userListHeight) userListHeight = 100;
window._currentChatHeight = height;
window._currentChatUserlistHeight = userListHeight;
var quicklinksHeight = $('quicklinks') ? $('quicklinks').parentNode.clientHeight : 26;
var maintabHeight = $('main_tab_set').clientHeight;
var tabPaneHeight = height - 16;
var mainHeight = height + quicklinksHeight + maintabHeight;
var gameHeight = parseInt($('game').style.height, 10);
$("maingame").style.height = mainHeight + "px";
$("maingamecontent").style.height = mainHeight + "px";
$("flashframecontent").style.height = mainHeight + "px";
$("chat_container").style.height = height + maintabHeight + "px";
$("user_mini_profile_container").style.height = height - 65 + "px";
$("user_mini_profile").style.height = height - 65 + "px";
var messageWindows = $$(".chat_message_window");
for (var i = 0; i < messageWindows.length; i++) {
messageWindows[i].style.height = tabPaneHeight - userListHeight - 93 - 14 + "px"; // 93 = roomname, users in room etc., 14 = charcount
}
var usersInRoom = $$(".users_in_room");
for (i = 0; i < usersInRoom.length; i++) {
usersInRoom[i].style.height = userListHeight + "px";
}
var roomsList = $$(".rooms_list");
for (i = 0; i < roomsList.length; i++) {
roomsList[i].style.height = height - 79 + "px";
}
var z = $("kong_game_ui").childNodes;
for (i = 0; i < z.length; i++) {
if (z[i].nodeName == "DIV") {
z[i].style.height = tabPaneHeight + "px";
}
}
if (center != -1 && center !== undefined) this.centerGame(center);
}
}, {
key: "setWidth",
value: function setWidth(width) {
window._currentChatWidth = width;
var gameWidth = parseInt($("game").style.width, 10);
$("maingame").style.width = gameWidth + 3 + width + "px";
$("maingamecontent").style.width = gameWidth + 3 + width + "px";
$("flashframecontent").style.width = gameWidth + 3 + width + "px";
$("chat_container").style.width = width + "px";
$('chat_window_spinner').style.right = width / 2 - 38 + "px";
if ($('high_scores_spinner')) $('high_scores_spinner').style.right = width / 2 - 38 + "px";
var ui = $("kong_game_ui");
var z = ui.childNodes;
for (var i = 0; i < z.length; i++) {
if (z[i].tagName == "DIV") z[i].style.width = width - 17 + "px";
}
this.$A(ui.querySelectorAll("textarea.chat_input")).forEach(function (el) {
el.style.width = width - 21 + "px";
});
}
}, {
key: "$A",
value: function $A(c) {
return [].slice.call(c);
}
}]);
return ChatResizer;
}(HolodeckScript);
//=require ../holodeckScript.js
var ChatTimestamp = function (_HolodeckScript7) {
_inherits(ChatTimestamp, _HolodeckScript7);
function ChatTimestamp() {
_classCallCheck(this, ChatTimestamp);
return _possibleConstructorReturn(this, (ChatTimestamp.__proto__ || Object.getPrototypeOf(ChatTimestamp)).call(this, 'Chat Timestamp', /^\/games/, true, Script.CATEGORIES.CHAT));
}
_createClass(ChatTimestamp, [{
key: "run",
value: function run() {
var dom = this.dom,
holodeck = dom.holodeck,
ChatDialogue = dom.ChatDialogue;
if (holodeck && ChatDialogue) {
ChatDialogue.prototype = dom.CDprototype || dom.ChatDialogue.prototype;
if (!holodeck.__timestamp) {
holodeck.__timestamp = true;
holodeck.addChatCommand("timeformat", function (l, n) {
var k = n.match(/^\/\S+\s+(\d+)/),
m = "",
q = l.activeDialogue();
k && (m = k[1]);
if (m == 12 || m == 24) {
l._timeFormat = m;
window.setTimeout(function () {
GM_setValue("kong_timeformat", m);
}, 0);
q.displayMessage("Timeformat", "Set to " + m + "-hour clock (hh:mm:ss" + (m == 12 ? " AM/PM)" : ")"), {
"class": "whisper received_whisper"
}, {
non_user: true
});
} else {
q.displayMessage("Timeformat", "Allowed values: 12 and 24", {
"class": "whisper received_whisper"
}, {
non_user: true
});
}
return false;
});
holodeck.addChatCommand("tscolor", function (l, n) {
var k = n.match(/^\/\S+\s+([0-9a-f]{6})/i),
z = "";
k && (z = "#" + k[1]);
if (z) {
updateColor(z);
window.setTimeout(function () {
GM_setValue("kong_timestampcolor", z);
}, 0);
l.activeDialogue().displayMessage("Timestamp", "Set font-color to " + z, {
"class": "whisper received_whisper"
}, {
non_user: true
});
} else {
l.activeDialogue().displayMessage("Timestamp", "No valid color! Format is /tscolor ###### (# = hex character)", {
"class": "whisper received_whisper"
}, {
non_user: true
});
}
return false;
});
holodeck.addChatCommand("toggleseconds", function (l, n) {
if (l._showSeconds) {
l._showSeconds = 0;
l.activeDialogue().displayMessage("Timestamp", "Now hiding seconds", {
"class": "whisper received_whisper"
}, {
non_user: true
});
} else {
l._showSeconds = 1;
l.activeDialogue().displayMessage("Timestamp", "Now showing seconds", {
"class": "whisper received_whisper"
}, {
non_user: true
});
}
window.setTimeout(function () {
GM_setValue("kong_timeshowseconds", l._showSeconds);
}, 0);
return false;
});
var timeformat = 12,
fontcolor = "#999999",
seconds = 0;
timeformat = GM_getValue("kong_timeformat", 12) || 12;
fontcolor = GM_getValue("kong_timestampcolor", "#999999") || "#999999";
seconds = GM_getValue("kong_timeshowseconds", 0) || 0;
holodeck._timeFormat = timeformat;
holodeck._showSeconds = seconds;
var updateColor = function (c) {
var style = document.createElement("style");
style.setAttribute("type", "text/css");
function _updateColor(color) {
style.innerHTML = "span.inline_timestamp { color: " + color + " !important; }";
}
_updateColor(c);
document.body.appendChild(style);
return _updateColor;
}(fontcolor);
ChatDialogue.MESSAGE_TEMPLATE.template = '