Kongregate One

Kongregate One - One script to rule them all. Everything here.

  1. // ==UserScript==
  2. // @name Kongregate One
  3. // @namespace profusiongames.com
  4. // @author UnknownGuardian, AlphaOverall
  5. // @version 1.2.5
  6. // @date 04/19/2013
  7. // @include http://www.kongregate.com/games/*/*
  8. // @include http://www.kongregate.com/accounts/*
  9. // @description Kongregate One - One script to rule them all. Everything here.
  10. // ==/UserScript==
  11.  
  12.  
  13.  
  14.  
  15. // Small Additions by AlphaOverall (http://www.kongregate.com/accounts/AlphaOverall) 2015
  16. // Written by UnknownGuardian (http://www.kongregate.com/accounts/UnknownGuardian) 2012 - 2013
  17. // Written by Ventero (http://www.kongregate.com/accounts/Ventero) 2009 - 2013
  18. // Licensed under MIT/X11 license
  19. // Copyright (c) Ventero, UnknownGuardian
  20. // http://www.opensource.org/licenses/mit-license.php
  21. // All terms, licenses, credits, etc from scripts used here (documented in comments) apply
  22.  
  23. // This portion of attribution only applies to code written or modified based on MrSpontaneous' implementation
  24. // Written by MrSpontaneous (http://www.kongregate.com/accounts/MrSpontaneous) 01/03/2010
  25.  
  26. //This portion of attribution only applies to code written or modified based on skyboy's implementation.
  27. /**
  28. *
  29. * Assorted Userscripts by skyboy.
  30. * Visit http://github.com/skyboy for documentation, updates
  31. * and more free code.
  32. *
  33. *
  34. * Copyright (c) 2010, skyboy
  35. * All rights reserved.
  36. *
  37. * Permission is hereby granted, free of charge, to any person
  38. * obtaining a copy of this software and associated documentation
  39. * files (the "Software"), to deal in the Software with
  40. * restriction, with limitation the rights to use, copy, modify,
  41. * merge, publish, distribute, sublicense copies of the Software,
  42. * and to permit persons to whom the Software is furnished to do so,
  43. * subject to the following conditions and limitations:
  44. *
  45. * ^ Attribution will be given to:
  46. * skyboy, http://www.kongregate.com/accounts/skyboy;
  47. * http://github.com/skyboy; http://skybov.deviantart.com
  48. *
  49. * ^ Redistributions of source code must retain the above copyright notice,
  50. * this list of conditions and the following disclaimer in all copies or
  51. * substantial portions of the Software.
  52. *
  53. * ^ Redistributions of modified source code must be marked as such, with
  54. * the modifications marked and ducumented and the modifer's name clearly
  55. * listed as having modified the source code.
  56. *
  57. * ^ Redistributions of source code may not add to, subtract from, or in
  58. * any other way modify the above copyright notice, this list of conditions,
  59. * or the following disclaimer for any reason.
  60. *
  61. * ^ Redistributions in binary form must reproduce the above copyright
  62. * notice, this list of conditions and the following disclaimer in the
  63. * documentation and/or other materials provided with the distribution.
  64. *
  65. * THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  66. * IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
  67. * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  68. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  69. * OR COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DIRECT,
  70. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  71. * OR OTHER LIABILITY,(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  72. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  73. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  74. * WHETHER AN ACTION OF IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  75. * NEGLIGENCE OR OTHERWISE) ARISING FROM, OUT OF, IN CONNECTION OR
  76. * IN ANY OTHER WAY OUT OF THE USE OF OR OTHER DEALINGS WITH THIS
  77. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  78. */
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. function main()
  86. {
  87. console.log("KongOne Script running.");
  88. var dom = (typeof unsafeWindow === "undefined"?window:unsafeWindow);
  89. dom.oneScriptVersion = "1.101";
  90.  
  91.  
  92.  
  93. init();
  94. function init()
  95. {
  96. if(typeof GM_setValue === 'undefined'){
  97. window.GM_setValue = function(a,b){localStorage.setItem(a,b)}
  98. window.GM_getValue = function(a,b){var r=localStorage.getItem(a);return (r==null?b:r)}
  99. window.GM_deleteValue = function(a){localStorage.removeItem(a)}
  100. }
  101.  
  102. var url = dom.location.href;
  103. url = url.substr(url.indexOf(".com/") + ".com/".length);
  104.  
  105. if(url.indexOf("/") != -1)
  106. oneDirectory = url.substring(0,url.indexOf("/"));
  107. else
  108. oneDirectory = url;
  109.  
  110. oneDirectory = oneDirectory.split("?")[0];
  111.  
  112. dom.holodeckCheckCounter = 0
  113. dom.holodeckInterval = dom.setInterval(checkIfHolodeckLoaded, 100)
  114. dom.oneScriptsInitialize = [];
  115.  
  116. useScript("this", "accounts", init_showScriptOptions, false, true);
  117. useScript("Chat Timestamp", "games", init_chatTimestamp, true, true);
  118. useScript("Chat PM Notifier", "games", init_PMNotifier, true, true);
  119. useScript("Chat Line Highlighting", "games", init_chatLineHighlighting, true, true);
  120. useScript("Chat Reply-command", "games", init_replyCommand, true, true);
  121. //useScript("Chat Reply-command (hotkey)", "games", init_replyHotkey, true, true);
  122. useScript("Chat Username-completion", "games", init_usernameCompletion, true, true);
  123. useScript("Chat Mouseover Timestamp", "games", init_chatMouseoverTimestamp, true, false);
  124. useScript("Chat Afk Command", "games", init_afk, true, true);
  125. useScript("Chat Character-limit", "games", init_chatCharacterLimit, true, true);
  126. useScript("Chat KongreLink", "games", init_kongreLink, true, true);
  127. //useScript("Chat Images", "games", init_chatImage, true, true);
  128. useScript("Chat Resizer", "games", init_chatResizer, true, true);
  129. useScript("Kongquer", "games", init_kongquer, true, true);
  130.  
  131. addScripts(false);
  132. }
  133.  
  134. function useScript(name, page, callback, requiresHolodeck, defaultEnabled)
  135. {
  136. dom.oneScriptsInitialize.push({name:name, page:page, callback:callback, requiresHolodeck:requiresHolodeck, added:false, defaultEnabled:defaultEnabled});
  137. }
  138.  
  139. function checkIfHolodeckLoaded()
  140. {
  141. holodeckCheckCounter++;
  142. console.log("[KongOne] Checking if holodeck loaded");
  143. if(typeof holodeck === 'undefined')
  144. {
  145.  
  146. }
  147. else if(holodeck.ready)
  148. {
  149. dom.clearInterval(dom.holodeckInterval);
  150. console.log("[KongOne] Holodeck loaded");
  151. addScripts(true);
  152. }
  153.  
  154. if(holodeckCheckCounter > 40)
  155. {
  156. dom.clearInterval(dom.holodeckInterval);
  157. console.log("[KongOne] Holodeck failed to load");
  158. }
  159. }
  160.  
  161. function addScripts(onlyHolodeckRequired)
  162. {
  163. console.log("[KongOne] Adding Scripts with holodeckRequired = " + onlyHolodeckRequired);
  164. dom.oneScriptsInitialize.each(function(item)
  165. {
  166. if(!item.defaultEnabled && GM_getValue("onescript-" + item.name, "null") == "null")//never been touched before
  167. GM_setValue("onescript-" + item.name, "false");
  168.  
  169. if(item.requiresHolodeck == onlyHolodeckRequired && !item.added)
  170. {
  171. if(item.page == oneDirectory && GM_getValue("onescript-" + item.name, "true") == "true")
  172. {
  173. console.log("[KongOne] Adding Script: " + item.name);
  174. item.callback();
  175. item.added = true;
  176. }
  177. }
  178. })
  179. console.log("[KongOne] Added Scripts");
  180. }
  181.  
  182. //============
  183. // This script's UI
  184. //============
  185.  
  186. function init_showScriptOptions()
  187. {
  188. console.log("init shot script")
  189. var div = new Element("div", {"style":"background-color:#FFF;padding: 8px;"}).update("<h2>Scripts</h2>Enable - Script Name<p></p>");
  190. $("profile_aside").down().insert(div);
  191. dom.oneScriptsInitialize.each(function(item)
  192. {
  193. if(item.name == "this")
  194. return true; //aka, continue for each loops
  195.  
  196. var span = new Element("span", {"style":"margin-top: 5px !important;display: block;"});
  197. div.insert(span);
  198.  
  199. var checkbox = new Element("input", {"type":"checkbox", "id":"onescript-" + item.name, "style":"margin-top:2px;vertical-align:top;margin-right:8px;"});
  200. var label = new Element("label", {"class":"pls"})
  201. checkbox.checked = GM_getValue(checkbox.id,item.defaultEnabled?"true":"false") == "true";
  202. label.update(item.name);
  203.  
  204.  
  205.  
  206. span.insert(checkbox);
  207. span.insert(label);
  208.  
  209.  
  210. checkbox.onchange = toggleScript;
  211. });
  212.  
  213. }
  214.  
  215. function toggleScript()
  216. {
  217. console.log("[KongOne] Toggled script");
  218. GM_setValue(this.id,this.checked);
  219. }
  220.  
  221.  
  222. //============
  223. // Chat Timestamps
  224. // http://userscripts.org/scripts/review/55571
  225. //============
  226.  
  227. function init_chatTimestamp()
  228. {
  229. var holodeck = dom.holodeck,
  230. ChatDialogue = dom.ChatDialogue;
  231. console.log(holodeck, " h", ChatDialogue, " c");
  232. if(holodeck && ChatDialogue)
  233. {
  234.  
  235. ChatDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  236.  
  237. if(!holodeck.__timestamp){
  238. holodeck.__timestamp = true;
  239.  
  240. holodeck.addChatCommand("timeformat", function(l,n){
  241. var k = n.match(/^\/\S+\s+(\d+)/),
  242. m = "",
  243. q = l.activeDialogue();
  244. k && (m=k[1]);
  245. if(m==12 || m==24){
  246. l._timeFormat = m;
  247. window.setTimeout(function(){GM_setValue("kong_timeformat", m);}, 0);
  248. q.displayMessage("Timeformat", "Set to "+m+"-hour clock (hh:mm:ss"+(m==12?" AM/PM)":")"), { "class": "whisper received_whisper"}, {non_user: true});
  249. } else {
  250. q.displayMessage("Timeformat", "Allowed values: 12 and 24", { "class": "whisper received_whisper"}, {non_user: true});
  251. }
  252. return false;
  253. });
  254.  
  255. holodeck.addChatCommand("tscolor", function(l,n){
  256. var k = n.match(/^\/\S+\s+([0-9a-f]{6})/i),
  257. z = "";
  258. k&&(z = "#"+k[1]);
  259. if (z){
  260. updateColor(z);
  261. window.setTimeout(function(){GM_setValue("kong_timestampcolor", z);}, 0);
  262. l.activeDialogue().displayMessage("Timestamp", "Set font-color to "+z, { "class": "whisper received_whisper"}, {non_user: true});
  263. } else {
  264. l.activeDialogue().displayMessage("Timestamp", "No valid color! Format is /tscolor ###### (# = hex character)", {"class":"whisper received_whisper"}, {non_user: true})
  265. }
  266. return false;
  267. });
  268.  
  269. holodeck.addChatCommand("toggleseconds", function(l,n){
  270. if(l._showSeconds){
  271. l._showSeconds = 0;
  272. l.activeDialogue().displayMessage("Timestamp", "Now hiding seconds", { "class": "whisper received_whisper"}, {non_user: true});
  273. }else{
  274. l._showSeconds = 1;
  275. l.activeDialogue().displayMessage("Timestamp", "Now showing seconds", { "class": "whisper received_whisper"}, {non_user: true})
  276. }
  277. window.setTimeout(function(){GM_setValue("kong_timeshowseconds", l._showSeconds);}, 0);
  278. return false;
  279. });
  280.  
  281. var timeformat = 12, fontcolor = "#999999", seconds = 0;
  282. if(typeof GM_setValue !== "function"){
  283. GM_getValue = GM_setValue = function(){};
  284. } else {
  285. timeformat = GM_getValue("kong_timeformat", 12)||12;
  286. fontcolor = GM_getValue("kong_timestampcolor", "#999999")||"#999999";
  287. seconds = GM_getValue("kong_timeshowseconds", 0)||0;
  288. }
  289. holodeck._timeFormat = timeformat;
  290. holodeck._showSeconds = seconds;
  291.  
  292. var updateColor = (function(c){
  293. var style = document.createElement("style");
  294. style.setAttribute("type", "text/css");
  295. function _updateColor(color){
  296. style.innerHTML = "span.inline_timestamp { color: " + color + " !important; }";
  297. };
  298.  
  299. _updateColor(c);
  300. document.body.appendChild(style);
  301. return _updateColor;
  302. })(fontcolor);
  303. ChatDialogue.MESSAGE_TEMPLATE.template = '<p class="#{classNames}"><span style="float: left;" class="inline_timestamp">[#{time}]&nbsp;</span><span style="text-decoration: underline;" username="#{username}" class="username #{userClassNames}">#{prefix}#{username}</span><span class="separator">: </span><span class="message">#{message}</span><span class="clear"></span></p>'
  304. ChatDialogue.MESSAGE_TEMPLATE.old_evaluate_inline = ChatDialogue.MESSAGE_TEMPLATE.evaluate;
  305. ChatDialogue.MESSAGE_TEMPLATE.evaluate = function(args){
  306. var date = new Date();
  307. var hours = date.getHours();
  308. var minutes = date.getMinutes();
  309. var seconds = date.getSeconds();
  310. var time;
  311. if (holodeck._timeFormat == 12){
  312. time = (hours<10?(hours==0?"12":"0"+hours):(hours>12?(hours>21?hours-12:"0"+(hours-12)):hours))+":"+(minutes<10?"0":"")+minutes+(holodeck._showSeconds?(":"+(seconds<10?"0":"")+seconds):"")+(hours>11?" PM":" AM");
  313. } else {
  314. time = (hours<10?"0":"")+hours+":"+(minutes<10?"0":"")+minutes+(holodeck._showSeconds?(":"+(seconds<10?"0":"")+seconds):"");
  315. }
  316. args.time = time;
  317. return this.old_evaluate_inline(args);
  318. };
  319. }
  320. }
  321. }
  322.  
  323.  
  324. //============
  325. // Chat Line Highlighting
  326. // http://userscripts-mirror.org/scripts/review/49868
  327. //============
  328.  
  329. function init_chatLineHighlighting()
  330. {
  331.  
  332. var holodeck = dom.holodeck,
  333. CDialogue = dom.ChatDialogue,
  334. CRoom = dom.ChatRoom,
  335. CWindow = dom.ChatWindow;
  336.  
  337. if(CRoom && CDialogue){
  338.  
  339. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  340. CRoom.prototype = dom.CRprototype||dom.ChatRoom.prototype;
  341. CWindow.prototype = dom.CWprototype||dom.ChatWindow.prototype;
  342. if(!CDialogue.prototype.searchWord){
  343.  
  344. if(!String.prototype.trim){
  345. String.prototype.trim = function(){
  346. return this.replace(/^\s+/, "").replace(/\s+$/, "");
  347. }
  348. }
  349.  
  350. CDialogue.prototype.searchWord = function(a, b){
  351. for (var i=0;i<b.length;i++){
  352. var r = b[i].replace(/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g, '\\$1'),
  353. reg = new RegExp("\\b"+r+"\\b");
  354. if (reg.test(a)) return true;
  355. }
  356. return false;
  357. };
  358.  
  359. CDialogue.prototype.searchUser = function(a){
  360. return this.searchWord(a, this._holodeck._hluser);
  361. };
  362.  
  363. CDialogue.prototype.searchText = function(a){
  364. var l = this._holodeck,
  365. z = l._highlighting.concat([l._username.toLowerCase()]);
  366. return this.searchWord(a, z);
  367. }
  368.  
  369. CWindow.prototype.hlFriend = function(a){
  370. return this._holodeck._hl_friends && this.isFriend(a);
  371. }
  372.  
  373. CWindow.prototype.hlMod = function(a){
  374. if(!this._holodeck._hl_mods) return;
  375.  
  376. return this._rooms.any(function(roomArr){
  377. var room = roomArr[1];
  378. var user = room.user(a);
  379. return user && room.canUserModerate(user);
  380. });
  381. }
  382.  
  383. CWindow.prototype.friendOrMod = function(a){
  384. if(a.toLowerCase() == this._holodeck._username.toLowerCase()) return "";
  385.  
  386. var colors = [];
  387. if(this.hlMod(a)) colors.push(" hlmod");
  388. if(this.hlFriend(a)) colors.push(" hlfriend");
  389. if(colors.length > 1)
  390. return colors[this._holodeck._hl_priority]
  391.  
  392.  
  393. return (colors[0] || "");
  394. }
  395.  
  396. CDialogue.prototype.displayUnsanitizedMessageOldHighlight = CDialogue.prototype.displayUnsanitizedMessage;
  397.  
  398. CDialogue.prototype.displayUnsanitizedMessage = function(user, msg, attributes, options){
  399. if(!attributes) attributes = {};
  400. var classes = attributes["class"] || "";
  401. var isWhisper = (classes.indexOf("whisper") >= 0);
  402.  
  403. if(!(options && options["private"]))
  404. classes += this._user_manager.friendOrMod(user.toLowerCase());
  405.  
  406. if(!isWhisper &&
  407. !this._user_manager.isMuted(user.toLowerCase()) &&
  408. (this.searchUser(user.toLowerCase()) ||
  409. this.searchText(msg.toLowerCase()))) {
  410. classes += " highlight";
  411. if(typeof this.new_private_message === "function") {
  412. var oldChime = holodeck._pm_chime;
  413. holodeck._pm_chime = holodeck._hl_chime;
  414. this.new_private_message();
  415. holodeck._pm_chime = oldChime;
  416. }
  417. }
  418.  
  419. attributes["class"] = classes;
  420.  
  421. this.displayUnsanitizedMessageOldHighlight(user, msg, attributes, options);
  422. }
  423.  
  424. holodeck.addChatCommand("highlight", function(l,n){
  425. var k = n.match(/^\/\S+\s+(.+)/),
  426. z = "";
  427. k&&(z = k[1])
  428. if(z){
  429. z = z.replace(/\s+/g, ' ').trim();
  430. window.setTimeout(function(){GM_setValue("kong_highlighting", z.toLowerCase());}, 0);
  431. l.activeDialogue().kongBotMessage("Now highlighting: "+z+" "+l._username);
  432. l._highlighting = z.toLowerCase().split(' ');
  433. }
  434. return false;
  435. });
  436.  
  437. holodeck.addChatCommand("hluser", function(l,n){
  438. var k = n.match(/^\/\S+\s+(.+)/),
  439. z = "";
  440. k&&(z = k[1])
  441. if(z){
  442. z = z.replace(/\s+/g, ' ').trim();
  443. window.setTimeout(function(){GM_setValue("kong_highlightuser", z.toLowerCase());}, 0);
  444. l.activeDialogue().kongBotMessage("Now highlighting user(s): "+z);
  445. l._hluser = z.toLowerCase().split(' ');
  446. }
  447. return false;
  448. });
  449.  
  450. function generateCallback(name, stop, start){
  451. return function(l, n){
  452. if(l["_hl_" + name]){
  453. l["_hl_" + name] = 0;
  454. l.activeDialogue().kongBotMessage(stop || "Stopped highlighting messages by " + name);
  455. }else{
  456. l["_hl_" + name] = 1;
  457. l.activeDialogue().kongBotMessage(start || "Now highlighting messages by " + name);
  458. }
  459. window.setTimeout(function(){GM_setValue("kong_highlight"+name, l["_hl_" + name]);}, 0);
  460. return false;
  461. }
  462. }
  463.  
  464. holodeck.addChatCommand("hlmods", generateCallback("mods"));
  465. holodeck.addChatCommand("hlfriends", generateCallback("friends"));
  466. holodeck.addChatCommand("hlchime", generateCallback("chime", "Stopped playing the chime for highlighted messages",
  467. "Now playing the chime for highlighted messages"));
  468. holodeck.addChatCommand("hlpriority", generateCallback("priority", "Now prioritizing mods over friends", "Now prioritizing friends over mods"));
  469.  
  470. function generateColorCallback(selector, rule, name, text, max){
  471. if(!max) max = 1;
  472. return function(l, n){
  473. var k = n.match(/^\/\S+\s+#?([0-9a-f]{6})/i),
  474. z = "",
  475. count = 0;
  476. if(k) z = "#" + k[1];
  477. if(z){
  478. for(var i = 0; i < sheet.cssRules.length; i++){
  479. if(sheet.cssRules[i].selectorText.indexOf(selector) == 0){
  480. sheet.cssRules[i].style.setProperty(rule, z, "important");
  481. if(++count == max){
  482. window.setTimeout(function(){GM_setValue("kong_" + name, z);}, 0);
  483. l.activeDialogue().kongBotMessage("New " + (text||name) + ": " + z);
  484. return false;
  485. }
  486. }
  487. }
  488. } else {
  489. l.activeDialogue().kongBotMessage("No valid color! Format is /" + name + " XXXXXX (X = hex character)");
  490. }
  491. return false;
  492. }
  493. };
  494.  
  495. holodeck.addChatCommand(
  496. "whispercolor",
  497. generateColorCallback("#kong_game_ui .chat_message_window .whisper",
  498. "background-color",
  499. "whispercolor")
  500. )
  501.  
  502. holodeck.addChatCommand(
  503. "friendcolor",
  504. generateColorCallback("#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username",
  505. "color",
  506. "friendcolor")
  507. )
  508. holodeck.addChatCommand(
  509. "hlcolor",
  510. generateColorCallback("#kong_game_ui .chat_message_window .highlight",
  511. "background-color",
  512. "hlcolor",
  513. "highlighting-color",
  514. 2)
  515. )
  516. holodeck.addChatCommand(
  517. "modcolor",
  518. generateColorCallback("#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username",
  519. "color",
  520. "modcolor")
  521. )
  522.  
  523. holodeck.addChatCommand("hllist", function(l, n) {
  524. var diag = l.activeDialogue();
  525. function botMessage(msg) {
  526. diag.displayUnsanitizedMessage("Kong Bot", msg, {"class":"whisper received_whisper"}, {non_user: true});
  527. }
  528.  
  529. botMessage("Current highlighting settings:");
  530.  
  531. if(holodeck._hluser.length > 0) {
  532. botMessage('Users:');
  533. botMessage('Users: ' + holodeck._hluser.map(function(user) {
  534. return ['<a href="#" onclick="holodeck.showMiniProfile(\'', user,
  535. '\'); return false;">', user, '</a>'].join("");
  536. }).join(" "));
  537. } else {
  538. botMessage("No users highlighted");
  539. }
  540.  
  541. if(holodeck._highlighting.length > 0) {
  542. botMessage('Words: ' + holodeck._highlighting.join(" "));
  543. } else {
  544. botMessage("No words highlighted");
  545. }
  546.  
  547. botMessage('Highlight color: <span style="color: ' + color + '">' +
  548. color + '</span>');
  549. botMessage('Whisper color: <span style="color: ' + wcolor + '">' +
  550. wcolor + '</span>');
  551.  
  552. botMessage("Highlighting friends: " +
  553. (holodeck._hl_friends ? "Yes" : "No") +
  554. ' (color: <span style="color: ' + fcolor + '">' +
  555. fcolor + '</span>)');
  556. botMessage("Highlighting mods: " +
  557. (holodeck._hl_mods ? "Yes" : "No") +
  558. ' (color: <span style="color: ' + mcolor + '">' +
  559. mcolor + '</span>)');
  560.  
  561. botMessage("Highlight priority: " +
  562. (holodeck._hl_priority ? "Friends over mods" : "Mods over friends"));
  563. botMessage("Playing chime: " +
  564. (holodeck._hl_chime ?
  565. (typeof holodeck._pm_chime !== "undefined" ? "Yes" :
  566. 'No, <a href="http://userscripts.org/scripts/show/65622">script</a> not installed') :
  567. "No"));
  568. return false;
  569. });
  570.  
  571. holodeck.addChatCommand("hlreset", function(l, n) {
  572. var diag = l.activeDialogue();
  573. diag.kongBotMessage("Resetting all highlighting preferences");
  574.  
  575. holodeck._chat_commands.hlcolor[0](holodeck, "/color #def6ea");
  576. holodeck._chat_commands.whispercolor[0](holodeck, "/color #deeaf6");
  577. holodeck._chat_commands.friendcolor[0](holodeck, "/color #006600");
  578. holodeck._chat_commands.modcolor[0](holodeck, "/color #ba6328");
  579. holodeck._hl_priority = 1;
  580. holodeck._hl_friends = 1;
  581. holodeck._hl_mods = 1;
  582. holodeck._hl_chime = 1;
  583. holodeck._highlighting = [];
  584. holodeck._hluser = [];
  585.  
  586. ["highlighting", "highlightuser", "hlcolor", "whispercolor", "friendcolor",
  587. "modcolor", "highlightfriends", "highlightpriority", "highlightmods",
  588. "highlightchime"].forEach(function(pref) {
  589. window.setTimeout(function() {
  590. GM_deleteValue("kong_" + pref);
  591. }, 0);
  592. });
  593.  
  594. return false;
  595. });
  596.  
  597. holodeck._chat_commands.hl = holodeck._chat_commands.highlight;
  598. holodeck._chat_commands.hlfriend = holodeck._chat_commands.hlfriends;
  599.  
  600. holodeck._highlighting = [];
  601. holodeck._hluser = [];
  602.  
  603.  
  604. var color = "#def6ea", wcolor = "#deeaf6", fcolor = "#006600", mcolor = "#ba6328", priority = 1, friends = 1, mods = 1, chime = 1;
  605.  
  606. if(typeof GM_setValue !== "function"){
  607. GM_setValue = GM_getValue = function(){};
  608. } else {
  609. // migrate old value
  610. var temp = GM_getValue("kong_highlightcolor", "");
  611. if(temp){
  612. GM_setValue("kong_hlcolor", temp);
  613. if(typeof GM_deleteValue === "undefined"){
  614. GM_setValue("kong_highlightcolor", "");
  615. } else {
  616. GM_deleteValue("kong_highlightcolor");
  617. }
  618. }
  619.  
  620. var list = GM_getValue("kong_highlighting"),
  621. user = GM_getValue("kong_highlightuser");
  622. color = GM_getValue("kong_hlcolor", "#def6ea")||"#def6ea";
  623. wcolor = GM_getValue("kong_whispercolor", "#deeaf6")||"#deeaf6";
  624. fcolor = GM_getValue("kong_friendcolor", "#006600")||"#006600";
  625. mcolor = GM_getValue("kong_modcolor", "#ba6328")||"#ba6328";
  626. friends = GM_getValue("kong_highlightfriends", 1);
  627. priority = GM_getValue("kong_highlightpriority", 1);
  628. mods = GM_getValue("kong_highlightmods", 1);
  629. chime = GM_getValue("kong_highlightchime", 1);
  630. if(list){holodeck._highlighting = list.trim().split(' ')};
  631. if(user){holodeck._hluser = user.trim().split(' ')}
  632. }
  633.  
  634. holodeck._hl_friends = friends;
  635. holodeck._hl_mods = mods;
  636. holodeck._hl_chime = chime;
  637. holodeck._hl_priority = priority;
  638.  
  639. // guarantee we have a non-crossdomain stylesheet
  640. var style = document.createElement("style");
  641. var head = document.getElementsByTagName("head")[0];
  642. (head || document.body).appendChild(style);
  643.  
  644. // now find it...
  645. var sheet = null;
  646. for(var s = document.styleSheets.length - 1; s >= 0; --s) {
  647. try{
  648. if(document.styleSheets[s].cssRules && document.styleSheets[s].cssRules.length) {
  649. sheet = document.styleSheets[s];
  650. break;
  651. }
  652. }catch(e){ /* no-op */ }
  653. }
  654.  
  655. if(!sheet) {
  656. alert("Kongregate Chat Line Highlighting could not find a style sheet!\nPlease send a message to Ventero about this problem.");
  657. return;
  658. }
  659.  
  660. sheet.insertRule('#kong_game_ui .chat_message_window .whisper { background-color: '+wcolor+' !important; }', sheet.cssRules.length);
  661. sheet.insertRule('#kong_game_ui .chat_message_window .highlight.even { background-color: '+color+' !important; }', sheet.cssRules.length);
  662. sheet.insertRule('#kong_game_ui .chat_message_window .highlight { background-color: '+color+' !important; }', sheet.cssRules.length);
  663. sheet.insertRule('#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username { color: '+fcolor+' !important; }', sheet.cssRules.length);
  664. sheet.insertRule('#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username { color: '+mcolor+' !important; }', sheet.cssRules.length);
  665. sheet.insertRule('#kong_game_ui .chat_message_window p { padding: 2px 2px 2px 2px;}', sheet.cssRules.length);
  666. sheet.insertRule('#kong_game_ui .chat_message_window p { margin: 0px 0px;}', sheet.cssRules.length);
  667. }
  668. }
  669. }
  670.  
  671.  
  672. //============
  673. // Reply-Command
  674. // http://userscripts-mirror.org/scripts/review/47963
  675. //============
  676. function init_replyCommand()
  677. {
  678.  
  679. var CDialogue = dom.ChatDialogue;
  680.  
  681. if (CDialogue){
  682.  
  683. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  684. if(!CDialogue.prototype.oldKeyPressReply){
  685.  
  686. CDialogue.prototype.oldKeyPressReply = CDialogue.prototype.onKeyPress;
  687.  
  688. if(CDialogue.prototype.reply){
  689. CDialogue.prototype.oldreply = CDialogue.prototype.reply
  690. } else {
  691. CDialogue.prototype.oldreply = function(a){};
  692. }
  693. CDialogue.prototype.reply = function(a){
  694. this._holodeck._reply = a;
  695. this.oldreply(a);
  696. }
  697.  
  698. if(!CDialogue.prototype.showReceivedPM){
  699. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  700. CDialogue.prototype.receivedPrivateMessage = function(a){
  701. if (a.data.success){
  702. this.reply(a.data.from)
  703. }
  704. this.showReceivedPM(a);
  705. }
  706. }
  707.  
  708. CDialogue.prototype.onKeyPress = function (a) {
  709. var z, node = (this._input_node.wrappedJSObject || this._input_node);
  710. if(a.which == 32 &&
  711. ((a.currentTarget.selectionStart == 2 && (z = node.getValue().match(/^\/r(.*)/i))) ||
  712. (z = node.getValue().match(/^\/r\b(.*)/i)))){
  713. var x=z[1]||"";
  714. if (this._holodeck._reply) {
  715. this.setInput("/w "+this._holodeck._reply+" "+x);
  716. } else {
  717. this.setInput("/w ");
  718. }
  719. if(a.stop) a.stop();
  720. if(a.preventDefault) a.preventDefault();
  721. };
  722.  
  723. this.oldKeyPressReply(a);
  724. }
  725. }
  726. }
  727. }
  728.  
  729.  
  730. //==========
  731. // Reply-Command (hotkey)
  732. // http://userscripts-mirror.org/scripts/review/47983
  733. function init_replyHotkey(){
  734.  
  735. var holodeck = dom.holodeck,
  736. CDialogue = dom.ChatDialogue;
  737.  
  738. if (CDialogue && holodeck){
  739. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  740.  
  741. if(!CDialogue.prototype.oldKeyPressReplyHotkey){
  742. CDialogue.prototype.oldKeyPressReplyHotkey = CDialogue.prototype.onKeyPress;
  743.  
  744. CDialogue.prototype.onKeyPress = function (a) {
  745. var node = (this._input_node.wrappedJSObject || this._input_node);
  746. if (a.which == 13) {
  747. this.cnt=0;
  748. } else if (a.altKey && a.which == 114) {
  749. this.cnt+=1;
  750. l=this._holodeck._replyHotkey.length||-1;
  751. reply=this._holodeck._replyHotkey[l-this.cnt]||"";
  752. if(reply && this.cnt<=l){
  753. if(z=node.getValue()){
  754. if(z.match(/^\/[\s]*/)){
  755. z=z.replace(/^([^\s]+)\s*[^\s]*\s*(.*)/, '/w '+reply+' $2')
  756. }else{
  757. z="/w "+reply+" "+z
  758. };
  759. this.setInput(z)
  760. }else{
  761. this._holodeck.insertPrivateMessagePrefixFor(reply);
  762. }
  763. }else if(this.cnt>l){
  764. z=node.getValue();
  765. if (z=="/w "+this._holodeck._replyHotkey[0]+" "){
  766. this.setInput("/w ");
  767. this.cnt=0;
  768. }else if(z=="" && l>0){
  769. this.cnt-=1;
  770. this.setInput("/w "+this._holodeck._replyHotkey[l-this.cnt]+" ");
  771. }else{
  772. r=z.match(/^\/[^\s]+\s+[^\s]+\s+(.*)/);
  773. r&&(z=r[1]);
  774. this.setInput(z);
  775. this.cnt=0;
  776. }
  777. }
  778. }
  779. this.oldKeyPressReplyHotkey(a);
  780. }
  781.  
  782. CDialogue.prototype.cnt=0;
  783.  
  784. CDialogue.prototype.whisperArray = function(a,x){var i=a.indexOf(x);if(-1!==i)a.splice(i, 1);return a.concat(x);};
  785.  
  786. if(CDialogue.prototype.reply){
  787. CDialogue.prototype.oldreplyHotkey = CDialogue.prototype.reply
  788. } else {
  789. CDialogue.prototype.oldreplyHotkey = function(a){};
  790. }
  791.  
  792. CDialogue.prototype.reply = function(a){
  793. this._holodeck._replyHotkey=this.whisperArray(this._holodeck._replyHotkey, a);
  794. this.oldreplyHotkey(a);
  795. }
  796.  
  797. if(!CDialogue.prototype.showReceivedPM){
  798. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  799. CDialogue.prototype.receivedPrivateMessage = function(a){
  800. if (a.data.success){
  801. this.reply(a.data.from)
  802. }
  803. this.showReceivedPM(a);
  804. }
  805. }
  806. holodeck._replyHotkey= new Array();
  807. }
  808. }
  809. }
  810.  
  811.  
  812. //============
  813. // Username-Completion
  814. // http://userscripts-mirror.org/scripts/review/49872
  815. // Thanks to kaedenn for the idea of adding a colon if the username is the first word in the message
  816. //============
  817. function init_usernameCompletion()
  818. {
  819. if(typeof ChatDialogue === "undefined" ||
  820. ChatDialogue.prototype.oldKeyPressTab) return;
  821.  
  822. var isChrome = (navigator.appVersion.indexOf("Chrome") >= 0);
  823. if(isChrome) {
  824. ChatDialogue.prototype.initialize =
  825. ChatDialogue.prototype.initialize.wrap(function(old, p, i, h, u){
  826. old(p, i, h, u);
  827. var self = this;
  828. this._input_node.observe("keydown", function(event) {
  829. if(event.keyCode != 9 || event.ctrlKey || event.altKey || event.metaKey) return;
  830. self.onKeyPress(event);
  831. });
  832. })
  833. }
  834.  
  835. ChatDialogue.prototype.oldKeyPressTab = ChatDialogue.prototype.onKeyPress;
  836. ChatDialogue.prototype.tabcnt = 0;
  837. ChatDialogue.prototype.done = 1;
  838. ChatDialogue.prototype.onKeyPress = function(a){
  839. if (a.keyCode != 9 || a.ctrlKey){
  840. this.tabcnt = 0;
  841. this.done = 1;
  842. this.oldKeyPressTab(a);
  843. return;
  844. }
  845.  
  846. var node = (this._input_node.wrappedJSObject || this._input_node);
  847. if (this.tabcnt == 0 && this.done == 1){
  848. var inputText = node.getValue(),
  849. spaceAtCaret = inputText.substr(0, node.selectionStart).lastIndexOf(' ');
  850. this._caretPos = node.selectionStart;
  851. this._start = inputText.substr(0,spaceAtCaret);
  852. if(this._start) this._start+=" ";
  853.  
  854. this._currentWord = inputText.substring(spaceAtCaret+1, this._caretPos);
  855. this._rest = inputText.substr(this._caretPos);
  856. }
  857. this.done = 0;
  858.  
  859. var userArray = this._holodeck.chatWindow().activeRoom()._users_list,
  860. possibleMatches = [],
  861. z = node.getValue();
  862. if (z.match(/\s+$/)) z=z.replace(/\s+$/, '')
  863.  
  864. for (var i=0;i<userArray.length;i++){
  865. if(userArray[i].username.toLowerCase().indexOf(this._currentWord.toLowerCase())==0){
  866. possibleMatches.push(userArray[i].username);
  867. }
  868. }
  869.  
  870. if (this.tabcnt < possibleMatches.length){
  871. node.setValue(this._start + possibleMatches[this.tabcnt] + (this._start?" ":": ") + this._rest);
  872. node.selectionStart = this._caretPos + possibleMatches[this.tabcnt].length - this._currentWord.length+(this._start?1:2);
  873. node.selectionEnd = node.selectionStart;
  874. this.tabcnt+=1;
  875. } else {
  876. node.setValue(this._start + this._currentWord + this._rest);
  877. node.selectionStart = this._caretPos;
  878. node.selectionEnd = this._caretPos;
  879. this.tabcnt = 0
  880. }
  881. if(a.stop) a.stop();
  882. if(a.preventDefault) a.preventDefault();
  883. }
  884. }
  885.  
  886.  
  887. //============
  888. // Kongregate Chat Mouseover Timestamp
  889. // http://userscripts-mirror.org/scripts/review/50785
  890. //============
  891. function init_chatMouseoverTimestamp()
  892. {
  893.  
  894. var holodeck = dom.holodeck,
  895. ChatDialogue = dom.ChatDialogue,
  896. $ = dom.$;
  897.  
  898. function injectMouseover(dom, $, holodeck, ChatDialogue) {
  899. var message_rollover_template = new dom.Element("div", {id: "message_rollover_template", "class": "user_rollover_container spritesite", style: "display: none"});
  900. var message_rollover = new dom.Element("div", {"class": "user_rollover spritesite"});
  901. var message_rollover_inner = new dom.Element("div", {"class": "user_rollover_inner"});
  902. var rollover_private_message_holder = new dom.Element("p", {"class": "rollover_message_private_message_link_message_link_holder"});
  903. 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");
  904. rollover_private_message_holder.appendChild(rollover_private_message_link);
  905. var rollover_time_text = new dom.Element("p", {id: "rollover_time_text"});
  906. message_rollover_inner.appendChild(rollover_time_text);
  907. message_rollover_inner.appendChild(rollover_private_message_holder);
  908. message_rollover.appendChild(message_rollover_inner);
  909. message_rollover_template.appendChild(message_rollover);
  910. $('chat_tab_pane').appendChild(message_rollover_template);
  911.  
  912. var MessageRollover = dom.MessageRollover = function(chat_dialogue) {
  913. this.initialize(chat_dialogue);
  914. return this;
  915. }
  916.  
  917. MessageRollover.prototype = {
  918. initialize: function(chat_dialogue){
  919. this._active_dialogue = chat_dialogue;
  920. this._holodeck = chat_dialogue._holodeck;
  921. this._rollover_template_node = $('message_rollover_template');
  922. this._private_message_node = $('rollover_message_private_message_link');
  923. this._time_node = $('rollover_time_text');
  924.  
  925. this._private_message_observer = function(){};
  926.  
  927. if(this._rollover_template_node){
  928. var rollover = this;
  929. this._rollover_template_node.observe('mouseover', function(event){
  930. rollover.stopHide();
  931. dom.Event.stop(event);
  932. });
  933. this._rollover_template_node.observe('mouseout', function(event){
  934. rollover.beginHide();
  935. dom.Event.stop(event);
  936. });
  937. }
  938. },
  939. show: function(time, user, event){
  940. if(this._hideTimer) clearTimeout(this._hideTimer);
  941. this.updatePrivateMessageLink(user);
  942. this.updateTimeText(time);
  943. this.setRolloverPosition(event);
  944. this._rollover_template_node.show();
  945. },
  946. setRolloverPosition: function(event) {
  947. var messagenode = event.target;
  948. var current_scroll_top = this._active_dialogue._message_window_node.scrollTop;
  949. var current_message_top = messagenode.positionedOffset()[1];
  950. // nudge the user rollover up a little
  951. current_message_top = current_message_top - 9;
  952.  
  953. var new_top_val = current_message_top;
  954. if ( current_scroll_top < current_message_top ) {
  955. new_top_val = current_message_top - current_scroll_top;
  956. }
  957.  
  958. var top_style_str = new_top_val + 'px';
  959. this._rollover_template_node.setStyle({ top: top_style_str });
  960.  
  961. // set left position based on username length
  962. var username_width = messagenode.getWidth();
  963. var new_left_val = 20 + username_width;
  964.  
  965. var left_style_str = new_left_val + 'px';
  966. this._rollover_template_node.setStyle({ left: left_style_str });
  967. },
  968.  
  969. updatePrivateMessageLink: function(username){
  970. var cw = this._holodeck.chatWindow();
  971. // replace observer
  972. this._private_message_node.stopObserving('click');
  973. this._private_message_observer = dom.CapturesToInlineRegistration.decorate(function(event){
  974. // just put /w <username> in the chat input field
  975. cw.insertPrivateMessagePrefixFor(username);
  976. dom.Event.stop(event);
  977. return false;
  978. });
  979. this._private_message_node.observe('click', this._private_message_observer);
  980. },
  981. updateTimeText: function(time){
  982. this._time_node.innerHTML = time;
  983. },
  984. beginHide: function() {
  985. var rollover = this;
  986. if(this._hideTimer){ clearTimeout(this._hideTimer); }
  987. this._hideTimer = setTimeout(function() { rollover.hide(); }, 500);
  988. },
  989. stopHide: function() {
  990. clearTimeout(this._hideTimer);
  991. },
  992. hide: function() {
  993. this._rollover_template_node.hide();
  994. }
  995. };
  996.  
  997. ChatDialogue.MESSAGE_TEMPLATE.template = '<p class="#{classNames}"><span username="#{username}" time="#{time}" class="username #{userClassNames}">#{prefix}#{username}</span><span class="separator">: </span><span class="message">#{message}</span><span class="clear"></span></p>';
  998. ChatDialogue.MESSAGE_TEMPLATE.old_evaluate = ChatDialogue.MESSAGE_TEMPLATE.evaluate;
  999. ChatDialogue.MESSAGE_TEMPLATE.evaluate = function(args){
  1000. var date = new Date();
  1001. var hours = date.getHours();
  1002. var minutes = date.getMinutes();
  1003. var seconds = date.getSeconds();
  1004. var time;
  1005. if (holodeck._timeFormat == 12){
  1006. 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
  1007. } else {
  1008. time = (hours<10?"0":"")+hours+":"+(minutes<10?"0":"")+minutes+":"+(seconds<10?"0":"")+seconds; //24-hour clock
  1009. }
  1010. args.time = time;
  1011. return this.old_evaluate(args);
  1012. };
  1013.  
  1014. ChatDialogue.prototype.initialize =
  1015. ChatDialogue.prototype.initialize.wrap(function(old, parent_node, onInputFunction, holodeck, user_manager){
  1016. old(parent_node, onInputFunction, holodeck, user_manager);
  1017. //var self = this;
  1018. //this._input_node.observe("keydown", function(event) {
  1019. // if(event.keyCode != 9 || event.ctrlKey || event.altKey || event.metaKey) return;
  1020. // self.onKeyPress(event);
  1021. //});
  1022. //})
  1023. //ChatDialogue.prototype.initialize = function(parent_node, onInputFunction, holodeck, user_manager) {
  1024. this._messages_until_next_collection = 0;
  1025. this._holodeck = holodeck;
  1026. this._user_manager = user_manager;
  1027. this._parent_node = parent_node;
  1028. this._messages_count = 0;
  1029. this._insertion_count = 0;
  1030. this._onInputFunction = onInputFunction;
  1031. this._message_rollover_manager = new MessageRollover(this);
  1032.  
  1033. // Establish references to re-used nodes
  1034. this._message_window_node = parent_node.down('.chat_message_window');
  1035. this._input_node = parent_node.down('.chat_input');
  1036.  
  1037. this._messages_to_retain = 200;
  1038.  
  1039. this._message_window_node.stopObserving();
  1040.  
  1041. this._message_window_node.observe('mouseover', function(event) {
  1042. var time = event.target.getAttribute("time"),
  1043. user = event.target.getAttribute("username");
  1044. if (time){
  1045. holodeck.activeDialogue().showMessageRollover(time, user, event);
  1046. dom.Event.stop(event);
  1047. }
  1048. });
  1049.  
  1050. this._message_window_node.observe('mouseout', function(event) {
  1051. holodeck.activeDialogue().hideMessageRollover();
  1052. dom.Event.stop(event);
  1053. });
  1054.  
  1055. // Bind event listeners
  1056. var dialogue = this,
  1057. input_node = this._input_node;
  1058. this._input_node.observe('keypress', function(event) { dialogue.onKeyPress(event); });
  1059. this._input_node.observe('focus', function(event) { dialogue.clearPrompt(); });
  1060.  
  1061. // Trigger mini-profile for clicks on usernames in chat.
  1062. this._message_window_node.observe('click',
  1063. function(event) {
  1064. if (event.target) {
  1065. var username = event.target.getAttribute('username');
  1066. if(username){
  1067. event.stop();
  1068. user_manager.showProfile(username);
  1069. }
  1070. }
  1071. });
  1072. });
  1073.  
  1074. ChatDialogue.prototype.showMessageRollover = function (time, user, event){
  1075. this._message_rollover_manager.show(time, user, event);
  1076. }
  1077.  
  1078. ChatDialogue.prototype.hideMessageRollover = function(){
  1079. this._message_rollover_manager.beginHide();
  1080. }
  1081. }
  1082.  
  1083. if(holodeck && ChatDialogue){
  1084. if(!ChatDialogue.prototype && dom.CDprototype)
  1085. ChatDialogue.prototype = dom.CDprototype;
  1086.  
  1087. if(!holodeck.__mouseover){
  1088. holodeck.__mouseover = true;
  1089.  
  1090. var script = document.createElement("script");
  1091. script.type = "text/javascript";
  1092. script.textContent = "(" + injectMouseover.toString() + ")(window, $, holodeck, ChatDialogue);";
  1093. document.body.appendChild(script);
  1094. setTimeout(function(){document.body.removeChild(script);}, 100);
  1095.  
  1096. holodeck.addChatCommand("timeformat", function(l,n){
  1097. var k = n.match(/^\/\S+\s+(\d+)/),
  1098. m = "",
  1099. q = l.activeDialogue();
  1100. k && (m=k[1]);
  1101. if(m==12 || m==24){
  1102. l._timeFormat = m;
  1103. window.setTimeout(function(){GM_setValue("kong_timeformat", m);}, 0);
  1104. q.displayMessage("Timeformat", "Set to "+m+"-hour clock (hh:mm:ss"+(m==12?" AM/PM)":")"), { "class": "whisper received_whisper"}, {non_user: true});
  1105. } else {
  1106. q.displayMessage("Timeformat", "Allowed values: 12 and 24", { "class": "whisper received_whisper"}, {non_user: true});
  1107. }
  1108. return false;
  1109. });
  1110.  
  1111. var timeformat = 12;
  1112.  
  1113. if(typeof GM_setValue !== "undefined"){
  1114. timeformat = GM_getValue("kong_timeformat", 12)||12;
  1115. }else{
  1116. GM_setValue = function(){};
  1117. }
  1118.  
  1119. holodeck._timeFormat = timeformat;
  1120. }
  1121. }
  1122. }
  1123.  
  1124.  
  1125. //============
  1126. // Kongregate Chat Afk-Commands
  1127. // http://userscripts-mirror.org/scripts/show/48936
  1128. //============
  1129.  
  1130. function init_afk(){
  1131. var AUTOAFK = "kongregate_autoAFKTimeout";
  1132.  
  1133. var holodeck = dom.holodeck,
  1134. CDialogue = dom.ChatDialogue,
  1135. CRoom = dom.ChatRoom,
  1136. CWindow = dom.ChatWindow,
  1137. Base64 = dom.Base64;
  1138.  
  1139. if(holodeck && CDialogue){
  1140. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  1141. CRoom.prototype = dom.CRprototype||dom.ChatRoom.prototype;
  1142. CWindow.prototype = dom.CWprototype||dom.ChatWindow.prototype;
  1143.  
  1144. if(!holodeck.__afk){
  1145. holodeck.__afk = true;
  1146. if(!holodeck.setPresenceAwayOld){
  1147. holodeck.setPresenceAwayOld = holodeck.setPresenceAway;
  1148. holodeck.setPresenceAway = function(){
  1149. this._afk = 1;
  1150. this.setPresenceAwayOld();
  1151. }
  1152. }
  1153. if(!holodeck.setPresenceChatOld){
  1154. holodeck.setPresenceChatOld = holodeck.setPresenceChat;
  1155. holodeck.setPresenceChat = function(){
  1156. this._afk = 0;
  1157. this.setPresenceChatOld();
  1158. }
  1159. }
  1160.  
  1161. if(!CRoom.prototype.updateUserOld_AFK){
  1162. CRoom.prototype.updateUserOld_AFK = CRoom.prototype.updateUser;
  1163. CRoom.prototype.updateUser= function(user){
  1164. this.updateUserOld_AFK.apply(this, arguments);
  1165. if(user.username == this._chat_window.username()){
  1166. if(this._presence != user.variables.presence){
  1167. switch(user.variables.presence){
  1168. case "chat":
  1169. if(!this._chat_window._holodeck._afktoggle)
  1170. this._chat_window._holodeck._afk = 0;
  1171. break;
  1172. case "away":
  1173. this._chat_window._holodeck._afk = 1;
  1174. break;
  1175. }
  1176. }
  1177. }
  1178. }
  1179. }
  1180.  
  1181. holodeck._chat_commands.afk[0] = function (l, n) { if (l._afk == 0) {l.setPresenceAway()} else {l.setPresenceChat()} return false; }
  1182. holodeck._chat_commands.back[0] = function(l,n){l.setPresenceChat(); return false};
  1183.  
  1184. holodeck.addChatCommand("afkmessage", function (l, n){ var z = n.match(/^\/\S+\s+(.+)/); if (z){a = z[1]}else{a="I am currently AFK"} l._afkmessage = a; l.activeDialogue().kongBotMessage("AFK-message set to: "+a); return false});
  1185.  
  1186. 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; });
  1187.  
  1188. holodeck.addChatCommand("autoafk", function(l, n){
  1189. var match = n.match(/^\/autoafk\s+(\d+)/),
  1190. timeout = 15;
  1191.  
  1192. if(match && match[1]){
  1193. timeout = parseInt(match[1], 10);
  1194. }
  1195.  
  1196. l._autoAFK = timeout*60*1000;
  1197. window.setTimeout(function(){GM_setValue(AUTOAFK, timeout)}, 0);
  1198.  
  1199. if(l._autoAFKTimeout){
  1200. clearTimeout(l._autoAFKTimeout);
  1201. }
  1202.  
  1203. if(timeout){
  1204. l.activeDialogue().kongBotMessage("Set auto-AFK timeout to " + timeout + " minute" + (timeout > 1?"s":""));
  1205. l._autoAFKTimeout = setTimeout(function(a){a.setPresenceAway();}, l._autoAFK, l);
  1206. } else {
  1207. l.activeDialogue().kongBotMessage("Disabled auto-AFK");
  1208. }
  1209.  
  1210. return false;
  1211. });
  1212.  
  1213. holodeck.checkAFK = function(){
  1214. if(!this._afktoggle){
  1215. this._afk = 0;
  1216. }
  1217. if(this._autoAFKTimeout){
  1218. clearTimeout(this._autoAFKTimeout);
  1219. }
  1220. if(this._autoAFK){
  1221. this._autoAFKTimeout = setTimeout(function(a){a.setPresenceAway();}, this._autoAFK, this);
  1222. }
  1223. }
  1224.  
  1225. holodeck.addOutgoingMessageFilter(function(message, nextFunction){
  1226. holodeck.checkAFK();
  1227. nextFunction(message, nextFunction);
  1228. });
  1229.  
  1230. // Outgoing whispers aren't filtered (yet), so check them manually...
  1231. if(!CWindow.prototype.oldSendPrivateMessageAFK){
  1232. CWindow.prototype.oldSendPrivateMessageAFK = CWindow.prototype.sendPrivateMessage;
  1233. CWindow.prototype.sendPrivateMessage = function(user, msg){
  1234. if(msg.indexOf(this._holodeck._afkprefix)!=0){
  1235. this._holodeck.checkAFK();
  1236. }
  1237. this.oldSendPrivateMessageAFK(user, msg);
  1238. }
  1239. }
  1240.  
  1241. // Create setTimeout on session reconnect
  1242. if(!CWindow.prototype.onLoginOldAFK){
  1243. CWindow.prototype.onLoginOldAFK = CWindow.prototype.onLogin;
  1244. CWindow.prototype.onLogin = function(){
  1245. this.onLoginOldAFK();
  1246. if(this._holodeck._afk) {
  1247. this._holodeck.setPresenceAway();
  1248. } else {
  1249. this._holodeck.setPresenceChat();
  1250. this._holodeck.checkAFK();
  1251. }
  1252. }
  1253. }
  1254.  
  1255. if(!CDialogue.prototype.reply){
  1256. CDialogue.prototype.reply = function(a){}
  1257. }
  1258.  
  1259. if(!CDialogue.prototype.showReceivedPM){
  1260. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  1261. }
  1262.  
  1263. CDialogue.prototype.receivedPrivateMessage = function(a){
  1264. if (a.data.success){
  1265. this.reply(a.data.from);
  1266. 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)}
  1267. }
  1268. this.showReceivedPM(a);
  1269. }
  1270.  
  1271. holodeck._afk = 0;
  1272.  
  1273. holodeck._afktoggle = 0;
  1274.  
  1275. holodeck._afkmessage = "I am currently AFK";
  1276.  
  1277. holodeck._afkprefix = "[AFK] ";
  1278.  
  1279. var autoAFK = 15;
  1280.  
  1281. try{
  1282. if(GM_setValue){
  1283. autoAFK = GM_getValue(AUTOAFK, 15);
  1284. }else{
  1285. GM_setValue = function(a,b){};
  1286. }
  1287. }catch(e){
  1288. GM_setValue = function(a,b){};
  1289. }
  1290.  
  1291. holodeck._autoAFK = autoAFK*60*1000;
  1292. if(holodeck._autoAFK > 0){
  1293. holodeck._autoAFKTimeout = setTimeout(function(a){a.setPresenceAway();}, holodeck._autoAFK, holodeck);
  1294. }
  1295. }
  1296. }
  1297. }
  1298.  
  1299.  
  1300. //============
  1301. // Character-limit
  1302. // http://userscripts-mirror.org/scripts/review/48979
  1303. //============
  1304. function init_chatCharacterLimit(){
  1305.  
  1306. var CDialogue = dom.ChatDialogue;
  1307.  
  1308. if(CDialogue){
  1309. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  1310.  
  1311. if(!CDialogue.prototype.oldKeyPressLimit){
  1312. CDialogue.prototype.oldKeyPressLimit = CDialogue.prototype.onKeyPress;
  1313. CDialogue.prototype.onKeyPress = function (a) {
  1314. var node = (this._input_node.wrappedJSObject || this._input_node);
  1315. this.oldKeyPressLimit(a);
  1316. if (node.getValue().length > 249) {
  1317. z = node.getValue();
  1318. var y = "";
  1319. if (n=z.match(/^(\/\S+\s+\S*\s*)(.*)/)){
  1320. y=n[2];
  1321. if (y.length>249){
  1322. node.setValue(n[1]+y.substr(0, 249))
  1323. }
  1324. }else{
  1325. node.setValue(node.getValue().substr(0, 249))
  1326. }
  1327. }
  1328. }
  1329. }
  1330. };
  1331. }
  1332.  
  1333.  
  1334. //============
  1335. // KongreLink (skyboy attribution applies)
  1336. // http://userscripts-mirror.org/scripts/review/72163
  1337. //============
  1338.  
  1339. function init_kongreLink()
  1340. {
  1341. window.location.assign("javascript:void(holodeck.addIncomingMessageFilter(function(m,n){var REGEX=/((?:<\\S[^>]+?)?(?:>)?)?(\\b(?:(?:(ht|f)tp)s?:\\/\\/)?(((?:\\w+[.])?(?:[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9]|[a-z0-9]{1,2})[.])*(a(?:c|d|e(?:ro)?|f|g|i|l|m|n|o|q|r(?:pa)?|s(?:ia)?|t|u|w|x|z)|b(?:a|b|d|e|f|g|h|i|iz|j|l|m|n|o|r|s|t|v|w|y|z)|c(?:at?|c|d|f|g|h|i|k|l|m|n|o(?:m|op)?|r|u|v|x|y|z)|d[ejkmoz]|e(?:c|du|e|g|h|r|s|t|u)|f[ijkmor]|g(?:a|b|d|e|f|g|h|i|l|m|n|ov|p|q|r|s|t|u|w|y)|h[kmnrtu]|host|i(?:d|e|l|m|n(?:fo|t)|o|q|r|s|t)|je|jm|jo|jobs|jp|k[eghimnprwyz]|l[abcikrstuvy]|moe|m(?:a|c|d|e|f|g|h|i?l|k|m|n|o(?:bi)?|p|q|r|s|t|u(?:seum)?|v|w|x|y|z)|n(?:a(?:me)?|c|et?|f|g|i|l|o|p|r|u|z)|om|org|p(?:a|e|f|g|h|k|l|m|n|ro?|s|t|w|y)|qa|r[eosuw]|s(?:a|b|c|d|e|g|h|i|j|k|l|m|n|o|r|t|u|v|y|z)|t(?:c|d|e?l|f|g|th|j|k|m|n|o|p|r(?:avel)?|t|v|w|z)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])\\b([.]\\B)?|\\d+[.]\\d+[.]\\d+[.]\\d+)(?::\\d+)?)(\\/+\\??(?:\\S+))?/ig,lF=/(?:<(\\S)[^>]+?href=[\"'])(?:\\b((?:(ht|f)tp)s?:\\/\\/)?(((?:\\S+[.])?(?:[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9]|[a-z0-9]{1,2})[.])*(a(?:c|d|e(?:ro)?|f|g|i|l|m|n|o|q|r(?:pa)?|s(?:ia)?|t|u|w|x|z)|b(?:a|b|d|e|f|g|h|i|iz|j|l|m|n|o|r|s|t|v|w|y|z)|c(?:at?|c|d|f|g|h|i|k|l|m|n|o(?:m|op)?|r|u|v|x|y|z)|d[ejkmoz]|e(?:c|du|e|g|h|r|s|t|u)|f[ijkmor]|g(?:a|b|d|e|f|g|h|i|l|m|n|ov|p|q|r|s|t|u|w|y)|h[kmnrtu]|i(?:d|e|l|m|n(?:fo|t)|o|q|r|s|t)|je|jm|jo|jobs|jp|k[eghimnprwyz]|l[abcikrstuvy]|m(?:a|c|d|e|f|g|h|i?l|k|m|n|o(?:bi)?|p|q|r|s|t|u(?:seum)?|v|w|x|y|z)|n(?:a(?:me)?|c|et?|f|g|i|l|o|p|r|u|z)|om|org|p(?:a|e|f|g|h|k|l|m|n|ro?|s|t|w|y)|qa|r[eosuw]|s(?:a|b|c|d|e|g|h|i|j|k|l|m|n|o|r|t|u|v|y|z)|t(?:c|d|e?l|f|g|th|j|k|m|n|o|p|r(?:avel)?|t|v|w|z)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])\\b([.]\\B)?|\\d+[.]\\d+[.]\\d+[.]\\d+)(?::\\d+)?)?(\\/+(?:\\S+))??(?:[\"'][^>]*?>([\\s\\S]+?)<\\/\\1>)/gi,q=function(w,c,r,l){var t,a,d;w=w.substring(0,(t=r.lastIndex)-(a=c[0]).length)+(a=(\"<a \"+(l?l[1]:'')+\" href='\"+(((d=c[3])==\"ht\"||d==\"f\")?\"\":\"http://\")+(d=a).replace(/<a[^>]+?href=([\"'])([\\s\\S]+?)\\1[^>]*?>[\\s\\S]+<\\/a>/, \"$2\")+\"' target='_blank'>\"+(c[9]||d)+\"</a>\"))+w.substring(t,w.length);REGEX.lastIndex+=a.length-d.length;return w},Q=function(b){var w=b,t=REGEX.lastIndex=0,a,c,d;while(c=REGEX.exec(w)){if(c[1]||(!c[5]&&!c[7])||(c[7]&&!(c[3]||c[8])))continue;w=q(w,c,REGEX)};while(c=lF.exec(w)){c[3]='ht';w=q(w,c,lF,c[0].match(/(class=(['\"])[^>]+?\\2)[\\s\\S]*?>/i))};return w};return n(Q(m),n)}))");
  1342. }
  1343.  
  1344. //============
  1345. // PM Notifier (MrSpontaneous attribution applies
  1346. // http://userscripts.org/scripts/review/48979
  1347. //============
  1348. function init_PMNotifier()
  1349. {
  1350. var holodeck = dom.holodeck,
  1351. CDialogue = dom.ChatDialogue;
  1352. if (CDialogue)
  1353. {
  1354. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  1355. console.log("pm1");
  1356. if (!CDialogue.prototype.new_private_message)
  1357. {
  1358. console.log("pm2");
  1359. dom._animatedFav = false;
  1360. dom._pmCount = 0;
  1361. dom._baseTitle = document.title;
  1362. dom._blurred = false;
  1363. dom._chime = dom.document.createElement('audio');
  1364. dom._chime.setAttribute('src', 'data:audio/wav;base64,UklGRi4IAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YakHAACAgIGBgYKEh4qLjIyNjY2LioqJh4aGio2QkZGRkI6Lh4B3cXJ0dnp/g4aHiImDdm1pZmVnbHR6fYGLlZuhpKOgnp2dnJGCdWldU0pEPjgyOktaaHR+homLjZWYjn9wYFJNSUZCPkNadYuitMXU2+Dn7uXRv7KnoaCkqKagpLO8wsfJyMG7uLetlYBzaF5ZVFNVVFFWYmt1fH58dm9pZl9NOy4hFQsEBAgKDRwyQ1NldICIi4+Xm5iVkId/eHR0dHN0gZWnuMna6fX6/P/979/Ova+knpybmJWZoaOlp6elopuVk4t7bF9SSUNAP0JGR0xZZXB8g4eLjod6aVdJPjEjHyUwPUlSXnKEiYF0aF1SQjIvOEdZa3iJnaqspp6WlZOLipSlus7d5vD17t/Qv7Oup5+cpbPCztHT1dTFrZN6ZVhLPjo/SVRcW1xiZFtKNiQYEAgAAg4fMkBIUV5mZV9ZVVpjZ218kanB0tzl7Ori2M/IyMrIydDd6vX49fHt4cy0nYd5cGVdXWJpb29pZmZhVEIuHRIMBQAEDhonMTY9RkxMSkVCRk9UWWV3ip6uusPLzcrFwLu7wMPFy9fj7/j6+PTs38y4o5OJgXhzdnuAhYR/endvYU87KiAaEw8SGyYxO0BGTlJQS0VAQEZKTllrf5WsvcHBwcC8s62xvcfT4+/z9vn359PEuayhm5iTi4J3alpQTkxFPjovIRYNBQIKHC0+UGFkXltbWFRXaX+UqsPZ4+fq6uHUzs7LyMvT19HGt5+Da19YVFJWW1ZNRTwvJis2QElVX1tRS05QUmF8mbHK5vn79e7j0b60rqqorLjCv7WnkHFVRDYtKzE2NDAvLysnLDlDTVpna2NdYmptdYqlu9Dn+v/68+zeyLavq6eor7i+vbeslnZcTkAzLS0uKiUmJiIdIzE6PkRMTUQ8P0ZLU2mJpLrT7Pv8+fXs28rEwr67v8vW1Mm/uLCllHdeVlJHNichIy5AXH2NjYuKhXpsaHJ6eHFoXFVWYHF2bWFVR0FETFdbV1piZ25/l7TM1tnZ0MfDwcPN1NTKtZ6Uj4iEgHRlU0I+RElSW1tZV1NTXGp/m662uLGloKCls8DCuaaMd2lgX2JeU0Y2KyszP0xSUFBQTlJfc4uisr/Hw7y8wMfS2NTHr5OAdGtpa2pmXlNNUFVaX15bWlhWW2RziJ2uvcbGwsC+wMXHw7ikjXpsY2JmZ2ZhV05LTE5RT0lFRUVKU2Fzhpajr7Owr66usrW0rqGNe25kXl9gX1xVTUtMT1RYWFdZXGFqdYSVpbG7wsK+vLm5vL26sqibj4d/enp5dW9mXFZTUFBQS0dGR0pSYHWGjY2RnK7Ayse3opOSmJaGbFFFSVRWTDwyPVd2iIh8cHWKqr++pouAh5idjGtLP0hdZ1xGOENkj6+2rKCmwOP589aznp+rq5RrQzI7UWBbSDU2T3eaqJ+NhpOwy9G/n4eDjpaIZDodGSk8PzMgGCdLdI+XkIuWstXq5syunaGtr5p0TTg6SlZTRTc3TnWarayhnarH5fPpzK6en6SehmJBMjVCRz4sHiE5X4CRj4WBjqnH1c62npOVmpV/YEU7QlBXTjwtLUJkhZeZk5GbscnVzrunnZ6jnolpSz1BUl9fUkRATmqKoKejnqCsvsnEspyNjJOWinFUPjhATVJMQDg8TmiAjZGSl6S5zNTMu6mhpKqpm4BjT0pPWFpTS0ZNXHGAh4aDhIydrbOsnIyGipSZkoFwYVZQUVRZYGdpa25sZWNpdoynur65rqKZlpaVl56ioJmLdV9SS09bZmZcTj4xMjtIU1xbVFJWWFdZXmp/ma24vbispaixvMza39rQwK6gl4yCgYOCfHBcRzs7QEpXW1ZOR0A9Q09gdo2eqK+xqZ+Zl5qltL/AuKaOeWxlYmVrbWpjWk5HRklOVl1fXVxbV1ZbZ3eMn6y0ubq1sK6vsLa9wsTAtqaViH52c3V1cWpgVU5MTk9RVFNQUVNUVVpganeIlZ6kpaGbl5eYm6Glp6ahmY2De3JtbG5vbmpiWlVWWV1jZmZjY2VnbHJ5gImSmqCmqaijn5ybnaKmqKahmZCKhYF9enh0cW5qZmRiYmJkZmdnaGhoaWtvdX2EiYyOkZKSkZGQj5CRkpOSkIqFgHt3dXNyc3R1dnl9gYOBfXh1c3Fta2xvcnV3e4CEhoaGhoiIhoSEhomNkJSan6GhnpuZlpGMiIaGhYOCg4WGhoOBfXp1cGtnZ2dnZ2hrbm9ubGtqaWdmZmltcHN2eXx9fHp6ent7e3x/g4iMj5KWmZqamZeWlJGOi4qJiYmJiouNjY2LioiFgn98e3p5eXl5ent7e3p6enp6enp6e3x8fH19fX19fn5+fn5+f39/f39/f3+AgICAgICAgICBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgABMSVNUWAAAAElORk9JQ09QHwAAAENvcHlyaWdodCCpIENpbmVtYXRyb25pY3MgMTk5NQAASVBSRCMAAABNaWNyb3NvZnQgUGx1cyEgriBmb3IgV2luZG93cyA5NSCuAAA=');
  1365. dom._chime.load();
  1366.  
  1367. //dom.document.addEventListener("blur", function() {
  1368. window.onblur=function(){
  1369. dom._blurred = true;
  1370. console.log("Blur1");
  1371. };//, false);
  1372. console.log("pm3");
  1373. //dom.document.addEventListener("focus", function() {
  1374. window.onfocus=function(){
  1375. dom._blurred = false;
  1376. console.log("Focus 1");
  1377. dom.pmReset();
  1378. };//, false);
  1379. console.log("pm4");
  1380. dom.pmReset = function() {
  1381. if (dom._animatedFav) {
  1382. dom.toggleFavLink();
  1383. }
  1384. dom._pmCount = 0;
  1385. document.title = dom._baseTitle;
  1386. }
  1387. console.log("pm5");
  1388. dom.createFavLink = function(attr) {
  1389. var link = document.createElement("link");
  1390. link.type = attr['type'];
  1391. link.rel = attr['rel'];
  1392. link.href = attr['href'];
  1393. return link;
  1394. }
  1395. console.log("pm6");
  1396. dom.toggleFavLink = function() {
  1397. var head = document.getElementsByTagName("head")[0];
  1398. var links = head.getElementsByTagName("link");
  1399. for (var i=0; i<links.length; i++) {
  1400. var link = links[i];
  1401. if (link.rel=="shortcut icon") {
  1402. head.removeChild(link);
  1403. }
  1404. }
  1405. if (dom._animatedFav) {
  1406. head.appendChild(dom.createFavLink(dom._staticFavLinkAttr));
  1407. }
  1408. else {
  1409. head.appendChild(dom.createFavLink(dom._animatedFavLinkAttr));
  1410. }
  1411. dom._animatedFav = !dom._animatedFav;
  1412. }
  1413. console.log("pm7");
  1414. dom._staticFavLinkAttr = {'rel':'shortcut icon', 'href':'/favicon.ico', 'type':'image/x-icon'};
  1415. dom._animatedFavLinkAttr = { 'rel':'shortcut icon', 'href':'data:image/gif;base64,R0lGODlhIAAgAPceAGYAAJgAAJgBAZkCApoEBJkWGpkAM5krAJkpL5krM6EMDKQPEaARDaYkLassIpkrZplVM5lVZswrM8xVM8xVZsyAZsyAmcyqmcyqzP+qzMzVzP/VzP/V////zP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAhkAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAIAAgAAAI/gATBBhIsKDBgwgTKlyI0ABBgRADRBQ40MCBiRIzUgxAYYPHjyA3ZDgw0ELIkyMHQvDAsqVLlhQvvJzpgSIFmi9j4nRJMcHOlhQt/GQpgSCFCxxmXqhAoeBRmhssVDhYYeYDhDdfbkgAAGHVlxMOynx5wSFCAF9dRjAolCzDti7DEtQwsynDtC3XSszwUoOErm9nhk2w4WWGjQyz8kxA12UHhgbxsrTQgaZeyAHgDoWJOYDkoRswo8W5VXFLDJg1nyYZoPDLqXdnZijocyaEwC9vF1TtgUPsl3YLNnapYeFnxAMl0LSAMEEC3heQJxhLFnHtnaEHOgAtgOBmBAMXIGzuHqDAZoIMxg8kcH5gA/WdDQqYT59+/Pv449MfoCAgACH5BAhkAAAALAAAAAAgACAAh5kAAJwICP38/P39/f7+/v///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAifAAsIHEiwoMGDCBMqXMiw4UEAECNKhDhwokWKFS9KzKgxIsGOHgWCDClyJEeQBTs+VLlyI8KLCi22nLhQZkqYNWl+tMmQZwGcDXkCDapzKNGRGB3+REryKFMASlkaTajxZNOYPpfqzOlyZ9aZSb1ufTlWbFeDVdGmNTsUKVufbq22NSlwwMgAA+2OFMCQgF+Cfv8qHUx4YWC/Aw4TGBgQADs%3D', 'type':'image/gif'};
  1416. console.log("pm8");
  1417. CDialogue.prototype.new_private_message = function() {
  1418. console.log("got pm 1");
  1419. if (_blurred || (document.hidden != undefined && document.hidden) || (document.webkitHidden != undefined && document.webkitHidden)) {
  1420. console.log("got pm blurred");
  1421. dom._pmCount++;
  1422. if (!dom._animatedFav) {
  1423. dom.toggleFavLink();
  1424. }
  1425. document.title = "[" + dom._pmCount + "] " + dom._baseTitle;
  1426. if (holodeck._pm_chime) {
  1427. dom._chime.play();
  1428. }
  1429. }
  1430. }
  1431.  
  1432. if(!CDialogue.prototype.showReceivedPM_notifier){
  1433. CDialogue.prototype.showReceivedPM_notifier = CDialogue.prototype.receivedPrivateMessage;
  1434. CDialogue.prototype.receivedPrivateMessage = function(a){
  1435. if (a.data.success && !this._user_manager.isMuted(a.data.from)) {
  1436. this.new_private_message();
  1437. }
  1438. this.showReceivedPM_notifier(a);
  1439. }
  1440. }
  1441.  
  1442. holodeck.addChatCommand("pmchime", function (l,n){
  1443. if(l._pm_chime) {
  1444. l._pm_chime = 0;
  1445. l.activeDialogue().kongBotMessage("PM chime is OFF");
  1446. } else {
  1447. l._pm_chime = 1;
  1448. l.activeDialogue().kongBotMessage("PM chime is ON");
  1449. }
  1450. window.setTimeout(function(){GM_setValue("kong_pmchime", l._pm_chime);}, 0);
  1451. return false;
  1452. });
  1453. try{
  1454. if (GM_setValue){
  1455. var pm_chime = GM_getValue("kong_pmchime", 1);
  1456. }else{
  1457. GM_setValue = function(a,b){};
  1458. var pm_chime = 1;
  1459. }
  1460. }catch(e){
  1461. GM_setValue = function(a,b){};
  1462. var pm_chime = 1;
  1463. }
  1464. holodeck._pm_chime = pm_chime;
  1465. }
  1466. }
  1467. }
  1468.  
  1469.  
  1470. //============
  1471. // PM Notifier (MrSpontaneous attribution applies
  1472. // http://userscripts.org/scripts/review/48979
  1473. //============
  1474. function init_chatResizer(){
  1475. dom.defaultWidth = 500;
  1476. dom.defaultHeight = 600;
  1477. dom.spaceLeft = 200;
  1478. dom.center = true;
  1479. dom.userListHeight = 100;
  1480.  
  1481. if(!$('maingamecontent')) return;
  1482. var initialOffsetTop = $('maingamecontent').offsetTop + $('chat_tab_pane').offsetTop;
  1483. var initialOffsetLeft = $('maingamecontent').offsetLeft + $('chat_tab_pane').offsetLeft;
  1484. var minimumHeight = parseInt($("game").style.height, 10) - parseInt($('main_tab_set').clientHeight, 10) - 16;
  1485. var minimumWidth = 300;
  1486.  
  1487. if(dom.holodeck){
  1488. var holodeck = dom.holodeck;
  1489. holodeck.addChatCommand("size", function(l, n){
  1490. var m = n.match(/^\/\S+\s+(\S+)/);
  1491. var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
  1492.  
  1493. if(m && m[1] == "reset"){
  1494. l.activeDialogue().kongBotMessage("Resetting size for this game to defaults.");
  1495. window.setTimeout(function(){GM_deleteValue("kong_resize_"+location.pathname)}, 0);
  1496. setWidth(window._defaultChatWidth);
  1497. setHeight(window._defaultChatHeight, window._defaultUserlistHeight, window._currentGameCentered);
  1498. return false;
  1499. } else if(m && m[1] == "show"){
  1500. l.activeDialogue().kongBotMessage("Current chat size: width: " + window._currentChatWidth + "px, height: " + window._currentChatHeight + "px, userlist-height: " + window._currentChatUserlistHeight + "px.");
  1501. return false;
  1502. } else if(!o){
  1503. l.activeDialogue().kongBotMessage("Please specify a width and a height: /size width height. Example: /size 500 500");
  1504. return false;
  1505. }
  1506.  
  1507. var width = parseInt(o[1], 10);
  1508. var height = parseInt(o[2], 10);
  1509. var listHeight = parseInt(o[3]||100, 10);
  1510. var gameHeight = parseInt($('game').style.height, 10);
  1511. if(width < 300){
  1512. l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
  1513. width = 300;
  1514. }
  1515.  
  1516. if(height < gameHeight){
  1517. l.activeDialogue().kongBotMessage("Minimum height is the game's height. Setting height to " + gameHeight + "px.");
  1518. height = gameHeight;
  1519. }
  1520.  
  1521. if(listHeight > height - 200){
  1522. l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
  1523. listHeight = 100;
  1524. }
  1525.  
  1526. window.setTimeout(function(){GM_setValue("kong_resize_"+location.pathname, width+"/"+height+"/"+listHeight)}, 0);
  1527. l.activeDialogue().kongBotMessage("Resizing chat to " + width + "px/" + height + "px/" + listHeight + "px");
  1528. setWidth(width);
  1529. setHeight(height, listHeight, window._currentGameCentered);
  1530.  
  1531. return false;
  1532. });
  1533.  
  1534. holodeck.addChatCommand("defaultsize", function(l, n){
  1535. var m = n.match(/^\/\S+\s+(\S+)/);
  1536. var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
  1537. if(m && m[1] == "reset"){
  1538. l.activeDialogue().kongBotMessage("Resetting default size to 500/600/100");
  1539. window.setTimeout(function(){GM_deleteValue("kong_resize_default")}, 0);
  1540.  
  1541. return false;
  1542. } else if(m && m[1] == "show"){
  1543. l.activeDialogue().kongBotMessage("Current chat size: width: " + window._defaultChatWidth + "px, height: " + window._defaultChatHeight + "px, userlist-height: " + window._defaultUserlistHeight + "px.");
  1544. return false;
  1545. } else if(!o){
  1546. l.activeDialogue().kongBotMessage("Syntax /defaultsize width height userlist-height. userlist-height is optional. Example: /defaultsize 500 500 100");
  1547. }
  1548.  
  1549. var width = parseInt(o[1], 10);
  1550. var height = parseInt(o[2], 10);
  1551. var listHeight = parseInt(o[3]||100, 10);
  1552. if(width < 300){
  1553. l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
  1554. width = 300;
  1555. }
  1556.  
  1557. if(listHeight > height){
  1558. l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
  1559. listHeight = 100;
  1560. }
  1561.  
  1562. window.setTimeout(function(){GM_setValue("kong_resize_default", width+"/"+height+"/"+listHeight)}, 0);
  1563. l.activeDialogue().kongBotMessage("Set default values to width: " + width + "px, height: " + height + "px, userlist-height: " + listHeight + "px.");
  1564.  
  1565. return false;
  1566. });
  1567.  
  1568. holodeck.addChatCommand("centergame", function(l, n){
  1569. var center = !window._currentGameCentered;
  1570. if(center){
  1571. l.activeDialogue().kongBotMessage("Now centering the game");
  1572. } else {
  1573. l.activeDialogue().kongBotMessage("Now aligning the game to the chat's bottom");
  1574. }
  1575. window.setTimeout(function(){GM_setValue("kong_resize_center", center?1:0)}, 0);
  1576.  
  1577. centerGame(center);
  1578.  
  1579. return false;
  1580. });
  1581. holodeck.addChatCommand("draggable", function(l, n){
  1582. var chatwindow = document.getElementById("chat_container");
  1583. //chatwindow.style.overflow = "auto";
  1584. chatwindow.style.resize = "both";
  1585. chatwindow.onresize = new function() {
  1586. var chatcontainer = document.getElementById("chat_window");
  1587. chatcontainer.style.width = chatwindow.style.width;
  1588. chatcontainer.style.height = chatwindow.style.height;
  1589. console.log(chatwindow.style.width);
  1590. l.activeDialogue().kongBotMessage("Chat window is now resizeable");
  1591. }
  1592. return false;
  1593. });
  1594.  
  1595. }
  1596.  
  1597. var getString = "", centerVal = -1, defaults = "";
  1598. getString = GM_getValue("kong_resize_"+location.pathname, "");
  1599. centerVal = GM_getValue("kong_resize_center", -1);
  1600. defaults = GM_getValue("kong_resize_default", "");
  1601.  
  1602. if(defaults){
  1603. var splitArr = defaults.split("/");
  1604. defaultWidth = parseInt(splitArr[0], 10)||defaultWidth;
  1605. defaultHeight = parseInt(splitArr[1], 10)||defaultHeight;
  1606. userListHeight = parseInt(splitArr[2], 10)||userListHeight;
  1607. }
  1608.  
  1609. window._defaultChatWidth = defaultWidth;
  1610. window._defaultChatHeight = defaultHeight;
  1611. window._defaultUserlistHeight = userListHeight;
  1612.  
  1613. var x = defaultWidth, y = defaultHeight, l = userListHeight, cg = center, override = false;
  1614.  
  1615. if(centerVal != -1){
  1616. cg = (centerVal == 1);
  1617. }
  1618.  
  1619. if(getString){
  1620. var splitArr = getString.split("/");
  1621. x = parseInt(splitArr[0], 10)||defaultWidth;
  1622. y = parseInt(splitArr[1], 10)||defaultHeight;
  1623. l = parseInt(splitArr[2], 10)||userListHeight;
  1624. override = true;
  1625. }
  1626.  
  1627. var gameWidth = parseInt($('game').style.width, 10);
  1628. var gameHeight = parseInt($('game').style.height, 10);
  1629.  
  1630. if(x > minimumWidth){
  1631. if(override || gameWidth + x < screen.width - spaceLeft){ // enough place to resize to specified width
  1632. setWidth(x);
  1633. }else{ // resize as far as possible
  1634. var chatWidth = screen.width - gameWidth - spaceLeft;
  1635. if(chatWidth > minimumWidth) setWidth(chatWidth);
  1636. }
  1637. }
  1638.  
  1639. if(y > minimumHeight && y > gameHeight){
  1640. setHeight(y, l, cg);
  1641. } else {
  1642. setHeight(gameHeight, l, cg);
  1643. }
  1644. }
  1645.  
  1646. function centerGame(center){
  1647. window._currentGameCentered = center;
  1648. if(center){
  1649. var gameHeight = parseInt($('game').style.height, 10);
  1650. var mainHeight = parseInt($("maingame").style.height, 10);
  1651. $('game').style.top = (mainHeight - gameHeight)/2+"px"
  1652. $('game').style.position = "relative";
  1653. }else{
  1654. $('game').style.bottom = "0px";
  1655. $('game').style.top = "";
  1656. $('game').style.position = "absolute";
  1657. }
  1658. }
  1659. function setHeight(height, userListHeight, center){
  1660. if(!userListHeight) userListHeight = 100;
  1661.  
  1662. window._currentChatHeight = height;
  1663. window._currentChatUserlistHeight = userListHeight;
  1664.  
  1665. var quicklinksHeight = $('quicklinks') ? $('quicklinks').parentNode.clientHeight : 26;
  1666. var maintabHeight = $('main_tab_set').clientHeight;
  1667.  
  1668. var tabPaneHeight = height - 16;
  1669. var mainHeight = height + quicklinksHeight + maintabHeight;
  1670. var gameHeight = parseInt($('game').style.height, 10);
  1671.  
  1672. $("maingame").style.height = mainHeight + "px";
  1673. $("maingamecontent").style.height = mainHeight + "px";
  1674. $("flashframecontent").style.height = mainHeight + "px";
  1675. $("chat_container").style.height = (height + maintabHeight) + "px";
  1676. $("user_mini_profile_container").style.height = (height - 65) + "px";
  1677. $("user_mini_profile").style.height = (height - 65) + "px";
  1678.  
  1679. var messageWindows = $$(".chat_message_window");
  1680. for(var i = 0; i < messageWindows.length; i++){
  1681. messageWindows[i].style.height = (tabPaneHeight - userListHeight - 93)+"px"; // 93 = roomname, users in room etc.
  1682. }
  1683.  
  1684. var usersInRoom = $$(".users_in_room");
  1685. for(i = 0; i < usersInRoom.length; i++){
  1686. usersInRoom[i].style.height = userListHeight + "px";
  1687. }
  1688.  
  1689. var roomsList = $$(".rooms_list");
  1690. for(i = 0; i < roomsList.length; i++){
  1691. roomsList[i].style.height = (height - 79)+"px";
  1692. }
  1693.  
  1694. z = $("kong_game_ui").childNodes;
  1695. for(i=0;i<z.length;i++){
  1696. if(z[i].nodeName=="DIV"){
  1697. z[i].style.height = tabPaneHeight + "px";
  1698. }
  1699. }
  1700. if(center != -1 && center !== undefined)
  1701. centerGame(center);
  1702. }
  1703.  
  1704. function setWidth(width){
  1705. window._currentChatWidth = width;
  1706. var gameWidth = parseInt($("game").style.width, 10);
  1707. $("maingame").style.width = (gameWidth + 3 + width) + "px";
  1708. $("maingamecontent").style.width = (gameWidth + 3 + width) + "px";
  1709. $("flashframecontent").style.width = (gameWidth + 3 + width) + "px";
  1710. $("chat_container").style.width = width + "px";
  1711. $('chat_window_spinner').style.right = width/2 - 38 + "px";
  1712. if($('high_scores_spinner'))
  1713. $('high_scores_spinner').style.right = width/2 - 38 + "px";
  1714. var ui = $("kong_game_ui");
  1715. z = ui.childNodes;
  1716. for(i=0;i<z.length;i++){
  1717. if(z[i].tagName == "DIV")
  1718. z[i].style.width = (width - 17) + "px";
  1719. }
  1720. $A(ui.querySelectorAll("textarea.chat_input")).forEach(function(el){
  1721. el.style.width = (width - 21) + "px";
  1722. });
  1723. }
  1724.  
  1725. function $A(c){
  1726. return [].slice.call(c);
  1727. }
  1728.  
  1729. //===========
  1730. // Kongquer
  1731. // http://alphaoverall.com
  1732. // by AlphaOverall (http://www.kongregate.com/accounts/AlphaOverall)
  1733. // Copyright (c) 2015 AlphaOverall
  1734. // Inspired by Kongregate Get (http://userscripts-mirror.org/scripts/review/56432)
  1735. // Full credit to Matthew Ammann and Ventero for the /avglvl and /mostplayed commands
  1736. //==========
  1737. function init_kongquer() {
  1738. if(typeof holodeck !== "undefined" && !holodeck.__urlregex){
  1739. holodeck.__urlregex = true;
  1740. }
  1741. function makeLink(user){
  1742. return '<a href="#" onclick="holodeck.showMiniProfile(\'' + user + '\'); return false;">' + user + '</a>';
  1743. }
  1744. var holodeck = dom.holodeck;
  1745. ChatDialogue = dom.ChatDialogue;
  1746. //
  1747. //Test command so you don't look stupid if script doesn't load
  1748. //
  1749. holodeck.addChatCommand("test", function(l,n){
  1750. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Script is active! Have fun...", {"class":"whisper received_whisper"}, {non_user: true});
  1751. return false;
  1752. });
  1753. //
  1754. //From original Kongregate Get script (http://userscripts-mirror.org/scripts/review/56432)
  1755. //
  1756. holodeck.addChatCommand("avg", function(l,n){
  1757. var roomDetails = l.chatWindow().activeRoom();
  1758. var allUsers = roomDetails.users();
  1759. var allLevels = 0;
  1760. for(var i=0; i < allUsers.length; i++){
  1761. allLevels += allUsers[i]._level;
  1762. }
  1763. var avgLevel = Math.round(allLevels/allUsers.length*10)/10;
  1764. l.activeDialogue().displayUnsanitizedMessage("Average Level in Room", avgLevel , {"class":"whisper received_whisper"}, {non_user: true});
  1765. return false;
  1766. });
  1767. if(holodeck && ChatDialogue && !holodeck._chat_commands.mostplayed) {
  1768. //Credit goes entirely to Ventero for this command. Thanks for fixing the command after the Kongregate update, Vent :)
  1769. holodeck.addChatCommand("mostplayed", function(l,n){
  1770. var matchArr = n.match(/\/\S+\s+(\d+)/),
  1771. dialog = l.activeDialogue(),
  1772. gamesCount = 5,
  1773. userList = dom.$A(l.chatWindow().activeRoom().users()),
  1774. usersCount = userList.length;
  1775. if(matchArr && matchArr[1]) gamesCount = matchArr[1];
  1776. function p(count){
  1777. return count == 1?"":"s";
  1778. }
  1779. var games = dom.$H();
  1780. userList.each(function(user){
  1781. console.log(user);
  1782. var o = user._game_url;
  1783. if(!games.get(o)){
  1784. games.set(o, {
  1785. title: user._game_title,
  1786. count: 0,
  1787. user: "",
  1788. url: o
  1789. });
  1790. }
  1791. games.get(o).count++;
  1792. games.get(o).user = user.username;
  1793. });
  1794.  
  1795. var countArr = games.values().sort(function(a,b){
  1796. return +b.count - +a.count;
  1797. }).slice(0, gamesCount);
  1798. var totalCount = games.size();
  1799.  
  1800. dialog.displayUnsanitizedMessage("Kong Bot", usersCount+" user"+p(usersCount)+" playing "+totalCount+" different game" + p(totalCount), {"class":"whisper received_whisper"}, {non_user: true});
  1801. dialog.displayUnsanitizedMessage("Kong Bot", gamesCount + " most played game" + p(gamesCount) + ":", {"class":"whisper received_whisper"}, {non_user: true});
  1802. countArr.each(function(obj){
  1803. dialog.displayUnsanitizedMessage("Kong Bot",
  1804. obj.count + " user" + p(obj.count) + " (" +
  1805. (obj.count > 1 ? "" : makeLink(obj.user) + ", ") +
  1806. (100*obj.count/usersCount).toFixed(1) + "%) " +
  1807. (obj.count > 1 ? "are" : "is") + ' playing <a href="' +
  1808. obj.url + '">' + obj.title + "</a>", {"class":"whisper received_whisper"}, {non_user: true});
  1809. });
  1810. return false;
  1811. });
  1812. holodeck._chat_commands.mp = holodeck._chat_commands.getmp = holodeck._chat_commands.mostplayed;
  1813. }
  1814. //
  1815. //Rest by AlphaOverall
  1816. //
  1817. holodeck.addChatCommand("highlvl", function(l,n){
  1818. var roomDetails = l.chatWindow().activeRoom();
  1819. var allUsers = roomDetails.users();
  1820. var highLevels = "";
  1821. var highestLevel = 0;
  1822. var count = 0;
  1823. for(var i=0; i < allUsers.length; i++){
  1824. if (allUsers[i]._level > highestLevel){
  1825. highestLevel = allUsers[i]._level;
  1826. highLevels = "<img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1827. count = 1;
  1828. }
  1829. else if (allUsers[i]._level == highestLevel){
  1830. highLevels = highLevels + ", <img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1831. count+=1;
  1832. }
  1833. }
  1834. l.activeDialogue().displayUnsanitizedMessage("Highest Level in Room", highestLevel + ", Usercount: " + count + ", Users: " + highLevels, {"class":"whisper received_whisper"}, {non_user: true});
  1835. return false;
  1836. });
  1837.  
  1838. holodeck.addChatCommand("lowlvl", function(l,n){
  1839. var roomDetails = l.chatWindow().activeRoom();
  1840. var allUsers = roomDetails.users();
  1841. var lowLevels = "";
  1842. var lowestLevel = Infinity; //Just to makes sure :P
  1843. var count = 0;
  1844. for(var i=0; i < allUsers.length; i++){
  1845. if (allUsers[i]._level < lowestLevel){
  1846. lowestLevel = allUsers[i]._level;
  1847. lowLevels = "<img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1848. count = 1;
  1849. }
  1850. else if (allUsers[i]._level == lowestLevel){
  1851. count+=1;
  1852. lowLevels = lowLevels + ", <img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1853. }
  1854. }
  1855. l.activeDialogue().displayUnsanitizedMessage("Lowest Level in Room", lowestLevel + ", Usercount: " + count + ", Users: " + lowLevels, {"class":"whisper received_whisper"}, {non_user: true});
  1856. return false;
  1857. });
  1858.  
  1859. holodeck.addChatCommand("list", function(l,n){
  1860. var roomDetails = l.chatWindow().activeRoom();
  1861. var allUsers = roomDetails.users();
  1862. var userList = "";
  1863. var word = n.match(/^\/\S+\s+(.+)/);
  1864. var count = 0;
  1865. if (word){
  1866. var toFind = word[1];
  1867. for(var i=0; i < allUsers.length; i++){
  1868. if (allUsers[i].username.toLowerCase().includes(toFind.toLowerCase())){
  1869. if (userList == ""){
  1870. userList = "<img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1871. count = 1;
  1872. }
  1873. else{
  1874. count+=1;
  1875. userList = userList + ", <img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1876. }
  1877. }
  1878. }
  1879. l.activeDialogue().displayUnsanitizedMessage("Usernames Containing " + word[1], "Usercount: " + count + ", Users: " + userList, {"class":"whisper received_whisper"}, {non_user: true});
  1880. }
  1881. else{
  1882. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Please use this command like " + n + " cat", {"class":"whisper received_whisper"}, {non_user: true});
  1883. }
  1884. return false;
  1885. });
  1886. holodeck.addChatCommand("levels", function(l,n){
  1887. var z = n.match(/^\/\S+\s+(.+)/);
  1888. var roomDetails = l.chatWindow().activeRoom();
  1889. var allUsers = roomDetails.users();
  1890. if (z){
  1891. var userLevels = "";
  1892. var levelCount = [];
  1893. var displaymessage = "";
  1894. if (z[1].includes("-")){
  1895. var inbetween = z[1].split("-");
  1896. console.log(inbetween[0]);
  1897. console.log(inbetween[1]);
  1898. if (inbetween[0] < inbetween[1]){
  1899. for (var a=inbetween[0]; a <= inbetween[1]; a++){
  1900. levelCount.push(a);
  1901. }
  1902. }
  1903. else{
  1904. for (var a=inbetween[1]; a <= inbetween[0]; a++){
  1905. levelCount.push(a);
  1906. }
  1907. }
  1908. displaymessage = z[1];
  1909. }
  1910. else{
  1911. var levelCount = z[1].split(" ");
  1912. displaymessage = levelCount.join(", ");
  1913. }
  1914. console.log(levelCount);
  1915. var count = 0;
  1916. for (var b=0; b <= levelCount.length; b++){
  1917. for(var i=0; i < allUsers.length; i++){
  1918. if (allUsers[i]._level == levelCount[b] && userLevels == ""){
  1919. userLevels = "<img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1920. count = 1;
  1921. }
  1922. else if (allUsers[i]._level == levelCount[b]){
  1923. count+=1;
  1924. userLevels = userLevels + ", <img src=\"" + allUsers[i]._chat_avatar_url + "\">" + makeLink(allUsers[i].username);
  1925. }
  1926. }
  1927.  
  1928. }
  1929. l.activeDialogue().displayUnsanitizedMessage("Level " + displaymessage, "Usercount: " + count + ", Users: " + userLevels, {"class":"whisper received_whisper"}, {non_user: true});
  1930. return false;
  1931. }
  1932. else{
  1933. var levelsList = [l._active_user._attributes._object.level];
  1934. for(var j=0; j < allUsers.length; j++){
  1935. for (var k=0; k <= allUsers[j]._level; k++){
  1936. if (allUsers[j]._level == k){
  1937. if (levelsList.indexOf(k) < 0){
  1938. levelsList.push(k);
  1939. }
  1940. }
  1941. }
  1942. }
  1943. levelsList.sort(function(a, b){return a-b});
  1944. l.activeDialogue().displayUnsanitizedMessage("Levels", levelsList.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  1945. return false;
  1946. }
  1947. });
  1948.  
  1949. holodeck.addChatCommand("highfans", function(l,n){
  1950. var roomDetails = l.chatWindow().activeRoom();
  1951. var allUsers = roomDetails.users();
  1952. var highFans = "";
  1953. var highestFans = 0;
  1954. var count = 0;
  1955. var content;
  1956. for(var i=0; i < allUsers.length; i++){
  1957. var username = allUsers[i].username;
  1958. var url = "http://www.kongregate.com/accounts/" + username +"#user_followers";
  1959. var request = new XMLHttpRequest();
  1960. var amount;
  1961. request.addEventListener("load", function(evt){
  1962. amount = evt.responseText;
  1963. }, false);
  1964.  
  1965. request.open("GET", url, true);
  1966. request.send();
  1967. var div = document.createElement("div");
  1968. div.innerHTML = amount;
  1969. var a = div.getElementsByTagName("li");
  1970. for (var i = 0, len = a.length; i < len; i++){
  1971. if (a[i].textContent.includes("fans"))
  1972. {
  1973. console.log(a[i]);
  1974. }
  1975. else { console.log(a[i] + "hahah");}
  1976. }
  1977. }
  1978. l.activeDialogue().displayUnsanitizedMessage("Highest Fans in Room", content, {"class":"whisper received_whisper"}, {non_user: true});
  1979. return false;
  1980. });
  1981. holodeck.addChatCommand("developer", function(l,n){
  1982. var roomDetails = l.chatWindow().activeRoom();
  1983. var allUsers = roomDetails.users();
  1984. var devs = [];
  1985. for(var i=0; i < allUsers.length; i++){
  1986. if (allUsers[i]._developer){
  1987. devs.push(makeLink(allUsers[i].username));
  1988. }
  1989. }
  1990. l.activeDialogue().displayUnsanitizedMessage("Developers in room", devs.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  1991. return false;
  1992. });
  1993.  
  1994. holodeck.addChatCommand("admin", function(l,n){
  1995. var roomDetails = l.chatWindow().activeRoom();
  1996. var allUsers = roomDetails.users();
  1997. var admins = [];
  1998. for(var i=0; i < allUsers.length; i++){
  1999. if (allUsers[i]._admin){
  2000. admins.push(makeLink(allUsers[i].username));
  2001. }
  2002. }
  2003. l.activeDialogue().displayUnsanitizedMessage("Admins in room", admins.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  2004. return false;
  2005. });
  2006.  
  2007. holodeck.addChatCommand("moderator", function(l,n){
  2008. var roomDetails = l.chatWindow().activeRoom();
  2009. var allUsers = roomDetails.users();
  2010. var mods = [];
  2011. for(var i=0; i < allUsers.length; i++){
  2012. if (allUsers[i]._moderator_room_ids.length > 0 || allUsers[i]._moderator_game_ids.length > 0){
  2013. mods.push(allUsers[i].username);
  2014. }
  2015. }
  2016. l.activeDialogue().displayUnsanitizedMessage("Mods in room", mods.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  2017. return false;
  2018. });
  2019.  
  2020. //Simple commands that will show up in user info also
  2021. holodeck.addChatCommand("id", function(l,n){
  2022. var user = l._active_user._attributes._object;
  2023. l.activeDialogue().displayUnsanitizedMessage("ID", user.id, {"class":"whisper received_whisper"}, {non_user: true});
  2024. return false;
  2025. });
  2026.  
  2027. holodeck.addChatCommand("username", function(l,n){
  2028. var user = l._active_user._attributes._object;
  2029. l.activeDialogue().displayUnsanitizedMessage("Username", makeLink(user.username), {"class":"whisper received_whisper"}, {non_user: true});
  2030. return false;
  2031. });
  2032.  
  2033. holodeck.addChatCommand("kreds", function(l,n){
  2034. var user = l._active_user._attributes._object;
  2035. l.activeDialogue().displayUnsanitizedMessage("Kreds", user.kreds_balance, {"class":"whisper received_whisper"}, {non_user: true});
  2036. return false;
  2037. });
  2038. holodeck.addChatCommand("level", function(l,n){
  2039. var user = l._active_user._attributes._object;
  2040. l.activeDialogue().displayUnsanitizedMessage("Level", user.level, {"class":"whisper received_whisper"}, {non_user: true});
  2041. return false;
  2042. });
  2043.  
  2044. holodeck.addChatCommand("age", function(l,n){
  2045. var user = l._active_user._attributes._object;
  2046. l.activeDialogue().displayUnsanitizedMessage("Age", user.age, {"class":"whisper received_whisper"}, {non_user: true});
  2047. return false;
  2048. });
  2049. holodeck.addChatCommand("email", function(l,n){
  2050. var user = l._active_user._attributes._object;
  2051. l.activeDialogue().displayUnsanitizedMessage("Name/Email", user.sender_name_or_email, {"class":"whisper received_whisper"}, {non_user: true});
  2052. return false;
  2053. });
  2054.  
  2055. holodeck.addChatCommand("user", function(l,n){
  2056. var z = n.match(/^\/\S+\s+(.+)/);
  2057. if (z){
  2058. var roomDetails = l.chatWindow().activeRoom();
  2059. var allUsers = roomDetails.users();
  2060. for(var i=0; i < allUsers.length; i++){
  2061. if (i == allUsers.length-1 && allUsers[i].username != z[1]){
  2062. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "User not in chat... Opening mini profile", {"class":"whisper received_whisper"}, {non_user: true});
  2063. holodeck.showMiniProfile(z[1]);
  2064. return false;
  2065. }
  2066. if (allUsers[i].username == z[1]){
  2067. var user = allUsers[i];
  2068. l.activeDialogue().displayUnsanitizedMessage("Username", "<img src=\""+user._chat_avatar_url+"\"></img>" + makeLink(user.username), {"class":"whisper received_whisper"}, {non_user: true});
  2069. l.activeDialogue().displayUnsanitizedMessage("Level", user._level, {"class":"whisper received_whisper"}, {non_user: true});
  2070. if (user._moderator_room_ids.length == 0 && user._moderator_game_ids.length == 0){
  2071. l.activeDialogue().displayUnsanitizedMessage("Admin/Moderator/Developer/Premium",user._admin+"/false/"+user._developer+"/"+user._premium, {"class":"whisper received_whisper"}, {non_user: true});
  2072. }
  2073. else{
  2074. l.activeDialogue().displayUnsanitizedMessage("Admin/Moderator/Developer/Premium",user._admin+"/true/"+user._developer+"/"+user._premium, {"class":"whisper received_whisper"}, {non_user: true});
  2075. if (!user._admin) {
  2076. l.activeDialogue().displayUnsanitizedMessage("Moderator Game Ids", user._moderator_game_ids.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  2077. l.activeDialogue().displayUnsanitizedMessage("Moderator Room Ids", user._moderator_room_ids.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  2078. }
  2079. }
  2080. l.activeDialogue().displayUnsanitizedMessage("Playing", "<a href=\"http://www.kongregate.com" + user._game_url + "\" target=\"_blank\">" + user._game_title + "</a>", {"class":"whisper received_whisper"}, {non_user: true});
  2081. l.activeDialogue().displayUnsanitizedMessage("Presence", user._presence, {"class":"whisper received_whisper"}, {non_user: true});
  2082. l.activeDialogue().displayUnsanitizedMessage("Role", user._role, {"class":"whisper received_whisper"}, {non_user: true});
  2083. return false;
  2084. }
  2085. }
  2086. }
  2087. else {
  2088. var user = l._active_user._attributes._object;
  2089. l.activeDialogue().displayUnsanitizedMessage("Username", "<img src=\""+user.avatar_url+"\">" + makeLink(user.username), {"class":"whisper received_whisper"}, {non_user: true});
  2090. l.activeDialogue().displayUnsanitizedMessage("Age", user.age, {"class":"whisper received_whisper"}, {non_user: true});
  2091. l.activeDialogue().displayUnsanitizedMessage("Admin/Moderator/Developer/Premium",user.admin+"/"+user.moderator+"/"+user.developer+"/"+user.premium, {"class":"whisper received_whisper"}, {non_user: true});
  2092. l.activeDialogue().displayUnsanitizedMessage("ID", user.id, {"class":"whisper received_whisper"}, {non_user: true});
  2093. l.activeDialogue().displayUnsanitizedMessage("Level", user.level, {"class":"whisper received_whisper"}, {non_user: true});
  2094. l.activeDialogue().displayUnsanitizedMessage("Points for Next Level", user.points_away, {"class":"whisper received_whisper"}, {non_user: true});
  2095. l.activeDialogue().displayUnsanitizedMessage("Total Points", user.points, {"class":"whisper received_whisper"}, {non_user: true});
  2096. l.activeDialogue().displayUnsanitizedMessage("Last Level Up", user.last_levelup_at, {"class":"whisper received_whisper"}, {non_user: true});
  2097. l.activeDialogue().displayUnsanitizedMessage("Kreds", user.kreds_balance, {"class":"whisper received_whisper"}, {non_user: true});
  2098. l.activeDialogue().displayUnsanitizedMessage("Gameplays", user.gameplays_count, {"class":"whisper received_whisper"}, {non_user: true});
  2099. l.activeDialogue().displayUnsanitizedMessage("Game Ratings", user.ratings_count, {"class":"whisper received_whisper"}, {non_user: true});
  2100. l.activeDialogue().displayUnsanitizedMessage("BOTD Earned This Week", user.botds_this_week, {"class":"whisper received_whisper"}, {non_user: true});
  2101. l.activeDialogue().displayUnsanitizedMessage("Name/Email", user.sender_name_or_email, {"class":"whisper received_whisper"}, {non_user: true});
  2102. return false;
  2103. }
  2104. });
  2105.  
  2106. holodeck.addChatCommand("available", function(l,n){
  2107. var z = n.match(/^\/\S+\s+(.+)/);
  2108. if (z){
  2109. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Availability of " + z[1] + ":<iframe src=\"httP://www.kongregate.com/accounts/availability?username=" + z[1] + "\" width=\"100%\" height=\"30\"></iframe>", {"class":"whisper received_whisper"}, {non_user: true});
  2110. }
  2111. return false;
  2112. });
  2113.  
  2114. holodeck.addChatCommand("info", function(l,n){
  2115. var info = l._chat_window._active_room;
  2116. var room = info._room;
  2117. l.activeDialogue().displayUnsanitizedMessage("Room Name", room.name, {"class":"whisper received_whisper"}, {non_user: true});
  2118. l.activeDialogue().displayUnsanitizedMessage("Room ID", room.id, {"class":"whisper received_whisper"}, {non_user: true});
  2119. l.activeDialogue().displayUnsanitizedMessage("Room Owner", "<a href=\"http://www.kongregate.com/accounts/" + room.owner + "\" target=\"_blank\">" + room.owner + "</a>", {"class":"whisper received_whisper"}, {non_user: true});
  2120. l.activeDialogue().displayUnsanitizedMessage("Room Type", room.type, {"class":"whisper received_whisper"}, {non_user: true});
  2121. l.activeDialogue().displayUnsanitizedMessage("Favorite Room", info._favorite_room, {"class":"whisper received_whisper"}, {non_user: true});
  2122. l.activeDialogue().displayUnsanitizedMessage("Users In Room", info._number_in_room_node.innerText, {"class":"whisper received_whisper"}, {non_user: true});
  2123. l.activeDialogue().displayUnsanitizedMessage("Guests In Room", info._guests_in_room_node.innerText, {"class":"whisper received_whisper"}, {non_user: true});
  2124. return false;
  2125. });
  2126.  
  2127. holodeck.addChatCommand("botd", function(l,n){
  2128. var kbotd = l._active_user._attributes._object;
  2129. var typeOf = "(easy)";
  2130. if (kbotd.botd_reward_points == 5){//Do nothing
  2131. }
  2132. else if (kbotd.botd_reward_points == 15) {typeOf = "(medium)";}
  2133. else if (kbotd.botd_reward_points == 30){typeOf = "(hard)";}
  2134. else if (kbotd.botd_reward_points == 60){typeOf = "(impossible)";}
  2135. else {typeOf = "Points: " + kbotd.botd_reward_points;} //Just in case
  2136. l.activeDialogue().displayUnsanitizedMessage("BOTD", "<img src=\""+kbotd.botd_icon_uri+"\"></img>" + "<a href=\"" + kbotd.botd_game_uri + "\" target=\"_blank\">" + kbotd.botd_game_name + " - " + kbotd.botd_description + "</a> " + typeOf, {"class":"whisper received_whisper"}, {non_user: true});
  2137. return false;
  2138. });
  2139.  
  2140. holodeck.addChatCommand("friends", function(l,n){
  2141. var kongfriends = l._chat_window._friends;
  2142. var final = [];
  2143. for(var friend in kongfriends){
  2144. final.push("<a href=\"http://www.kongregate.com/accounts/" + friend + "\" target=\"_blank\">" + friend + "</a>");
  2145. }
  2146. l.activeDialogue().displayUnsanitizedMessage("Friends", final.join(", "), {"class":"whisper received_whisper"}, {non_user: true});
  2147. return false;
  2148. });
  2149.  
  2150. holodeck.addChatCommand("online", function(l,n){
  2151. holodeck._chat_window.showOnlineFriends();
  2152. return false;
  2153. });
  2154.  
  2155. holodeck.addChatCommand("exit", function(l,n){
  2156. close();
  2157. return false;
  2158. });
  2159.  
  2160. holodeck.addChatCommand("open", function(l,n){
  2161. var z = n.match(/^\/\S+\s+(.+)/);
  2162. if (z[1]) {
  2163. m = z[1].split(" ");
  2164. if (m[0] == "accounts"){
  2165. if (m[1]){
  2166. open("http://www.kongregate.com/accounts/" + m[1], "_blank");
  2167. }
  2168. else{
  2169. open("http://www.kongregate.com/accounts/" + l._active_user._attributes._object.username);
  2170. }
  2171. }
  2172. else if (m[0] == "games"){
  2173. if (m[1]) {
  2174. if (m[2]){
  2175. open("http://www.kongregate.com/games/" + m[1] + "/" + m[2], "_blank");
  2176. }
  2177. else{
  2178. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "No specified game", {"class":"whisper received_whisper"}, {non_user: true});
  2179. }
  2180. }
  2181. else{
  2182. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "No specified game creator", {"class":"whisper received_whisper"}, {non_user: true});
  2183. }
  2184. }
  2185. else {
  2186. open("http://www.kongregate.com/search?q=" + z[1], "_blank");
  2187. }
  2188. }
  2189. else {
  2190. open("http://www.kongregate.com/accounts/" + l._active_user._attributes._object.username);
  2191. }
  2192. return false;
  2193. });
  2194.  
  2195. holodeck.addChatCommand("khelp", function(l,n){
  2196. open("http://www.kongregate.com/pages/help", "_blank");
  2197. return false;
  2198. });
  2199.  
  2200. holodeck.addChatCommand("kong", function(l,n){
  2201. open("http://www.kongregate.com", "_blank");
  2202. return false;
  2203. });
  2204. holodeck.addChatCommand("help", function(l,n){
  2205. open("http://www.alphaoverall.com", "_blank");
  2206. return false;
  2207. });
  2208. holodeck.addChatCommand("signup", function(l,n){
  2209. lightbox.prototype.initializeKongregateLightboxFromAjax('/accounts/new/behind_login?game_id=' + active_user.gameId(), { afterStaticContentLoad:lightbox.prototype.toggleRegistration });
  2210. return false;
  2211. });
  2212. holodeck.addChatCommand("login", function(l,n){
  2213. active_user.activateInlineLogin();
  2214. return false;
  2215. });
  2216. holodeck.addChatCommand("signout", function(l,n){
  2217. signoutFromSite();
  2218. return false;
  2219. });
  2220. holodeck.addChatCommand("google", function(l,n){
  2221. var z = n.match(/^\/\S+\s+(.+)/);
  2222. if (z) {
  2223. open("https://www.google.com/search?q=" + z[1], "_blank");
  2224. }
  2225. else {
  2226. open("https://www.google.com", "_blank");
  2227. }
  2228. return false;
  2229. });
  2230. holodeck.addChatCommand("bing", function(l,n){
  2231. var z = n.match(/^\/\S+\s+(.+)/);
  2232. if (z) {
  2233. open("https://www.bing.com/search?q=" + z[1], "_blank");
  2234. }
  2235. else {
  2236. open("https://www.bing.com", "_blank");
  2237. }
  2238. return false;
  2239. });
  2240. holodeck.addChatCommand("yahoo", function(l,n){
  2241. var z = n.match(/^\/\S+\s+(.+)/);
  2242. if (z) {
  2243. open("https://search.yahoo.com/search;_ylt=Aq7xBwaF.DQZx151DcVK87ybvZx4?p=" + z[1], "_blank");
  2244. }
  2245. else {
  2246. open("https://www.yahoo.com", "_blank");
  2247. }
  2248. return false;
  2249. });
  2250. holodeck.addChatCommand("wikipedia", function(l,n){
  2251. var z = n.match(/^\/\S+\s+(.+)/);
  2252. if (z) {
  2253. open("https://en.wikipedia.org/wiki/" + z[1].replace(" ", "_"), "_blank");
  2254. }
  2255. else {
  2256. open("https://en.wikipedia.org/", "_blank");
  2257. }
  2258. return false;
  2259. });
  2260. holodeck.addChatCommand("url", function(l,n){
  2261. var z = n.match(/^\/\S+\s+(.+)/);
  2262. if (z) {
  2263. if (!z[1].includes("http://") && !z[1].includes("https://")){
  2264. open("http://"+z[1], "_blank");
  2265. }
  2266. else {
  2267. open(z[1], "_blank");
  2268. }
  2269. }
  2270. else {
  2271. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Please use command like " + n + " https://www.google.com", {"class":"whisper received_whisper"}, {non_user: true});
  2272. }
  2273. return false;
  2274. });
  2275.  
  2276. holodeck.addChatCommand("calculator", function(l,n){
  2277. var z = n.match(/^\/\S+\s+(.+)/);
  2278. var output = "Nothing happened";
  2279. if (z) {
  2280. /*jshint multistr: true */
  2281. if (z[1] == "help"){
  2282. l.activeDialogue().displayUnsanitizedMessage("Math Commands", "+,-,*,<br>Math.abs(a) = absolute value of a<br>Math.acos(a) = arc cosine of a<br>\
  2283. Math.asin(a) = arc sine of a<br>Math.atan(a) = arc tangent of a<br>Math.atan2(a,b) = arc tangent of a/b<br>Math.ceil(a) = integer closest to a and not less than a<br>\
  2284. Math.cos(a) = cosine of a<br>Math.exp(a) = exponent of a (Math.E to the power a)<br>Math.floor(a) = integer closest to a, not greater than a<br>Math.log(a) = log of a base e<br>\
  2285. Math.max(a,b) = the maximum of a and b<br>Math.min(a,b) = the minimum of a and b<br>Math.pow(a,b) = a to the power b<br>Math.random() = pseudorandom number 0 to 1<br>\
  2286. Math.round(a) = integer closest to a <br> Math.sin(a) = sine of a<br>Math.sqrt(a) = square root of a<br>Math.tan(a) = tangent of a", {"class":"whisper received_whisper"}, {non_user: true});
  2287. }
  2288. else{
  2289. try {
  2290. output = eval(z[1]); //I know, I know, eval is evil
  2291. l.activeDialogue().displayUnsanitizedMessage("Calculation", z[1] + " = " + output, {"class":"whisper received_whisper"}, {non_user: true});
  2292. }
  2293. catch (err){
  2294. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", err, {"class":"whisper received_whisper"}, {non_user: true});
  2295. }
  2296. }
  2297. }
  2298. else {
  2299. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "Please use command like " + n + " 4+3-8*9/3^.5", {"class":"whisper received_whisper"}, {non_user: true});
  2300. }
  2301. console.log(output);
  2302. return false;
  2303. });
  2304. holodeck.addChatCommand("youtube", function(l,n){
  2305. var z = n.match(/^\/\S+\s+(.+)/);
  2306. if (z) {
  2307. var m = z[1].split(" ");
  2308. if (m[0] == "embed"){
  2309. var chatWindow = document.getElementsByClassName("chat_message_window");
  2310. var chatWin;
  2311. if (chatWindow[2] != undefined && chatWindow[2].offsetHeight > chatWindow[1].offsetHeight){
  2312. chatWin = chatWindow[2];
  2313. }
  2314. else {
  2315. chatWin = chatWindow[1];
  2316. }
  2317. var h = chatWin.offsetHeight;
  2318. if (chatWin.offsetWidth > chatWin.offsetHeight) {
  2319. h = chatWin.offsetHeight;
  2320. }
  2321. else{
  2322. h = chatWin.offsetWidth*9/16; //YouTube 16:9 aspect ratio
  2323. }
  2324. if (m[1].includes("youtu.be/")){
  2325. l.activeDialogue().displayUnsanitizedMessage("YouTube", "<iframe src=\"https://www.youtube.com/embed/" + m[1].split("youtu.be/")[1] + "\" width=\"100%\" height=\"" + h +"\"></iframe>", {"class":"whisper received_whisper"}, {non_user: true});
  2326. }
  2327. else if (m[1].includes("youtube.com/watch?v=")){
  2328. l.activeDialogue().displayUnsanitizedMessage("YouTube", "<iframe src=\"https://www.youtube.com/embed/" + m[1].split("youtube.com/watch?v=")[1] + "\" width=\"100%\" height=\"" + h + "\"></iframe>", {"class":"whisper received_whisper"}, {non_user: true});
  2329. }
  2330. else{
  2331. l.activeDialogue().displayUnsanitizedMessage("YouTube", "Invalid YouTube video url", {"class":"whisper received_whisper"}, {non_user: true});
  2332. }
  2333. }
  2334. else {
  2335. open("https://www.youtube.com/results?search_query=" + z[1], "_blank");
  2336. }
  2337. }
  2338. else {
  2339. open("https://www.youtube.com", "_blank");
  2340. }
  2341. return false;
  2342. });
  2343. holodeck.addChatCommand("mp3", function(l,n){
  2344. var z = n.match(/^\/\S+\s+(.+)/);
  2345. if (z[1].includes(".mp3")) {
  2346. l.activeDialogue().displayUnsanitizedMessage("MP3 Container", "<audio src=\"" + z[1] + "\" controls><embed src=\"" + z[1] + "\" width=\"100%\" height=\"90\" loop=\"false\" autostart=\"true\"/>" +
  2347. "</audio>", {"class":"whisper received_whisper"}, {non_user: true});
  2348. }
  2349. else {
  2350. l.activeDialogue().displayUnsanitizedMessage("MP3 Container", "Invalid mp3 url", {"class":"whisper received_whisper"}, {non_user: true});
  2351. }
  2352. return false;
  2353. });
  2354. holodeck.addChatCommand("img", function(l,n){
  2355. var z = n.match(/^\/\S+\s+(.+)/);
  2356. if (z[1].includes(".jpg")||z[1].includes(".jpeg")||z[1].includes(".png")||z[1].includes(".gif")||z[1].includes(".bmp")) {
  2357. l.activeDialogue().displayUnsanitizedMessage("IMG Container", "<img src=\"" + z[1] + "\" style=\"max-width:100%; max-height:100%;\"/>", {"class":"whisper received_whisper"}, {non_user: true});
  2358. }
  2359. else {
  2360. l.activeDialogue().displayUnsanitizedMessage("IMG Container", "Invalid img url", {"class":"whisper received_whisper"}, {non_user: true});
  2361. }
  2362. return false;
  2363. });
  2364. holodeck.addChatCommand("time", function(l,n){
  2365. var today = new Date();
  2366. var format = today.getDate() + "/" + (today.getMonth()+1) + "/" + today.getFullYear() + ", " + today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  2367. l.activeDialogue().displayUnsanitizedMessage("Date/Time", format, {"class":"whisper received_whisper"}, {non_user: true});
  2368. return false;
  2369. });
  2370. holodeck.addChatCommand("reload", function(l,n){
  2371. location.reload();
  2372. return false;
  2373. });
  2374. holodeck.addChatCommand("reloadgame", function(l,n){
  2375. activateGame(); // Default function on Kongregate to reload/activate game
  2376. return false;
  2377. });
  2378. holodeck.addChatCommand("removegame", function(l, n) {
  2379. try {
  2380. var gametd = document.getElementById("gameholder");
  2381. gametd.parentNode.removeChild(gametd);
  2382. var width = document.getElementById("chat_container").offsetWidth;
  2383. width = (width > 550 ? width + 5 : 570) + "px";
  2384. console.log("Resizing containers to " + width);
  2385. document.getElementById("flashframecontent").style.width = width;
  2386. document.getElementById("maingamecontent").style.width = width;
  2387. var maingame = document.getElementById("maingame");
  2388. maingame.style.width = width;
  2389. maingame.style.height = (parseInt(maingame.style.height) + 5) + "px";
  2390. }
  2391. catch (e) {
  2392. l.activeDialogue().displayUnsanitizedMessage("Kong Bot", "No Game Found / Could not resize", {"class":"whisper received_whisper"}, {non_user: true});
  2393. }
  2394. return false;
  2395. });
  2396. holodeck.addChatCommand("clear", function(l,n){
  2397. holodeck._active_dialogue.clear();
  2398. return false;
  2399. });
  2400. holodeck.addChatCommand("report", function(l,n){
  2401. var z = n.match(/^\/\S+\s+(.+)/);
  2402. if (z) {
  2403. m = z[1].split(" ");
  2404. if (m[0] == "help"){
  2405. l.activeDialogue().displayUnsanitizedMessage("Report Help", "To report someone, type /report username message, or just /report username. Both cases will bring up the report box in chat.", {"class":"whisper received_whisper"}, {non_user: true});
  2406. }
  2407. else if (m[0] == null){
  2408. l.activeDialogue().displayUnsanitizedMessage("Report", "Invalid report format", {"class":"whisper received_whisper"}, {non_user: true});
  2409. }
  2410. else {
  2411. var message;
  2412. if (m[1] != undefined) {
  2413. var m2 = m.join(" ");
  2414. message = m2.substr(m2.indexOf(' ')+1);
  2415. }
  2416. else { message = "";}
  2417. active_room.showChatNag(' ' +
  2418. '<div id="new_abuse_report" class="mvm mrl"><div id="abuse_form_internal" class="cntrBasic pam">' +
  2419. '<form accept-charset="UTF-8" action="http://www.kongregate.com/accounts/' + m[0] + '/abuse_reports" method="post" onsubmit="new Ajax.Request(\'http://www.kongregate.com/accounts/aidansos132231/abuse_reports\', {asynchronous:true, evalScripts:true, method:\'post\', parameters:Form.serialize(this)}); return false;"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="ub9xDEoiIi+lRAPWsUL2yApjKAbA2XKTjRO/taF1zwE="></div>' +
  2420. '<dl>' +
  2421. '<dd class="report_options"><select id="select_type" label="Abuse Type" name="type" onchange="subjectChanged(\'' + m[0] + '\')">' +
  2422. '<option value="InappropriateUsernameReport">Inappropriate Username</option>' +
  2423. '<option value="InappropriateAvatarReport">Inappropriate Avatar</option>' +
  2424. '<option value="InappropriateProfileReport">Offensive Profile Content</option>' +
  2425. '<option selected="selected" value="InappropriateChatReport">Chat Behavior</option>' +
  2426. '<option value="OtherAbuseReport">Other</option></select></dd>' +
  2427. '<div id="description_field">' +
  2428. '<dd class="form_block" id="abuse_report_description_block">' +
  2429. '<dl>' +
  2430. '<span class="error_block error" id="abuse_report_description_error_block">' +
  2431. '</span>' +
  2432. '<dd class="label_block" id="abuse_report_description_label_block">' +
  2433. '<label for="abuse_report_description" id="abuse_report_description_label">Please describe your reason for reporting ' + m[0] + ' using as much detail as possible. We don\'t need chat logs:</label>' +
  2434. '</dd>' +
  2435. '<dd id="abuse_report_description_control_block" class="input_block"><textarea cols="55" id="abuse_report_description" name="abuse_report[description]" rows="4">' + message + '</textarea></dd>' +
  2436. '</dl>' +
  2437. '</dd>' +
  2438.  
  2439. '</div>' +
  2440. '</dl>' +
  2441.  
  2442. '<p class="report_submission">' +
  2443. '<input class="submission_button" id="abuse_form_submit" onclick="try{}catch(e){};if(!this.elem_abuse_form_submit){this.elem_abuse_form_submit=$(\'abuse_form_submit\');this.spin_abuse_form_submit=$(\'abuse_form_submit_spinner\');this.restore=function(t){return function(){t.elem_abuse_form_submit.show();t.spin_abuse_form_submit.hide();Event.stopObserving(window, \'unload\', t.restore);}}(this);}this.elem_abuse_form_submit.hide();this.spin_abuse_form_submit.show();Event.observe(window, \'unload\', this.restore);" type="submit" value="submit"><span class="spinner" id="abuse_form_submit_spinner" style="display:none" title="loading…">​</span>' +
  2444. '<a href="#" onclick="$(\'abuse_form_internal\').remove(); return false;">cancel</a>' +
  2445. '</p>' +
  2446. '</form></div>' +
  2447. '</div>', {"class":"whisper received_whisper"}, {non_user: true});
  2448. }
  2449. }
  2450. return false;
  2451. });
  2452. holodeck.addChatCommand("cry", function(l,n){
  2453. l.activeDialogue().displayUnsanitizedMessage("You're sad!", "( -̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥᷄◞ω◟-̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥̥᷅ )", {"class":"whisper received_whisper"}, {non_user: true});
  2454. return false;
  2455. });
  2456. holodeck._chat_commands.wiki = holodeck._chat_commands.wikipedia;
  2457. holodeck._chat_commands.weep = holodeck._chat_commands.krie = holodeck._chat_commands.cry;
  2458. holodeck._chat_commands.lol = holodeck._chat_commands.hi = holodeck._chat_commands.hmm = holodeck._chat_commands.test;
  2459. holodeck._chat_commands.userlist = holodeck._chat_commands.username = holodeck._chat_commands.list;
  2460. holodeck._chat_commands.date = holodeck._chat_commands.datetime = holodeck._chat_commands.now = holodeck._chat_commands.time;
  2461. holodeck._chat_commands.math = holodeck._chat_commands.calc = holodeck._chat_commands.calculator;
  2462. holodeck._chat_commands.goto = holodeck._chat_commands.http = holodeck._chat_commands.www = holodeck._chat_commands.url;
  2463. holodeck._chat_commands.lvl = holodeck._chat_commands.level;
  2464. holodeck._chat_commands.konghelp = holodeck._chat_commands.kongregatehelp = holodeck._chat_commands.khelp;
  2465. holodeck._chat_commands.kongregate = holodeck._chat_commands.kong;
  2466. holodeck._chat_commands.avglvl = holodeck._chat_commands.alvl = holodeck._chat_commands.avg;
  2467. holodeck._chat_commands.close = holodeck._chat_commands.exit;
  2468. holodeck._chat_commands.roominfo = holodeck._chat_commands.info;
  2469. holodeck._chat_commands.friendsonline = holodeck._chat_commands.online;
  2470. holodeck._chat_commands.u = holodeck._chat_commands.me = holodeck._chat_commands.user;
  2471. holodeck._chat_commands.admins = holodeck._chat_commands.administrator = holodeck._chat_commands.administrators = holodeck._chat_commands.admin;
  2472. holodeck._chat_commands.dev = holodeck._chat_commands.devs = holodeck._chat_commands.developers = holodeck._chat_commands.developer;
  2473. holodeck._chat_commands.mod = holodeck._chat_commands.mods = holodeck._chat_commands.moderators = holodeck._chat_commands.moderator;
  2474. holodeck._chat_commands.hlvl = holodeck._chat_commands.highlevel = holodeck._chat_commands.hlevel = holodeck._chat_commands.highlvl;
  2475. holodeck._chat_commands.llvl = holodeck._chat_commands.lowlevel = holodeck._chat_commands.llevel = holodeck._chat_commands.lowlvl;
  2476. holodeck._chat_commands.mp = holodeck._chat_commands.getmp = holodeck._chat_commands.mostplayed;
  2477. }
  2478. }
  2479.  
  2480.  
  2481. // This injects our script onto the page.
  2482. // Kinda borrowed from http://userscripts.org/scripts/review/125666
  2483. // Borrowed from: http://stackoverflow.com/a/2303228
  2484. var script = document.createElement('script');
  2485. script.appendChild(document.createTextNode('('+ main +')();'));
  2486. (document.body || document.head || document.documentElement).appendChild(script);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址