Fullscreen Chat *OLD*

Adds a command to hide the game and expand chat

  1. // ==UserScript==
  2. // @name Fullscreen Chat *OLD*
  3. // @namespace tag://kongregate
  4. // @description Adds a command to hide the game and expand chat
  5. // @author Ventero
  6. // @include *://www.kongregate.com/*
  7. // @date 06/29/10
  8. // @version 1.5.1
  9. // require http://kong.ventero.de/updates/70076.js
  10. // @license MIT license
  11. // ==/UserScript==
  12.  
  13. // Written by Ventero (http://www.kongregate.com/accounts/Ventero) 02/27/10
  14. // Based on an idea by SavageWolf (http://www.kongregate.com/accounts/SavageWolf - http://www.wolfthatissavage.com)
  15. // Licensed under MIT/X11 license
  16. // Copyright (c) 2010-2012 Ventero
  17. // Full text of the license here:
  18. // http://www.opensource.org/licenses/mit-license.php
  19.  
  20. function init_resize(){
  21.  
  22. var dom = (typeof unsafeWindow === "undefined"?window:unsafeWindow);
  23.  
  24. function d(c){
  25. return document.getElementById(c);
  26. }
  27.  
  28. if(!d("maingame")) return;
  29.  
  30. function setWidth(width, gamewidth){
  31. d("maingame").style.width = (gamewidth + width) + "px";
  32. d("maingamecontent").style.width = (gamewidth + width) + "px";
  33. d("flashframecontent").style.width = (gamewidth + width) + "px";
  34. d("chat_container").style.width = width + "px";
  35. d('chat_window_spinner').style.right = width/2 - 38 + "px";
  36. if(d('high_scores_spinner'))
  37. d('high_scores_spinner').style.right = width/2 - 38 + "px";
  38. z = d("kong_game_ui").childNodes
  39. for(i=0;i<z.length;i++){
  40. if(z[i].tagName == "DIV")
  41. z[i].style.width = (width - 17) + "px";
  42. }
  43. }
  44.  
  45. function p(a){
  46. return parseInt(d(a).style.width, 10);
  47. }
  48.  
  49. var isIFrame = !document.getElementById("game_wrapper")
  50. var wrapper = isIFrame?"gameiframe":"game_wrapper";
  51. var initialized = false;
  52.  
  53. function initOrigValues(){
  54. window.__oldWidth = p("chat_container");
  55. window.__gameHolderWidth = p("gameholder");
  56. window.__gameWrapperWidth = p(wrapper);
  57. window.__gameWidth = p("game");
  58. initialized = true;
  59. }
  60.  
  61. dom.resizeChat = function(){
  62. if(!initialized) initOrigValues();
  63. if(p("game") == 0){
  64. d("chat_container").style.marginLeft = "3px";
  65. d("gameholder").style.width = window.__gameHolderWidth + "px";
  66. d("game").style.width = window.__gameWidth + "px";
  67. d(wrapper).style.width = window.__gameWrapperWidth + "px";
  68. if(!isIFrame)
  69. d("gamediv").width = window.__gameDivWidth;
  70. if(typeof dom.__setChatWidth === "function")
  71. dom.__setChatWidth(window.__oldWidth);
  72. else
  73. setWidth(window.__oldWidth, window.__gameWidth + 3);
  74. } else {
  75. d("chat_container").style.marginLeft = "0px";
  76. d("gameholder").style.width = "0px";
  77. d("game").style.width = "0px";
  78. d(wrapper).style.width = "0px";
  79. if(!isIFrame){
  80. window.__gameDivWidth = d("gamediv").width;
  81. d("gamediv").width = 0;
  82. }
  83. if(typeof dom.__setChatWidth === "function")
  84. dom.__setChatWidth(p("flashframecontent"));
  85. else
  86. setWidth(p("flashframecontent"), 0);
  87. }
  88. }
  89. }
  90.  
  91. // ugly workaround because Chrome doesn't fire onclick for <option>s
  92. var isChrome = /Chrome/.test(navigator.appVersion);
  93. if(isChrome){
  94. var inject = document.createElement("script");
  95. var head = document.getElementsByTagName("head")[0];
  96. inject.type = "text/javascript";
  97. inject.textContent = init_resize.toString() + "\ninit_resize();";
  98. (head || document.body).appendChild(inject);
  99. } else {
  100. init_resize();
  101. }
  102.  
  103. var call = document.createElement("option");
  104. call.setAttribute("class","action");
  105. call.setAttribute("value", "resize_chat");
  106. call.setAttribute("onclick","resizeChat();");
  107. call.innerHTML = "Fullscreen Chat";
  108.  
  109. var template = document.getElementById("chat_actions_dropdown_template");
  110. var container = document.createElement("div");
  111. container.appendChild(call);
  112. template.innerHTML = template.innerHTML.replace("</select>", container.innerHTML + "</select>");
  113.  
  114. [].slice.call(document.querySelectorAll(".chat_actions_container")).forEach(function(n){
  115. var c = n.querySelector("select");
  116. if(c) {
  117. c.appendChild(call);
  118. if(isChrome)
  119. c.setAttribute("onchange", "if(this.getValue() == 'resize_chat') resizeChat();");
  120. }
  121. });

QingJ © 2025

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