Greasy Fork is available in English.

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
  5. // @version 0.61
  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.  
  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.  
  24.  
  25.  
  26. // This portion of attribution only applies to code written or modified based on MrSpontaneous' implementation
  27. // Written by MrSpontaneous (http://www.kongregate.com/accounts/MrSpontaneous) 01/03/2010
  28.  
  29.  
  30.  
  31.  
  32. //This portion of attribution only applies to code written or modified based on skyboy's implementation.
  33. /**
  34. *
  35. * Assorted Userscripts by skyboy.
  36. * Visit http://github.com/skyboy for documentation, updates
  37. * and more free code.
  38. *
  39. *
  40. * Copyright (c) 2010, skyboy
  41. * All rights reserved.
  42. *
  43. * Permission is hereby granted, free of charge, to any person
  44. * obtaining a copy of this software and associated documentation
  45. * files (the "Software"), to deal in the Software with
  46. * restriction, with limitation the rights to use, copy, modify,
  47. * merge, publish, distribute, sublicense copies of the Software,
  48. * and to permit persons to whom the Software is furnished to do so,
  49. * subject to the following conditions and limitations:
  50. *
  51. * ^ Attribution will be given to:
  52. * skyboy, http://www.kongregate.com/accounts/skyboy;
  53. * http://github.com/skyboy; http://skybov.deviantart.com
  54. *
  55. * ^ Redistributions of source code must retain the above copyright notice,
  56. * this list of conditions and the following disclaimer in all copies or
  57. * substantial portions of the Software.
  58. *
  59. * ^ Redistributions of modified source code must be marked as such, with
  60. * the modifications marked and ducumented and the modifer's name clearly
  61. * listed as having modified the source code.
  62. *
  63. * ^ Redistributions of source code may not add to, subtract from, or in
  64. * any other way modify the above copyright notice, this list of conditions,
  65. * or the following disclaimer for any reason.
  66. *
  67. * ^ Redistributions in binary form must reproduce the above copyright
  68. * notice, this list of conditions and the following disclaimer in the
  69. * documentation and/or other materials provided with the distribution.
  70. *
  71. * THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  72. * IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
  73. * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  74. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  75. * OR COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DIRECT,
  76. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  77. * OR OTHER LIABILITY,(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  78. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  79. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  80. * WHETHER AN ACTION OF IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  81. * NEGLIGENCE OR OTHERWISE) ARISING FROM, OUT OF, IN CONNECTION OR
  82. * IN ANY OTHER WAY OUT OF THE USE OF OR OTHER DEALINGS WITH THIS
  83. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  84. */
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. function main()
  92. {
  93. console.log("KongOne Script running.");
  94. var dom = (typeof unsafeWindow === "undefined"?window:unsafeWindow);
  95. dom.oneScriptVersion = "1.101";
  96.  
  97.  
  98.  
  99. init();
  100. function init()
  101. {
  102. if(typeof GM_setValue === 'undefined'){
  103. window.GM_setValue = function(a,b){localStorage.setItem(a,b)}
  104. window.GM_getValue = function(a,b){var r=localStorage.getItem(a);return (r==null?b:r)}
  105. window.GM_deleteValue = function(a){localStorage.removeItem(a)}
  106. }
  107.  
  108. var url = dom.location.href;
  109. url = url.substr(url.indexOf(".com/") + ".com/".length);
  110.  
  111. if(url.indexOf("/") != -1)
  112. oneDirectory = url.substring(0,url.indexOf("/"));
  113. else
  114. oneDirectory = url;
  115.  
  116. oneDirectory = oneDirectory.split("?")[0];
  117.  
  118. dom.holodeckCheckCounter = 0
  119. dom.holodeckInterval = dom.setInterval(checkIfHolodeckLoaded, 100)
  120. dom.oneScriptsInitialize = [];
  121. useScript("this", "accounts", init_showScriptOptions, false, true);
  122. useScript("Chat Timestamp", "games", init_chatTimestamp, true, true);
  123. useScript("Chat PM Notifier", "games", init_PMNotifier, true, true);
  124. useScript("Chat Line Highlighting", "games", init_chatLineHighlighting, true, true);
  125. useScript("Chat Reply-command", "games", init_replyCommand, true, true);
  126. useScript("Chat Username-completion", "games", init_usernameCompletion, true, true);
  127. //useScript("Chat Mouseover Timestamp", "games", init_chatMouseoverTimestamp, true, true);
  128. useScript("Chat Character-limit", "games", init_chatCharacterLimit, true, true);
  129. useScript("Chat KongreLink", "games", init_kongreLink, true, true);
  130. useScript("Chat Resizer", "games", init_chatResizer, true, false);
  131.  
  132.  
  133. addScripts(false);
  134. }
  135.  
  136. function useScript(name, page, callback, requiresHolodeck, defaultEnabled)
  137. {
  138. dom.oneScriptsInitialize.push({name:name, page:page, callback:callback, requiresHolodeck:requiresHolodeck, added:false, defaultEnabled:defaultEnabled});
  139. }
  140. function checkIfHolodeckLoaded()
  141. {
  142. holodeckCheckCounter++;
  143. console.log("[KongOne] Checking if holodeck loaded");
  144. if(typeof holodeck === 'undefined')
  145. {
  146.  
  147. }
  148. else if(holodeck.ready)
  149. {
  150. dom.clearInterval(dom.holodeckInterval);
  151. console.log("[KongOne] Holodeck loaded");
  152. addScripts(true);
  153. }
  154.  
  155. if(holodeckCheckCounter > 40)
  156. {
  157. dom.clearInterval(dom.holodeckInterval);
  158. console.log("[KongOne] Holodeck failed to load");
  159. }
  160. }
  161.  
  162. function addScripts(onlyHolodeckRequired)
  163. {
  164. console.log("[KongOne] Adding Scripts with holodeckRequired = " + onlyHolodeckRequired);
  165. dom.oneScriptsInitialize.each(function(item)
  166. {
  167. if(!item.defaultEnabled && GM_getValue("onescript-" + item.name, "null") == "null")//never been touched before
  168. GM_setValue("onescript-" + item.name, "false");
  169.  
  170. if(item.requiresHolodeck == onlyHolodeckRequired && !item.added)
  171. {
  172. if(item.page == oneDirectory && GM_getValue("onescript-" + item.name, "true") == "true")
  173. {
  174. console.log("[KongOne] Adding Script: " + item.name);
  175. item.callback();
  176. item.added = true;
  177. }
  178. }
  179. })
  180. console.log("[KongOne] Added Scripts");
  181. }
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. //============
  196. // This script's UI
  197. //============
  198.  
  199. function init_showScriptOptions()
  200. {
  201. console.log("init shot script")
  202. var div = new Element("div", {"style":"background-color:#FFF;padding: 8px;"}).update("<h2>Scripts</h2>Enable - Script Name<p></p>");
  203. $("profile_aside").down().insert(div);
  204. dom.oneScriptsInitialize.each(function(item)
  205. {
  206. if(item.name == "this")
  207. return true; //aka, continue for each loops
  208.  
  209. var span = new Element("span", {"style":"margin-top: 5px !important;display: block;"});
  210. div.insert(span);
  211.  
  212. var checkbox = new Element("input", {"type":"checkbox", "id":"onescript-" + item.name, "style":"margin-top:2px;vertical-align:top;margin-right:8px;"});
  213. var label = new Element("label", {"class":"pls"})
  214. checkbox.checked = GM_getValue(checkbox.id,item.defaultEnabled?"true":"false") == "true";
  215. label.update(item.name);
  216.  
  217.  
  218.  
  219. span.insert(checkbox);
  220. span.insert(label);
  221. checkbox.onchange = toggleScript;
  222. });
  223. }
  224.  
  225. function toggleScript()
  226. {
  227. console.log("[KongOne] Toggled script");
  228. GM_setValue(this.id,this.checked);
  229. }
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248. //============
  249. // Chat Timestamps
  250. // http://userscripts.org/scripts/review/55571
  251. //============
  252.  
  253. function init_chatTimestamp()
  254. {
  255. var holodeck = dom.holodeck,
  256. ChatDialogue = dom.ChatDialogue;
  257. console.log(holodeck, " h", ChatDialogue, " c");
  258. if(holodeck && ChatDialogue)
  259. {
  260.  
  261. ChatDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  262.  
  263. if(!holodeck.__timestamp){
  264. holodeck.__timestamp = true;
  265.  
  266. holodeck.addChatCommand("timeformat", function(l,n){
  267. var k = n.match(/^\/\S+\s+(\d+)/),
  268. m = "",
  269. q = l.activeDialogue();
  270. k && (m=k[1]);
  271. if(m==12 || m==24){
  272. l._timeFormat = m;
  273. window.setTimeout(function(){GM_setValue("kong_timeformat", m);}, 0);
  274. q.displayMessage("Timeformat", "Set to "+m+"-hour clock (hh:mm:ss"+(m==12?" AM/PM)":")"), { "class": "whisper received_whisper"}, {non_user: true});
  275. } else {
  276. q.displayMessage("Timeformat", "Allowed values: 12 and 24", { "class": "whisper received_whisper"}, {non_user: true});
  277. }
  278. return false;
  279. });
  280. holodeck.addChatCommand("tscolor", function(l,n){
  281. var k = n.match(/^\/\S+\s+([0-9a-f]{6})/i),
  282. z = "";
  283. k&&(z = "#"+k[1]);
  284. if (z){
  285. updateColor(z);
  286. window.setTimeout(function(){GM_setValue("kong_timestampcolor", z);}, 0);
  287. l.activeDialogue().displayMessage("Timestamp", "Set font-color to "+z, { "class": "whisper received_whisper"}, {non_user: true});
  288. } else {
  289. l.activeDialogue().displayMessage("Timestamp", "No valid color! Format is /hlcolor ###### (# = hex character)", {"class":"whisper received_whisper"}, {non_user: true})
  290. }
  291. return false;
  292. });
  293.  
  294. holodeck.addChatCommand("toggleseconds", function(l,n){
  295. if(l._showSeconds){
  296. l._showSeconds = 0;
  297. l.activeDialogue().displayMessage("Timestamp", "Now hiding seconds", { "class": "whisper received_whisper"}, {non_user: true});
  298. }else{
  299. l._showSeconds = 1;
  300. l.activeDialogue().displayMessage("Timestamp", "Now showing seconds", { "class": "whisper received_whisper"}, {non_user: true})
  301. }
  302. window.setTimeout(function(){GM_setValue("kong_timeshowseconds", l._showSeconds);}, 0);
  303. return false;
  304. });
  305.  
  306. var timeformat = 12, fontcolor = "#999999", seconds = 0;
  307. if(typeof GM_setValue !== "function"){
  308. GM_getValue = GM_setValue = function(){};
  309. } else {
  310. timeformat = GM_getValue("kong_timeformat", 12)||12;
  311. fontcolor = GM_getValue("kong_timestampcolor", "#999999")||"#999999";
  312. seconds = GM_getValue("kong_timeshowseconds", 0)||0;
  313. }
  314. holodeck._timeFormat = timeformat;
  315. holodeck._showSeconds = seconds;
  316.  
  317. var updateColor = (function(c){
  318. var style = document.createElement("style");
  319. style.setAttribute("type", "text/css");
  320. function _updateColor(color){
  321. style.innerHTML = "span.inline_timestamp { color: " + color + " !important; }";
  322. };
  323.  
  324. _updateColor(c);
  325. document.body.appendChild(style);
  326.  
  327. return _updateColor;
  328. })(fontcolor);
  329. ChatDialogue.MESSAGE_TEMPLATE.template = '<p class="#{classNames}"><span style="float: left;" class="inline_timestamp">[#{time}]&nbsp;</span><span username="#{username}" class="username #{userClassNames}">#{prefix}#{username}</span><span class="separator">: </span><span class="message">#{message}</span><span class="clear"></span></p>'
  330. ChatDialogue.MESSAGE_TEMPLATE.old_evaluate_inline = ChatDialogue.MESSAGE_TEMPLATE.evaluate;
  331. ChatDialogue.MESSAGE_TEMPLATE.evaluate = function(args){
  332. var date = new Date();
  333. var hours = date.getHours();
  334. var minutes = date.getMinutes();
  335. var seconds = date.getSeconds();
  336. var time;
  337. if (holodeck._timeFormat == 12){
  338. 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");
  339. } else {
  340. time = (hours<10?"0":"")+hours+":"+(minutes<10?"0":"")+minutes+(holodeck._showSeconds?(":"+(seconds<10?"0":"")+seconds):"");
  341. }
  342. args.time = time;
  343. return this.old_evaluate_inline(args);
  344. };
  345. }
  346. }
  347. }
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365. //============
  366. // Chat Line Highlighting
  367. // http://userscripts.org/scripts/review/49868
  368. //============
  369.  
  370. function init_chatLineHighlighting()
  371. {
  372.  
  373. var holodeck = dom.holodeck,
  374. CDialogue = dom.ChatDialogue,
  375. CRoom = dom.ChatRoom,
  376. CWindow = dom.ChatWindow;
  377.  
  378. if(CRoom && CDialogue){
  379.  
  380. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  381. CRoom.prototype = dom.CRprototype||dom.ChatRoom.prototype;
  382. CWindow.prototype = dom.CWprototype||dom.ChatWindow.prototype;
  383. if(!CDialogue.prototype.searchWord){
  384.  
  385. if(!String.prototype.trim){
  386. String.prototype.trim = function(){
  387. return this.replace(/^\s+/, "").replace(/\s+$/, "");
  388. }
  389. }
  390.  
  391. CDialogue.prototype.searchWord = function(a, b){
  392. for (var i=0;i<b.length;i++){
  393. var r = b[i].replace(/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g, '\\$1'),
  394. reg = new RegExp("\\b"+r+"\\b");
  395. if (reg.test(a)) return true;
  396. }
  397. return false;
  398. };
  399.  
  400. CDialogue.prototype.searchUser = function(a){
  401. return this.searchWord(a, this._holodeck._hluser);
  402. };
  403.  
  404. CDialogue.prototype.searchText = function(a){
  405. var l = this._holodeck,
  406. z = l._highlighting.concat([l._username.toLowerCase()]);
  407. return this.searchWord(a, z);
  408. }
  409.  
  410. CWindow.prototype.hlFriend = function(a){
  411. return this._holodeck._hl_friends && this.isFriend(a);
  412. }
  413.  
  414. CWindow.prototype.hlMod = function(a){
  415. if(!this._holodeck._hl_mods) return;
  416.  
  417. return this._rooms.any(function(roomArr){
  418. var room = roomArr[1];
  419. var user = room.user(a);
  420. return user && room.canUserModerate(user);
  421. });
  422. }
  423.  
  424. CWindow.prototype.friendOrMod = function(a){
  425. if(a.toLowerCase() == this._holodeck._username.toLowerCase()) return "";
  426.  
  427. var colors = [];
  428. if(this.hlMod(a)) colors.push(" hlmod");
  429. if(this.hlFriend(a)) colors.push(" hlfriend");
  430. if(colors.length > 1)
  431. return colors[this._holodeck._hl_priority]
  432.  
  433.  
  434. return (colors[0] || "");
  435. }
  436.  
  437. CDialogue.prototype.displayUnsanitizedMessageOldHighlight = CDialogue.prototype.displayUnsanitizedMessage;
  438.  
  439. CDialogue.prototype.displayUnsanitizedMessage = function(user, msg, attributes, options){
  440. if(!attributes) attributes = {};
  441. var classes = attributes["class"] || "";
  442. var isWhisper = (classes.indexOf("whisper") >= 0);
  443.  
  444. if(!(options && options["private"]))
  445. classes += this._user_manager.friendOrMod(user.toLowerCase());
  446.  
  447. if(!isWhisper &&
  448. !this._user_manager.isMuted(user.toLowerCase()) &&
  449. (this.searchUser(user.toLowerCase()) ||
  450. this.searchText(msg.toLowerCase()))) {
  451. classes += " highlight";
  452. if(typeof this.new_private_message === "function") {
  453. var oldChime = holodeck._pm_chime;
  454. holodeck._pm_chime = holodeck._hl_chime;
  455. this.new_private_message();
  456. holodeck._pm_chime = oldChime;
  457. }
  458. }
  459.  
  460. attributes["class"] = classes;
  461.  
  462. this.displayUnsanitizedMessageOldHighlight(user, msg, attributes, options);
  463. }
  464.  
  465. holodeck.addChatCommand("highlight", function(l,n){
  466. var k = n.match(/^\/\S+\s+(.+)/),
  467. z = "";
  468. k&&(z = k[1])
  469. if(z){
  470. z = z.replace(/\s+/g, ' ').trim();
  471. window.setTimeout(function(){GM_setValue("kong_highlighting", z.toLowerCase());}, 0);
  472. l.activeDialogue().kongBotMessage("Now highlighting: "+z+" "+l._username);
  473. l._highlighting = z.toLowerCase().split(' ');
  474. }
  475. return false;
  476. });
  477.  
  478. holodeck.addChatCommand("hluser", function(l,n){
  479. var k = n.match(/^\/\S+\s+(.+)/),
  480. z = "";
  481. k&&(z = k[1])
  482. if(z){
  483. z = z.replace(/\s+/g, ' ').trim();
  484. window.setTimeout(function(){GM_setValue("kong_highlightuser", z.toLowerCase());}, 0);
  485. l.activeDialogue().kongBotMessage("Now highlighting user(s): "+z);
  486. l._hluser = z.toLowerCase().split(' ');
  487. }
  488. return false;
  489. });
  490.  
  491. function generateCallback(name, stop, start){
  492. return function(l, n){
  493. if(l["_hl_" + name]){
  494. l["_hl_" + name] = 0;
  495. l.activeDialogue().kongBotMessage(stop || "Stopped highlighting messages by " + name);
  496. }else{
  497. l["_hl_" + name] = 1;
  498. l.activeDialogue().kongBotMessage(start || "Now highlighting messages by " + name);
  499. }
  500. window.setTimeout(function(){GM_setValue("kong_highlight"+name, l["_hl_" + name]);}, 0);
  501. return false;
  502. }
  503. }
  504.  
  505. holodeck.addChatCommand("hlmods", generateCallback("mods"));
  506. holodeck.addChatCommand("hlfriends", generateCallback("friends"));
  507. holodeck.addChatCommand("hlchime", generateCallback("chime", "Stopped playing the chime for highlighted messages",
  508. "Now playing the chime for highlighted messages"));
  509. holodeck.addChatCommand("hlpriority", generateCallback("priority", "Now prioritizing mods over friends", "Now prioritizing friends over mods"));
  510.  
  511. function generateColorCallback(selector, rule, name, text, max){
  512. if(!max) max = 1;
  513. return function(l, n){
  514. var k = n.match(/^\/\S+\s+#?([0-9a-f]{6})/i),
  515. z = "",
  516. count = 0;
  517. if(k) z = "#" + k[1];
  518. if(z){
  519. for(var i = 0; i < sheet.cssRules.length; i++){
  520. if(sheet.cssRules[i].selectorText.indexOf(selector) == 0){
  521. sheet.cssRules[i].style.setProperty(rule, z, "important");
  522. if(++count == max){
  523. window.setTimeout(function(){GM_setValue("kong_" + name, z);}, 0);
  524. l.activeDialogue().kongBotMessage("New " + (text||name) + ": " + z);
  525. return false;
  526. }
  527. }
  528. }
  529. } else {
  530. l.activeDialogue().kongBotMessage("No valid color! Format is /" + name + " XXXXXX (X = hex character)");
  531. }
  532. return false;
  533. }
  534. };
  535.  
  536. holodeck.addChatCommand(
  537. "whispercolor",
  538. generateColorCallback("#kong_game_ui .chat_message_window .whisper",
  539. "background-color",
  540. "whispercolor")
  541. )
  542.  
  543. holodeck.addChatCommand(
  544. "friendcolor",
  545. generateColorCallback("#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username",
  546. "color",
  547. "friendcolor")
  548. )
  549. holodeck.addChatCommand(
  550. "hlcolor",
  551. generateColorCallback("#kong_game_ui .chat_message_window .highlight",
  552. "background-color",
  553. "hlcolor",
  554. "highlighting-color",
  555. 2)
  556. )
  557. holodeck.addChatCommand(
  558. "modcolor",
  559. generateColorCallback("#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username",
  560. "color",
  561. "modcolor")
  562. )
  563.  
  564. holodeck.addChatCommand("hllist", function(l, n) {
  565. var diag = l.activeDialogue();
  566. function botMessage(msg) {
  567. diag.displayUnsanitizedMessage("Kong Bot", msg);
  568. }
  569.  
  570. botMessage("Current highlighting settings:");
  571.  
  572. if(holodeck._hluser.length > 0) {
  573. botMessage('Users:');
  574. botMessage('Users: ' + holodeck._hluser.map(function(user) {
  575. return ['<a href="#" onclick="holodeck.showMiniProfile(\'', user,
  576. '\'); return false;">', user, '</a>'].join("");
  577. }).join(" "));
  578. } else {
  579. botMessage("No users highlighted");
  580. }
  581.  
  582. if(holodeck._highlighting.length > 0) {
  583. botMessage('Words: ' + holodeck._highlighting.join(" "));
  584. } else {
  585. botMessage("No words highlighted");
  586. }
  587.  
  588. botMessage('Highlight color: <span style="color: ' + color + '">' +
  589. color + '</span>');
  590. botMessage('Whisper color: <span style="color: ' + wcolor + '">' +
  591. wcolor + '</span>');
  592.  
  593. botMessage("Highlighting friends: " +
  594. (holodeck._hl_friends ? "Yes" : "No") +
  595. ' (color: <span style="color: ' + fcolor + '">' +
  596. fcolor + '</span>)');
  597. botMessage("Highlighting mods: " +
  598. (holodeck._hl_mods ? "Yes" : "No") +
  599. ' (color: <span style="color: ' + mcolor + '">' +
  600. mcolor + '</span>)');
  601.  
  602. botMessage("Highlight priority: " +
  603. (holodeck._hl_priority ? "Friends over mods" : "Mods over friends"));
  604. botMessage("Playing chime: " +
  605. (holodeck._hl_chime ?
  606. (typeof holodeck._pm_chime !== "undefined" ? "Yes" :
  607. 'No, <a href="http://userscripts.org/scripts/show/65622">script</a> not installed') :
  608. "No"));
  609. return false;
  610. });
  611.  
  612. holodeck.addChatCommand("hlreset", function(l, n) {
  613. var diag = l.activeDialogue();
  614. diag.kongBotMessage("Resetting all highlighting preferences");
  615.  
  616. holodeck._chat_commands.hlcolor[0](holodeck, "/color #def6ea");
  617. holodeck._chat_commands.whispercolor[0](holodeck, "/color #deeaf6");
  618. holodeck._chat_commands.friendcolor[0](holodeck, "/color #006600");
  619. holodeck._chat_commands.modcolor[0](holodeck, "/color #ba6328");
  620. holodeck._hl_priority = 1;
  621. holodeck._hl_friends = 1;
  622. holodeck._hl_mods = 1;
  623. holodeck._hl_chime = 1;
  624. holodeck._highlighting = [];
  625. holodeck._hluser = [];
  626.  
  627. ["highlighting", "highlightuser", "hlcolor", "whispercolor", "friendcolor",
  628. "modcolor", "highlightfriends", "highlightpriority", "highlightmods",
  629. "highlightchime"].forEach(function(pref) {
  630. window.setTimeout(function() {
  631. GM_deleteValue("kong_" + pref);
  632. }, 0);
  633. });
  634.  
  635. return false;
  636. });
  637.  
  638. holodeck._chat_commands.hl = holodeck._chat_commands.highlight;
  639. holodeck._chat_commands.hlfriend = holodeck._chat_commands.hlfriends;
  640.  
  641. holodeck._highlighting = [];
  642. holodeck._hluser = [];
  643.  
  644.  
  645. var color = "#def6ea", wcolor = "#deeaf6", fcolor = "#006600", mcolor = "#ba6328", priority = 1, friends = 1, mods = 1, chime = 1;
  646.  
  647. if(typeof GM_setValue !== "function"){
  648. GM_setValue = GM_getValue = function(){};
  649. } else {
  650. // migrate old value
  651. var temp = GM_getValue("kong_highlightcolor", "");
  652. if(temp){
  653. GM_setValue("kong_hlcolor", temp);
  654. if(typeof GM_deleteValue === "undefined"){
  655. GM_setValue("kong_highlightcolor", "");
  656. } else {
  657. GM_deleteValue("kong_highlightcolor");
  658. }
  659. }
  660.  
  661. var list = GM_getValue("kong_highlighting"),
  662. user = GM_getValue("kong_highlightuser");
  663. color = GM_getValue("kong_hlcolor", "#def6ea")||"#def6ea";
  664. wcolor = GM_getValue("kong_whispercolor", "#deeaf6")||"#deeaf6";
  665. fcolor = GM_getValue("kong_friendcolor", "#006600")||"#006600";
  666. mcolor = GM_getValue("kong_modcolor", "#ba6328")||"#ba6328";
  667. friends = GM_getValue("kong_highlightfriends", 1);
  668. priority = GM_getValue("kong_highlightpriority", 1);
  669. mods = GM_getValue("kong_highlightmods", 1);
  670. chime = GM_getValue("kong_highlightchime", 1);
  671. if(list){holodeck._highlighting = list.trim().split(' ')};
  672. if(user){holodeck._hluser = user.trim().split(' ')}
  673. }
  674.  
  675. holodeck._hl_friends = friends;
  676. holodeck._hl_mods = mods;
  677. holodeck._hl_chime = chime;
  678. holodeck._hl_priority = priority;
  679.  
  680. // guarantee we have a non-crossdomain stylesheet
  681. var style = document.createElement("style");
  682. var head = document.getElementsByTagName("head")[0];
  683. (head || document.body).appendChild(style);
  684.  
  685. // now find it...
  686. var sheet = null;
  687. for(var s = document.styleSheets.length - 1; s >= 0; --s) {
  688. try{
  689. if(document.styleSheets[s].cssRules && document.styleSheets[s].cssRules.length) {
  690. sheet = document.styleSheets[s];
  691. break;
  692. }
  693. }catch(e){ /* no-op */ }
  694. }
  695.  
  696. if(!sheet) {
  697. alert("Kongregate Chat Line Highlighting could not find a style sheet!\nPlease send a message to Ventero about this problem.");
  698. return;
  699. }
  700.  
  701. sheet.insertRule('#kong_game_ui .chat_message_window .whisper { background-color: '+wcolor+' !important; }', sheet.cssRules.length);
  702. sheet.insertRule('#kong_game_ui .chat_message_window .highlight.even { background-color: '+color+' !important; }', sheet.cssRules.length);
  703. sheet.insertRule('#kong_game_ui .chat_message_window .highlight { background-color: '+color+' !important; }', sheet.cssRules.length);
  704. sheet.insertRule('#kong_game_ui .chat_message_window .hlfriend span.chat_message_window_username { color: '+fcolor+' !important; }', sheet.cssRules.length);
  705. sheet.insertRule('#kong_game_ui .chat_message_window .hlmod span.chat_message_window_username { color: '+mcolor+' !important; }', sheet.cssRules.length);
  706. }
  707. }
  708. }
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724. //============
  725. // Reply-Command
  726. // http://userscripts.org/scripts/review/47963
  727. //============
  728. function init_replyCommand()
  729. {
  730.  
  731. var CDialogue = dom.ChatDialogue;
  732.  
  733. if (CDialogue){
  734.  
  735. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  736. if(!CDialogue.prototype.oldKeyPressReply){
  737.  
  738. CDialogue.prototype.oldKeyPressReply = CDialogue.prototype.onKeyPress;
  739.  
  740. if(CDialogue.prototype.reply){
  741. CDialogue.prototype.oldreply = CDialogue.prototype.reply
  742. } else {
  743. CDialogue.prototype.oldreply = function(a){};
  744. }
  745. CDialogue.prototype.reply = function(a){
  746. this._holodeck._reply = a;
  747. this.oldreply(a);
  748. }
  749.  
  750. if(!CDialogue.prototype.showReceivedPM){
  751. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  752. CDialogue.prototype.receivedPrivateMessage = function(a){
  753. if (a.data.success){
  754. this.reply(a.data.from)
  755. }
  756. this.showReceivedPM(a);
  757. }
  758. }
  759.  
  760. CDialogue.prototype.onKeyPress = function (a) {
  761. var z, node = (this._input_node.wrappedJSObject || this._input_node);
  762. if(a.which == 32 &&
  763. ((a.currentTarget.selectionStart == 2 && (z = node.getValue().match(/^\/r(.*)/i))) ||
  764. (z = node.getValue().match(/^\/r\b(.*)/i)))){
  765. var x=z[1]||"";
  766. if (this._holodeck._reply) {
  767. this.setInput("/w "+this._holodeck._reply+" "+x);
  768. } else {
  769. this.setInput("/w ");
  770. }
  771. if(a.stop) a.stop();
  772. if(a.preventDefault) a.preventDefault();
  773. };
  774.  
  775. this.oldKeyPressReply(a);
  776. }
  777. }
  778. }
  779. }
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792. //============
  793. // Username-Completion
  794. // http://userscripts.org/scripts/review/49872
  795. // Thanks to kaedenn for the idea of adding a colon if the username is the first word in the message
  796. //============
  797. function init_usernameCompletion()
  798. {
  799. if(typeof ChatDialogue === "undefined" ||
  800. ChatDialogue.prototype.oldKeyPressTab) return;
  801.  
  802. var isChrome = (navigator.appVersion.indexOf("Chrome") >= 0);
  803. if(isChrome) {
  804. ChatDialogue.prototype.initialize =
  805. ChatDialogue.prototype.initialize.wrap(function(old, p, i, h, u){
  806. old(p, i, h, u);
  807. var self = this;
  808. this._input_node.observe("keydown", function(event) {
  809. if(event.keyCode != 9 || event.ctrlKey || event.altKey || event.metaKey) return;
  810. self.onKeyPress(event);
  811. });
  812. })
  813. }
  814.  
  815. ChatDialogue.prototype.oldKeyPressTab = ChatDialogue.prototype.onKeyPress;
  816. ChatDialogue.prototype.tabcnt = 0;
  817. ChatDialogue.prototype.done = 1;
  818. ChatDialogue.prototype.onKeyPress = function(a){
  819. if (a.keyCode != 9 || a.ctrlKey){
  820. this.tabcnt = 0;
  821. this.done = 1;
  822. this.oldKeyPressTab(a);
  823. return;
  824. }
  825.  
  826. var node = (this._input_node.wrappedJSObject || this._input_node);
  827. if (this.tabcnt == 0 && this.done == 1){
  828. var inputText = node.getValue(),
  829. spaceAtCaret = inputText.substr(0, node.selectionStart).lastIndexOf(' ');
  830. this._caretPos = node.selectionStart;
  831. this._start = inputText.substr(0,spaceAtCaret);
  832. if(this._start) this._start+=" ";
  833.  
  834. this._currentWord = inputText.substring(spaceAtCaret+1, this._caretPos);
  835. this._rest = inputText.substr(this._caretPos);
  836. }
  837. this.done = 0;
  838.  
  839. var userArray = this._holodeck.chatWindow().activeRoom()._users_list,
  840. possibleMatches = [],
  841. z = node.getValue();
  842. if (z.match(/\s+$/)) z=z.replace(/\s+$/, '')
  843.  
  844. for (var i=0;i<userArray.length;i++){
  845. if(userArray[i].username.toLowerCase().indexOf(this._currentWord.toLowerCase())==0){
  846. possibleMatches.push(userArray[i].username);
  847. }
  848. }
  849.  
  850. if (this.tabcnt < possibleMatches.length){
  851. node.setValue(this._start + possibleMatches[this.tabcnt] + (this._start?" ":": ") + this._rest);
  852. node.selectionStart = this._caretPos + possibleMatches[this.tabcnt].length - this._currentWord.length+(this._start?1:2);
  853. node.selectionEnd = node.selectionStart;
  854. this.tabcnt+=1;
  855. } else {
  856. node.setValue(this._start + this._currentWord + this._rest);
  857. node.selectionStart = this._caretPos;
  858. node.selectionEnd = this._caretPos;
  859. this.tabcnt = 0
  860. }
  861. if(a.stop) a.stop();
  862. if(a.preventDefault) a.preventDefault();
  863. }
  864. }
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884. //============
  885. // Kongregate Chat Mouseover Timestamp
  886. // http://userscripts.org/scripts/review/50785
  887. //============
  888. function init_chatMouseoverTimestamp()
  889. {
  890.  
  891. var holodeck = dom.holodeck,
  892. ChatDialogue = dom.ChatDialogue;
  893.  
  894. function injectMouseover(dom, holodeck, ChatDialogue) {
  895. var message_rollover_template = new dom.Element("div", {id: "message_rollover_template", "class": "user_rollover_container spritesite", style: "display: none"});
  896. var message_rollover = new dom.Element("div", {"class": "user_rollover spritesite"});
  897. var message_rollover_inner = new dom.Element("div", {"class": "user_rollover_inner"});
  898. var rollover_private_message_holder = new dom.Element("p", {"class": "rollover_message_private_message_link_message_link_holder"});
  899. 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");
  900. rollover_private_message_holder.appendChild(rollover_private_message_link);
  901. var rollover_time_text = new dom.Element("p", {id: "rollover_time_text"});
  902. message_rollover_inner.appendChild(rollover_time_text);
  903. message_rollover_inner.appendChild(rollover_private_message_holder);
  904. message_rollover.appendChild(message_rollover_inner);
  905. message_rollover_template.appendChild(message_rollover);
  906. $('chat_tab_pane').appendChild(message_rollover_template);
  907.  
  908. var MessageRollover = dom.MessageRollover = function(chat_dialogue) {
  909. this.initialize(chat_dialogue);
  910. return this;
  911. }
  912.  
  913. MessageRollover.prototype = {
  914. initialize: function(chat_dialogue){
  915. this._active_dialogue = chat_dialogue;
  916. this._holodeck = chat_dialogue._holodeck;
  917. this._rollover_template_node = $('message_rollover_template');
  918. this._private_message_node = $('rollover_message_private_message_link');
  919. this._time_node = $('rollover_time_text');
  920.  
  921. this._private_message_observer = function(){};
  922.  
  923. if(this._rollover_template_node){
  924. var rollover = this;
  925. this._rollover_template_node.observe('mouseover', function(event){
  926. rollover.stopHide();
  927. dom.Event.stop(event);
  928. });
  929. this._rollover_template_node.observe('mouseout', function(event){
  930. rollover.beginHide();
  931. dom.Event.stop(event);
  932. });
  933. }
  934. },
  935. show: function(time, user, event){
  936. if(this._hideTimer) clearTimeout(this._hideTimer);
  937. this.updatePrivateMessageLink(user);
  938. this.updateTimeText(time);
  939. this.setRolloverPosition(event);
  940. this._rollover_template_node.show();
  941. },
  942. setRolloverPosition: function(event) {
  943. var messagenode = event.target;
  944. var current_scroll_top = this._active_dialogue._message_window_node.scrollTop;
  945. var current_message_top = messagenode.positionedOffset()[1];
  946. // nudge the user rollover up a little
  947. current_message_top = current_message_top - 9;
  948.  
  949. var new_top_val = current_message_top;
  950. if ( current_scroll_top < current_message_top ) {
  951. new_top_val = current_message_top - current_scroll_top;
  952. }
  953.  
  954. var top_style_str = new_top_val + 'px';
  955. this._rollover_template_node.setStyle({ top: top_style_str });
  956.  
  957. // set left position based on username length
  958. var username_width = messagenode.getWidth();
  959. var new_left_val = 20 + username_width;
  960.  
  961. var left_style_str = new_left_val + 'px';
  962. this._rollover_template_node.setStyle({ left: left_style_str });
  963. },
  964.  
  965. updatePrivateMessageLink: function(username){
  966. var cw = this._holodeck.chatWindow();
  967. // replace observer
  968. this._private_message_node.stopObserving('click');
  969. this._private_message_observer = dom.CapturesToInlineRegistration.decorate(function(event){
  970. // just put /w <username> in the chat input field
  971. cw.insertPrivateMessagePrefixFor(username);
  972. dom.Event.stop(event);
  973. return false;
  974. });
  975. this._private_message_node.observe('click', this._private_message_observer);
  976. },
  977. updateTimeText: function(time){
  978. this._time_node.innerHTML = time;
  979. },
  980. beginHide: function() {
  981. var rollover = this;
  982. if(this._hideTimer){ clearTimeout(this._hideTimer); }
  983. this._hideTimer = setTimeout(function() { rollover.hide(); }, 500);
  984. },
  985. stopHide: function() {
  986. clearTimeout(this._hideTimer);
  987. },
  988. hide: function() {
  989. this._rollover_template_node.hide();
  990. }
  991. };
  992.  
  993. 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>';
  994. ChatDialogue.MESSAGE_TEMPLATE.old_evaluate = ChatDialogue.MESSAGE_TEMPLATE.evaluate;
  995. ChatDialogue.MESSAGE_TEMPLATE.evaluate = function(args){
  996. var date = new Date();
  997. var hours = date.getHours();
  998. var minutes = date.getMinutes();
  999. var seconds = date.getSeconds();
  1000. var time;
  1001. if (holodeck._timeFormat == 12){
  1002. 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
  1003. } else {
  1004. time = (hours<10?"0":"")+hours+":"+(minutes<10?"0":"")+minutes+":"+(seconds<10?"0":"")+seconds; //24-hour clock
  1005. }
  1006. args.time = time;
  1007. return this.old_evaluate(args);
  1008. };
  1009.  
  1010. ChatDialogue.prototype.initialize =
  1011. ChatDialogue.prototype.initialize.wrap(function(old, parent_node, onInputFunction, holodeck, user_manager){
  1012. old(parent_node, onInputFunction, holodeck, user_manager);
  1013. //var self = this;
  1014. //this._input_node.observe("keydown", function(event) {
  1015. // if(event.keyCode != 9 || event.ctrlKey || event.altKey || event.metaKey) return;
  1016. // self.onKeyPress(event);
  1017. //});
  1018. //})
  1019. //ChatDialogue.prototype.initialize = function(parent_node, onInputFunction, holodeck, user_manager) {
  1020. this._messages_until_next_collection = 0;
  1021. this._holodeck = holodeck;
  1022. this._user_manager = user_manager;
  1023. this._parent_node = parent_node;
  1024. this._messages_count = 0;
  1025. this._insertion_count = 0;
  1026. this._onInputFunction = onInputFunction;
  1027. this._message_rollover_manager = new MessageRollover(this);
  1028.  
  1029. // Establish references to re-used nodes
  1030. this._message_window_node = parent_node.down('.chat_message_window');
  1031. this._input_node = parent_node.down('.chat_input');
  1032.  
  1033. this._messages_to_retain = 200;
  1034.  
  1035. this._message_window_node.stopObserving();
  1036.  
  1037. this._message_window_node.observe('mouseover', function(event) {
  1038. var time = event.target.getAttribute("time"),
  1039. user = event.target.getAttribute("username");
  1040. if (time){
  1041. holodeck.activeDialogue().showMessageRollover(time, user, event);
  1042. dom.Event.stop(event);
  1043. }
  1044. });
  1045.  
  1046. this._message_window_node.observe('mouseout', function(event) {
  1047. holodeck.activeDialogue().hideMessageRollover();
  1048. dom.Event.stop(event);
  1049. });
  1050.  
  1051. // Bind event listeners
  1052. var dialogue = this,
  1053. input_node = this._input_node;
  1054. this._input_node.observe('keypress', function(event) { dialogue.onKeyPress(event); });
  1055. this._input_node.observe('focus', function(event) { dialogue.clearPrompt(); });
  1056.  
  1057. // Trigger mini-profile for clicks on usernames in chat.
  1058. this._message_window_node.observe('click',
  1059. function(event) {
  1060. if (event.target) {
  1061. var username = event.target.getAttribute('username');
  1062. if(username){
  1063. event.stop();
  1064. user_manager.showProfile(username);
  1065. }
  1066. }
  1067. });
  1068. });
  1069.  
  1070. ChatDialogue.prototype.showMessageRollover = function (time, user, event){
  1071. this._message_rollover_manager.show(time, user, event);
  1072. }
  1073.  
  1074. ChatDialogue.prototype.hideMessageRollover = function(){
  1075. this._message_rollover_manager.beginHide();
  1076. }
  1077. }
  1078.  
  1079. if(holodeck && ChatDialogue){
  1080. if(!ChatDialogue.prototype && dom.CDprototype)
  1081. ChatDialogue.prototype = dom.CDprototype;
  1082.  
  1083. if(!holodeck.__mouseover){
  1084. holodeck.__mouseover = true;
  1085.  
  1086. var script = document.createElement("script");
  1087. script.type = "text/javascript";
  1088. script.textContent = "(" + injectMouseover.toString() + ")(window, $, holodeck, ChatDialogue);";
  1089. document.body.appendChild(script);
  1090. setTimeout(function(){document.body.removeChild(script);}, 100);
  1091.  
  1092. holodeck.addChatCommand("timeformat", function(l,n){
  1093. var k = n.match(/^\/\S+\s+(\d+)/),
  1094. m = "",
  1095. q = l.activeDialogue();
  1096. k && (m=k[1]);
  1097. if(m==12 || m==24){
  1098. l._timeFormat = m;
  1099. window.setTimeout(function(){GM_setValue("kong_timeformat", m);}, 0);
  1100. q.displayMessage("Timeformat", "Set to "+m+"-hour clock (hh:mm:ss"+(m==12?" AM/PM)":")"), { "class": "whisper received_whisper"}, {non_user: true});
  1101. } else {
  1102. q.displayMessage("Timeformat", "Allowed values: 12 and 24", { "class": "whisper received_whisper"}, {non_user: true});
  1103. }
  1104. return false;
  1105. });
  1106.  
  1107. var timeformat = 12;
  1108.  
  1109. if(typeof GM_setValue !== "undefined"){
  1110. timeformat = GM_getValue("kong_timeformat", 12)||12;
  1111. }else{
  1112. GM_setValue = function(){};
  1113. }
  1114.  
  1115. holodeck._timeFormat = timeformat;
  1116. }
  1117. }
  1118. }
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138. //============
  1139. // Character-limit
  1140. // http://userscripts.org/scripts/review/48979
  1141. //============
  1142. function init_chatCharacterLimit(){
  1143.  
  1144. var CDialogue = dom.ChatDialogue;
  1145.  
  1146. if(CDialogue){
  1147. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  1148.  
  1149. if(!CDialogue.prototype.oldKeyPressLimit){
  1150. CDialogue.prototype.oldKeyPressLimit = CDialogue.prototype.onKeyPress;
  1151. CDialogue.prototype.onKeyPress = function (a) {
  1152. var node = (this._input_node.wrappedJSObject || this._input_node);
  1153. this.oldKeyPressLimit(a);
  1154. if (node.getValue().length > 249) {
  1155. z = node.getValue();
  1156. var y = "";
  1157. if (n=z.match(/^(\/\S+\s+\S*\s*)(.*)/)){
  1158. y=n[2];
  1159. if (y.length>249){
  1160. node.setValue(n[1]+y.substr(0, 249))
  1161. }
  1162. }else{
  1163. node.setValue(node.getValue().substr(0, 249))
  1164. }
  1165. }
  1166. }
  1167. }
  1168. };
  1169. }
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180. //============
  1181. // KongreLink (skyboy attribution applies)
  1182. // http://userscripts.org/scripts/review/72163
  1183. //============
  1184.  
  1185. function init_kongreLink()
  1186. {
  1187. console.log("initializing the kongrelink js");
  1188. 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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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)}))");
  1189. }
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209. //============
  1210. // PM Notifier (MrSpontaneous attribution applies
  1211. // http://userscripts.org/scripts/review/48979
  1212. //============
  1213. function init_PMNotifier()
  1214. {
  1215. var holodeck = dom.holodeck,
  1216. CDialogue = dom.ChatDialogue;
  1217. if (CDialogue)
  1218. {
  1219. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  1220. console.log("pm1");
  1221. if (!CDialogue.prototype.new_private_message)
  1222. {
  1223. console.log("pm2");
  1224. dom._animatedFav = false;
  1225. dom._pmCount = 0;
  1226. dom._baseTitle = document.title;
  1227. dom._blurred = false;
  1228. dom._chime = dom.document.createElement('audio');
  1229. 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+/z9vn359PEu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a25sZWNpdoynur65rqKZlpaVl56ioJmLdV9SS09bZmZcTj4xMjtIU1xbVFJWWFdZXmp/ma24vbispaixvMza39rQwK6gl4yCgYOCfHBcRzs7QEpXW1ZOR0A9Q09gdo2eqK+xqZ+Zl5qltL/AuKaOeWxlYmVrbWpjWk5HRklOVl1fXVxbV1ZbZ3eMn6y0ubq1sK6vsLa9wsTAtqaViH52c3V1cWpgVU5MTk9RVFNQUVNUVVpganeIlZ6kpaGbl5eYm6Glp6ahmY2De3JtbG5vbmpiWlVWWV1jZmZjY2VnbHJ5gImSmqCmqaijn5ybnaKmqKahmZCKhYF9enh0cW5qZmRiYmJkZmdnaGhoaWtvdX2EiYyOkZKSkZGQj5CRkpOSkIqFgHt3dXNyc3R1dnl9gYOBfXh1c3Fta2xvcnV3e4CEhoaGhoiIhoSEhomNkJSan6GhnpuZlpGMiIaGhYOCg4WGhoOBfXp1cGtnZ2dnZ2hrbm9ubGtqaWdmZmltcHN2eXx9fHp6ent7e3x/g4iMj5KWmZqamZeWlJGOi4qJiYmJiouNjY2LioiFgn98e3p5eXl5ent7e3p6enp6enp6e3x8fH19fX19fn5+fn5+f39/f39/f3+AgICAgICAgICBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgABMSVNUWAAAAElORk9JQ09QHwAAAENvcHlyaWdodCCpIENpbmVtYXRyb25pY3MgMTk5NQAASVBSRCMAAABNaWNyb3NvZnQgUGx1cyEgriBmb3IgV2luZG93cyA5NSCuAAA=');
  1230. dom._chime.load();
  1231.  
  1232. //dom.document.addEventListener("blur", function() {
  1233. window.onblur=function(){
  1234. dom._blurred = true;
  1235. console.log("Blur1");
  1236. };//, false);
  1237. console.log("pm3");
  1238. //dom.document.addEventListener("focus", function() {
  1239. window.onfocus=function(){
  1240. dom._blurred = false;
  1241. console.log("Focus 1");
  1242. dom.pmReset();
  1243. };//, false);
  1244. console.log("pm4");
  1245. dom.pmReset = function() {
  1246. if (dom._animatedFav) {
  1247. dom.toggleFavLink();
  1248. }
  1249. dom._pmCount = 0;
  1250. document.title = dom._baseTitle;
  1251. }
  1252. console.log("pm5");
  1253. dom.createFavLink = function(attr) {
  1254. var link = document.createElement("link");
  1255. link.type = attr['type'];
  1256. link.rel = attr['rel'];
  1257. link.href = attr['href'];
  1258. return link;
  1259. }
  1260. console.log("pm6");
  1261. dom.toggleFavLink = function() {
  1262. var head = document.getElementsByTagName("head")[0];
  1263. var links = head.getElementsByTagName("link");
  1264. for (var i=0; i<links.length; i++) {
  1265. var link = links[i];
  1266. if (link.rel=="shortcut icon") {
  1267. head.removeChild(link);
  1268. }
  1269. }
  1270. if (dom._animatedFav) {
  1271. head.appendChild(dom.createFavLink(dom._staticFavLinkAttr));
  1272. }
  1273. else {
  1274. head.appendChild(dom.createFavLink(dom._animatedFavLinkAttr));
  1275. }
  1276. dom._animatedFav = !dom._animatedFav;
  1277. }
  1278. console.log("p7");
  1279. dom._staticFavLinkAttr = {'rel':'shortcut icon', 'href':'/favicon.ico', 'type':'image/x-icon'};
  1280. dom._animatedFavLinkAttr = { 'rel':'shortcut icon', 'href':'data:image/gif;base64,R0lGODlhIAAgAPceAGYAAJgAAJgBAZkCApoEBJkWGpkAM5krAJkpL5krM6EMDKQPEaARDaYkLassIpkrZplVM5lVZswrM8xVM8xVZsyAZsyAmcyqmcyqzP+qzMzVzP/VzP/V////zP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAifAAsIHEiwoMGDCBMqXMiw4UEAECNKhDhwokWKFS9KzKgxIsGOHgWCDClyJEeQBTs+VLlyI8KLCi22nLhQZkqYNWl+tMmQZwGcDXkCDapzKNGRGB3+REryKFMASlkaTajxZNOYPpfqzOlyZ9aZSb1ufTlWbFeDVdGmNTsUKVufbq22NSlwwMgAA+2OFMCQgF+Cfv8qHUx4YWC/Aw4TGBgQADs%3D', 'type':'image/gif'};
  1281. console.log("pm8");
  1282. CDialogue.prototype.new_private_message = function() {
  1283. console.log("got pm 1");
  1284. if (_blurred || (document.hidden != undefined && document.hidden) || (document.webkitHidden != undefined && document.webkitHidden)) {
  1285. console.log("got pm blurred");
  1286. dom._pmCount++;
  1287. if (!dom._animatedFav) {
  1288. dom.toggleFavLink();
  1289. }
  1290. document.title = "[" + dom._pmCount + "] " + dom._baseTitle;
  1291. if (holodeck._pm_chime) {
  1292. dom._chime.play();
  1293. }
  1294. }
  1295. }
  1296. if(!CDialogue.prototype.showReceivedPM_notifier){
  1297. CDialogue.prototype.showReceivedPM_notifier = CDialogue.prototype.receivedPrivateMessage;
  1298. CDialogue.prototype.receivedPrivateMessage = function(a){
  1299. if (a.data.success && !this._user_manager.isMuted(a.data.from)) {
  1300. this.new_private_message();
  1301. }
  1302. this.showReceivedPM_notifier(a);
  1303. }
  1304. }
  1305. holodeck.addChatCommand("pmchime", function (l,n){
  1306. if(l._pm_chime) {
  1307. l._pm_chime = 0;
  1308. l.activeDialogue().kongBotMessage("PM chime is OFF");
  1309. } else {
  1310. l._pm_chime = 1;
  1311. l.activeDialogue().kongBotMessage("PM chime is ON");
  1312. }
  1313. window.setTimeout(function(){GM_setValue("kong_pmchime", l._pm_chime);}, 0);
  1314. return false;
  1315. });
  1316. try{
  1317. if (GM_setValue){
  1318. var pm_chime = GM_getValue("kong_pmchime", 1);
  1319. }else{
  1320. GM_setValue = function(a,b){};
  1321. var pm_chime = 1;
  1322. }
  1323. }catch(e){
  1324. GM_setValue = function(a,b){};
  1325. var pm_chime = 1;
  1326. }
  1327. holodeck._pm_chime = pm_chime;
  1328. }
  1329. }
  1330. }
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348. //============
  1349. // PM Notifier (MrSpontaneous attribution applies
  1350. // http://userscripts.org/scripts/review/48979
  1351. //============
  1352. function init_chatResizer()
  1353. {
  1354. dom.defaultWidth = 500;
  1355. dom.defaultHeight = 600;
  1356. dom.spaceLeft = 200;
  1357. dom.center = true;
  1358. dom.userListHeight = 100;
  1359.  
  1360.  
  1361.  
  1362.  
  1363. if(!$('maingamecontent')) return;
  1364. var initialOffsetTop = $('maingamecontent').offsetTop + $('chat_tab_pane').offsetTop;
  1365. var initialOffsetLeft = $('maingamecontent').offsetLeft + $('chat_tab_pane').offsetLeft;
  1366. var minimumHeight = parseInt($("game").style.height, 10) - parseInt($('main_tab_set').clientHeight, 10) - 16;
  1367. var minimumWidth = 300;
  1368.  
  1369. if(dom.holodeck){
  1370. var holodeck = dom.holodeck;
  1371. holodeck.addChatCommand("size", function(l, n){
  1372. var m = n.match(/^\/\S+\s+(\S+)/);
  1373. var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
  1374.  
  1375. if(m && m[1] == "reset"){
  1376. l.activeDialogue().kongBotMessage("Resetting size for this game to defaults.");
  1377. window.setTimeout(function(){GM_deleteValue("kong_resize_"+location.pathname)}, 0);
  1378. setWidth(window._defaultChatWidth);
  1379. setHeight(window._defaultChatHeight, window._defaultUserlistHeight, window._currentGameCentered);
  1380.  
  1381. return false;
  1382. } else if(m && m[1] == "show"){
  1383. l.activeDialogue().kongBotMessage("Current chat size: width: " + window._currentChatWidth + "px, height: " + window._currentChatHeight + "px, userlist-height: " + window._currentChatUserlistHeight + "px.");
  1384. return false;
  1385. } else if(!o){
  1386. l.activeDialogue().kongBotMessage("Please specify a width and a height: /size width height. Example: /size 500 500");
  1387. return false;
  1388. }
  1389.  
  1390. var width = parseInt(o[1], 10);
  1391. var height = parseInt(o[2], 10);
  1392. var listHeight = parseInt(o[3]||100, 10);
  1393. var gameHeight = parseInt($('game').style.height, 10);
  1394. if(width < 300){
  1395. l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
  1396. width = 300;
  1397. }
  1398.  
  1399. if(height < gameHeight){
  1400. l.activeDialogue().kongBotMessage("Minimum height is the game's height. Setting height to " + gameHeight + "px.");
  1401. height = gameHeight;
  1402. }
  1403.  
  1404. if(listHeight > height - 200){
  1405. l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
  1406. listHeight = 100;
  1407. }
  1408.  
  1409. window.setTimeout(function(){GM_setValue("kong_resize_"+location.pathname, width+"/"+height+"/"+listHeight)}, 0);
  1410. l.activeDialogue().kongBotMessage("Resizing chat to " + width + "px/" + height + "px/" + listHeight + "px");
  1411. setWidth(width);
  1412. setHeight(height, listHeight, window._currentGameCentered);
  1413.  
  1414. return false;
  1415. });
  1416.  
  1417. holodeck.addChatCommand("defaultsize", function(l, n){
  1418. var m = n.match(/^\/\S+\s+(\S+)/);
  1419. var o = n.match(/^\/\S+\s+(\d+)\s+(\d+)(?:\s+(\d+))?/)
  1420. if(m && m[1] == "reset"){
  1421. l.activeDialogue().kongBotMessage("Resetting default size to 500/600/100");
  1422. window.setTimeout(function(){GM_deleteValue("kong_resize_default")}, 0);
  1423.  
  1424. return false;
  1425. } else if(m && m[1] == "show"){
  1426. l.activeDialogue().kongBotMessage("Current chat size: width: " + window._defaultChatWidth + "px, height: " + window._defaultChatHeight + "px, userlist-height: " + window._defaultUserlistHeight + "px.");
  1427. return false;
  1428. } else if(!o){
  1429. l.activeDialogue().kongBotMessage("Syntax /defaultsize width height userlist-height. userlist-height is optional. Example: /defaultsize 500 500 100");
  1430. }
  1431.  
  1432. var width = parseInt(o[1], 10);
  1433. var height = parseInt(o[2], 10);
  1434. var listHeight = parseInt(o[3]||100, 10);
  1435. if(width < 300){
  1436. l.activeDialogue().kongBotMessage("Minimum width is 300. Setting width to 300px.");
  1437. width = 300;
  1438. }
  1439.  
  1440. if(listHeight > height){
  1441. l.activeDialogue().kongBotMessage("Userlist height is too large. Setting it to 100px");
  1442. listHeight = 100;
  1443. }
  1444.  
  1445. window.setTimeout(function(){GM_setValue("kong_resize_default", width+"/"+height+"/"+listHeight)}, 0);
  1446. l.activeDialogue().kongBotMessage("Set default values to width: " + width + "px, height: " + height + "px, userlist-height: " + listHeight + "px.");
  1447.  
  1448. return false;
  1449. });
  1450.  
  1451. holodeck.addChatCommand("centergame", function(l, n){
  1452. var center = !window._currentGameCentered;
  1453. if(center){
  1454. l.activeDialogue().kongBotMessage("Now centering the game");
  1455. } else {
  1456. l.activeDialogue().kongBotMessage("Now aligning the game to the chat's bottom");
  1457. }
  1458. window.setTimeout(function(){GM_setValue("kong_resize_center", center?1:0)}, 0);
  1459.  
  1460. centerGame(center);
  1461.  
  1462. return false;
  1463. });
  1464.  
  1465. }
  1466.  
  1467. var getString = "", centerVal = -1, defaults = "";
  1468. getString = GM_getValue("kong_resize_"+location.pathname, "");
  1469. centerVal = GM_getValue("kong_resize_center", -1);
  1470. defaults = GM_getValue("kong_resize_default", "");
  1471.  
  1472. if(defaults){
  1473. var splitArr = defaults.split("/");
  1474. defaultWidth = parseInt(splitArr[0], 10)||defaultWidth;
  1475. defaultHeight = parseInt(splitArr[1], 10)||defaultHeight;
  1476. userListHeight = parseInt(splitArr[2], 10)||userListHeight;
  1477. }
  1478.  
  1479. window._defaultChatWidth = defaultWidth;
  1480. window._defaultChatHeight = defaultHeight;
  1481. window._defaultUserlistHeight = userListHeight;
  1482.  
  1483. var x = defaultWidth, y = defaultHeight, l = userListHeight, cg = center, override = false;
  1484.  
  1485. if(centerVal != -1){
  1486. cg = (centerVal == 1);
  1487. }
  1488.  
  1489. if(getString){
  1490. var splitArr = getString.split("/");
  1491. x = parseInt(splitArr[0], 10)||defaultWidth;
  1492. y = parseInt(splitArr[1], 10)||defaultHeight;
  1493. l = parseInt(splitArr[2], 10)||userListHeight;
  1494. override = true;
  1495. }
  1496.  
  1497. var gameWidth = parseInt($('game').style.width, 10);
  1498. var gameHeight = parseInt($('game').style.height, 10);
  1499.  
  1500. if(x > minimumWidth){
  1501. if(override || gameWidth + x < screen.width - spaceLeft){ // enough place to resize to specified width
  1502. setWidth(x);
  1503. }else{ // resize as far as possible
  1504. var chatWidth = screen.width - gameWidth - spaceLeft;
  1505. if(chatWidth > minimumWidth) setWidth(chatWidth);
  1506. }
  1507. }
  1508.  
  1509. if(y > minimumHeight && y > gameHeight){
  1510. setHeight(y, l, cg);
  1511. } else {
  1512. setHeight(gameHeight, l, cg);
  1513. }
  1514. }
  1515.  
  1516. function centerGame(center){
  1517. window._currentGameCentered = center;
  1518. if(center){
  1519. var gameHeight = parseInt($('game').style.height, 10);
  1520. var mainHeight = parseInt($("maingame").style.height, 10);
  1521. $('game').style.top = (mainHeight - gameHeight)/2+"px"
  1522. $('game').style.position = "relative";
  1523. }else{
  1524. $('game').style.bottom = "0px";
  1525. $('game').style.top = "";
  1526. $('game').style.position = "absolute";
  1527. }
  1528. }
  1529. function setHeight(height, userListHeight, center){
  1530. if(!userListHeight) userListHeight = 100;
  1531.  
  1532. window._currentChatHeight = height;
  1533. window._currentChatUserlistHeight = userListHeight;
  1534.  
  1535. var quicklinksHeight = $('quicklinks') ? $('quicklinks').parentNode.clientHeight : 26;
  1536. var maintabHeight = $('main_tab_set').clientHeight;
  1537.  
  1538. var tabPaneHeight = height - 16;
  1539. var mainHeight = height + quicklinksHeight + maintabHeight;
  1540. var gameHeight = parseInt($('game').style.height, 10);
  1541.  
  1542. $("maingame").style.height = mainHeight + "px";
  1543. $("maingamecontent").style.height = mainHeight + "px";
  1544. $("flashframecontent").style.height = mainHeight + "px";
  1545. $("chat_container").style.height = (height + maintabHeight) + "px";
  1546. $("user_mini_profile_container").style.height = (height - 65) + "px";
  1547. $("user_mini_profile").style.height = (height - 65) + "px";
  1548.  
  1549. var messageWindows = $$(".chat_message_window");
  1550. for(var i = 0; i < messageWindows.length; i++){
  1551. messageWindows[i].style.height = (tabPaneHeight - userListHeight - 93)+"px"; // 93 = roomname, users in room etc.
  1552. }
  1553.  
  1554. var usersInRoom = $$(".users_in_room");
  1555. for(i = 0; i < usersInRoom.length; i++){
  1556. usersInRoom[i].style.height = userListHeight + "px";
  1557. }
  1558.  
  1559. var roomsList = $$(".rooms_list");
  1560. for(i = 0; i < roomsList.length; i++){
  1561. roomsList[i].style.height = (height - 79)+"px";
  1562. }
  1563.  
  1564. z = $("kong_game_ui").childNodes;
  1565. for(i=0;i<z.length;i++){
  1566. if(z[i].nodeName=="DIV"){
  1567. z[i].style.height = tabPaneHeight + "px";
  1568. }
  1569. }
  1570. if(center != -1 && center !== undefined)
  1571. centerGame(center);
  1572. }
  1573.  
  1574. function setWidth(width){
  1575. window._currentChatWidth = width;
  1576. var gameWidth = parseInt($("game").style.width, 10);
  1577. $("maingame").style.width = (gameWidth + 3 + width) + "px";
  1578. $("maingamecontent").style.width = (gameWidth + 3 + width) + "px";
  1579. $("flashframecontent").style.width = (gameWidth + 3 + width) + "px";
  1580. $("chat_container").style.width = width + "px";
  1581. $('chat_window_spinner').style.right = width/2 - 38 + "px";
  1582. if($('high_scores_spinner'))
  1583. $('high_scores_spinner').style.right = width/2 - 38 + "px";
  1584. var ui = $("kong_game_ui");
  1585. z = ui.childNodes
  1586. for(i=0;i<z.length;i++){
  1587. if(z[i].tagName == "DIV")
  1588. z[i].style.width = (width - 17) + "px";
  1589. }
  1590. $A(ui.querySelectorAll("textarea.chat_input")).forEach(function(el){
  1591. el.style.width = (width - 21) + "px";
  1592. });
  1593. }
  1594.  
  1595. function $A(c){
  1596. return [].slice.call(c);
  1597. }
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620. }
  1621.  
  1622.  
  1623.  
  1624.  
  1625. // This injects our script onto the page.
  1626. // Kinda borrowed from http://userscripts.org/scripts/review/125666
  1627. // Borrowed from: http://stackoverflow.com/a/2303228
  1628. var script = document.createElement('script');
  1629. script.appendChild(document.createTextNode('('+ main +')();'));
  1630. (document.body || document.head || document.documentElement).appendChild(script);