Monster Twitch

Streches stream to max width and hides left navigation bar with an 'M' toggle on the bottom right

目前为 2014-05-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Monster Twitch
  3. // @namespace http://enut.co/dev
  4. // @author Tracerman
  5. // @version 2.760
  6. // @description Streches stream to max width and hides left navigation bar with an 'M' toggle on the bottom right
  7. // @include http://*.twitch.tv/*
  8. // @include http://twitch.tv/*
  9. // @exclude http://www.twitch.tv/directory*
  10. // @exclude http://www.twitch.tv/*/chat?popout=
  11. // @exclude http://www.twitch.tv/*/popout
  12. // @exclude http://www.twitch.tv/*/dashboard
  13. // @exclude http://www.twitch.tv/inbox*
  14. // @exclude http://www.twitch.tv/subscriptions*
  15. // @exclude http://store.twitch.tv
  16. // @exclude http://api.twitch.tv/*
  17. // @exclude https://api.twitch.tv/*
  18. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
  19. // @grant GM_addStyle
  20. // @copyright 2014+, tracerman
  21. // ==/UserScript==
  22.  
  23. function ChatWFix(){
  24. GM_addStyle ( multilineStr ( function () {/*!
  25. #right_col:before {
  26. left: 0px
  27. }
  28. */} ) );
  29. $(".segmented_tabs").css("z-index", "4");
  30. $("#right_col .top").css("z-index", "4");
  31. console.log("TM: Chat Left Position Fixed");
  32. }
  33.  
  34. setTimeout(function () {ChatWFix()}, 5000);
  35.  
  36. $("#player").ready(function() {
  37. var showCheck3 = 0;
  38. var zNode3 = document.createElement ('div');
  39. var pHeight = $(".dynamic-player").css("height");
  40. var intHeight = $(".chat-interface").css("height");
  41. var bHeight = $('#left_col').css("width");
  42. var cHeight = $('#right_col').css("width");
  43. var cDisp = $('#right_col').css("display");
  44. var conWidth = $('#content').css("width");
  45. var tHeight = $('#main_col').css("margin-left");
  46. var zHeight = $('#main_col').css("margin-right");
  47. var mrCheck = $('#main_col').css("margin-right");
  48. var zWidth = $('#main_col').css("width");
  49. var ZWidthCheck = zWidth;
  50. var chatInt = $(".chat-interface").css("background-color");
  51. var chatHeight = $('#chat').css("width");
  52. var chatLHeight = $('#chat_line').css("width");
  53. var chatLLHeight = $('#chat_line_list').css("width");
  54. var chatLLPadding = $('#chat_line_list').css("padding");
  55. var chatLeft;
  56.  
  57.  
  58. zNode3.innerHTML = '<button id="myButton3" type="button">'
  59. + '</button>';
  60.  
  61. zNode3.setAttribute ('id', 'myContainer3');
  62. document.getElementById('player').appendChild(zNode3);
  63. //--- Activate the newly added button.
  64. document.getElementById ("myButton3").addEventListener (
  65. "click", ButtonClickAction, false
  66. );
  67. function ButtonClickAction (zEvent) {
  68. if(showCheck3 == 1) {
  69. $("#channel").removeAttr('style');
  70. $("#chat_line_list").each(function () {
  71. this.style.setProperty("padding", chatLLPadding, "important");
  72. });
  73. $("#chat_line_list").each(function () {
  74. this.style.setProperty("padding", chatLLPadding);
  75. });
  76. $("#left_col").show(300, "swing");
  77. $(".editable").show(300, "swing");
  78. $("#channel_panels_contain").show(300, "swing");
  79. $(".stats-and-actions").show(300, "swing");
  80. $(".resizer").show(300, "swing");
  81. $("#right_close").show(300, "swing");
  82. $("#right_col").each(function () {
  83. this.style.setProperty("width", "", "important");
  84. });
  85. $("#right_col").each(function () {
  86. this.style.setProperty("width", cHeight);
  87. });
  88. $("#main_col").removeAttr('style');
  89. $("#main_col").each(function () {
  90. this.style.setProperty("margin-left", "", "important");
  91. });
  92. $("#main_col").css("margin-left","");
  93.  
  94. $("#main_col").each(function () {
  95. this.style.setProperty("width", "", "important");
  96. });
  97. if (cDisp == "block") {
  98. $("#main_col").each(function () {
  99. this.style.setProperty("margin-right", "");
  100. });
  101. }
  102. else {
  103. $("#main_col").each(function () {
  104. this.style.setProperty("width", "");
  105. });
  106. }
  107. if(zWidth >= 1) {
  108. $("#main_col").each(function () {
  109. this.style.setProperty("width", "");
  110. this.style.setProperty("margin-right", "");
  111. });
  112. }
  113. else {
  114. $("#main_col").css("width", "");
  115. }
  116. $(".dynamic-player").removeAttr("style");
  117. $("#player").each(function () {
  118. this.style.setProperty("position", "relative");
  119. });
  120. $("#content").each(function () {
  121. this.style.setProperty("width", "", "important");
  122. });
  123. $("#content").each(function () {
  124. this.style.setProperty("width", conWidth);
  125. });
  126. $("#chat").each(function () {
  127. this.style.setProperty("width", "", "important");
  128. });
  129. $("#chat").each(function () {
  130. this.style.setProperty("width", chatHeight);
  131. });
  132. $("#chat_line").each(function () {
  133. this.style.setProperty("width", "", "important");
  134. });
  135. $("#chat_line").each(function () {
  136. this.style.setProperty("width", chatLHeight);
  137. });
  138. $("#chat_line_list").each(function () {
  139. this.style.setProperty("width", "", "important");
  140. });
  141. $("#myContainer3").fadeTo("fast", 0.5).css({"background":"url('http://i61.tinypic.com/qq1hy1.png')"}).delay(300).css({"box-shadow":"inset 0 0 20px rgb(138, 138, 138)"});
  142. //--- Old Chat Button
  143. $("#chat_speak").animate({"width":"149px"}, "fast");
  144. //--- New Chat Button
  145. $(".send-chat-button").css("width", "").css("left", chatLeft);
  146. $("button.primary_button").css("background", "");
  147. $("button.primary_button").removeAttr("style");
  148. // Show the video bar
  149. $("#twitch_chat").animate({"top":"51px"}, "fast");
  150. $("#chat").each(function () {
  151. this.style.setProperty("top", "51px", "important");
  152. });
  153. $("#archives").animate({"top":"51px"}, "fast");
  154. //--- Chat Bottom
  155. $(".chat-messages").removeAttr("style");
  156. $(".chat-buttons-container").css("top", "");
  157. //--- Old Buttons Border
  158. $(".dropdown_glyph").css("border", "", "important").css("box-shadow", "", "important");
  159. //--- New Buttons Border
  160. $("button.settings").css("margin-right", "").css("border", "", "important").css("box-shadow", "", "important");
  161. $("button.settings").removeAttr("style");
  162. $("button.viewers").css("margin-right", "").css("border", "", "important").css("box-shadow", "", "important");
  163. $("button.viewers").removeAttr("style");
  164. $("button.emotemenu").css("margin-right", "").css("margin-left", "").css("border", "", "important").css("box-shadow", "", "important");
  165. $("button.emotemenu").removeAttr("style");
  166. //--- Chat Background
  167. $(".chat-messages").css("background", "");
  168. //--- New Chat Interface Features
  169. $(".chat-interface").css("background", "").css("border", "", "important").css("box-shadow", "", "!important");
  170. $(".chat-interface").each(function () {
  171. this.style.setProperty("height", intHeight, "important");
  172. });
  173. $(".textarea-contain").css("border", "");
  174. $(".segmented_tabs").css({"visibility":"visible"}).css({"z-index":"4"});
  175. $("#right_col .top").css({"z-index":"4"});
  176. showCheck3 = 2;
  177. }
  178. else if(showCheck3 == 0) {
  179. pHeight = $(".dynamic-player").css("height");
  180. bHeight = $('#left_col').css("width");
  181. cHeight = $('#right_col').css("width");
  182. conWidth = $('#content').css("width");
  183. tHeight = $('#main_col').css("margin-left");
  184. zHeight = $('#main_col').css("margin-right");
  185. chatHeight = $('#chat').css("width");
  186. chatLHeight = $('#chat_line').css("width");
  187. chatLLHeight = $('#chat_line_list').css("width");
  188. chatLLPadding = $('#chat_line_list').css("padding");
  189. cDisp = $('#right_col').css("display");
  190. zWidth = $('#main_col').css("width");
  191. chatLeft= $('.send-chat-button').css("left");
  192. intHeight = $(".chat-interface").css("height");
  193. $("#channel").each(function () {
  194. this.style.setProperty("padding", "0 0 0 0", "important");
  195. });
  196. $("#chat_line_list").each(function () {
  197. this.style.setProperty("padding", "0 0 0", "important");
  198. });
  199. $(".editable").hide(300, "swing");
  200. $("#left_col").hide(300, "swing");
  201. $(".resizer").hide(300, "swing");
  202. $("#channel_panels_contain").hide(300, "swing");
  203. $(".stats-and-actions").hide(300, "swing");
  204. $(".dynamic-player, .dynamic-player object, .dynamic-player video").each(function () {
  205. this.style.setProperty("height", "100%", "important");
  206. this.style.setProperty("width", "100%", "important");
  207. });
  208. $(".dynamic-player").each(function () {
  209. this.style.setProperty("height", "100%", "important");
  210. this.style.setProperty("width", "100%", "important");
  211. });
  212. $("#player").each(function () {
  213. this.style.setProperty("position", "absolute");
  214. });
  215. //--- Scroll Top Test
  216. $(".tse-scroll-content").scrollTop(0);
  217. //--- End Test
  218.  
  219. if (cDisp == "block") {
  220. $("#content").each(function () {
  221. this.style.setProperty("width", "275px", "important");
  222. });
  223. $("#right_col").each(function () {
  224. this.style.setProperty("width", "275px", "important");
  225. });
  226. $("#chat").animate({"width":"275px"}, "fast");
  227. $("#chat_line_list").css({"width":""});
  228. $("#chat_line").animate({"width":"272px"}, "fast");
  229.  
  230. $("#main_col").each(function () {
  231. this.style.setProperty("margin-right", "275px", "important");
  232. this.style.setProperty("width", "");
  233. });
  234. $(".segmented_tabs").css({"visibility":"hidden"});
  235. $("#right_col .top").css({"z-index":"inherit"});
  236. $("#twitch_chat").css({"top":"0px"});
  237. $("#chat").each(function () {
  238. this.style.setProperty("top", "0px", "important");
  239. });
  240. $("#archives").animate({"top":"0px"}, "fast");
  241. //--- Old Chat Button
  242. $("#chat_speak").animate({"width":"84px"}, "fast");
  243. //--- New Chat Button
  244. $(".send-chat-button").css("width", "120px").css("left", "auto");
  245. $("button.primary_button").css("background", "black");
  246. $("button.primary_button").each(function () {
  247. this.style.setProperty("border", "2px solid #6441a5", "important");
  248. });
  249. //--- Chat Background
  250. $(".chat-messages").css("background", "white");
  251. //--- Chat Bottom
  252. $(".chat-messages").each(function () {
  253. this.style.setProperty("bottom", "110px", "important");
  254. });
  255. $(".chat-buttons-container").css("top", "70px");
  256. //--- New Chat Interface Features
  257. $(".chat-interface").css("background", "white").css("border", "1px solid #6441a5", "important").css("box-shadow", "1px 1px 1px rgb(100, 65, 165), 0px 1px 0px rgba(0, 0, 0, 0.15) inset", "!important");
  258. $(".chat-interface").each(function () {
  259. this.style.setProperty("height", "110px", "important");
  260. });
  261. $(".textarea-contain").css("border", "2px solid rgb(100, 65, 165)");
  262. }
  263. else {
  264. $("#content").each(function () {
  265. this.style.setProperty("width", "0px", "important");
  266. });
  267. $("#right_col").each(function () {
  268. this.style.setProperty("width", "0px", "important");
  269. });
  270. $("#main_col").each(function () {
  271. this.style.setProperty("margin-right", "0px", "important");
  272. this.style.setProperty("width", "100%", "important");
  273. });
  274. }
  275. if (zWidth > 0) {
  276. $("#main_col").each(function () {
  277. this.style.setProperty("width", "100%", "important");
  278. });
  279. }
  280. else {
  281. this.style.setProperty("width", "", "important");
  282. }
  283. $("#main_col").each(function () {
  284. this.style.setProperty("margin-left", "0px", "important");
  285. });
  286. $("#right_close").hide(300, "swing");
  287. //--- Old Buttons Border
  288. $(".dropdown_glyph").css("border", "1px solid #6441a5", "important").css("box-shadow", "1px 1px 1px rgb(100, 65, 165), 0px 1px 0px rgba(0, 0, 0, 0.15) inset", "!important");
  289. //--- New Buttons Border
  290. $("button.settings").css("margin-right", "2px");
  291. $("button.settings").each(function () {
  292. this.style.setProperty("border", "2px solid #6441a5", "important");
  293. this.style.setProperty("box-shadow", "1px 1px 1px rgb(100, 65, 165), 0px 1px 0px rgba(0, 0, 0, 0.15) inset", "important");
  294. });
  295. $("button.viewers").css("margin-right", "2px");
  296. $("button.viewers").each(function () {
  297. this.style.setProperty("border", "2px solid #6441a5", "important");
  298. this.style.setProperty("box-shadow", "1px 1px 1px rgb(100, 65, 165), 0px 1px 0px rgba(0, 0, 0, 0.15) inset", "important");
  299. });
  300. $("button.emotemenu").css("margin-right", "2px");
  301. $("button.emotemenu").each(function () {
  302. this.style.setProperty("margin-left", "0px", "important");
  303. this.style.setProperty("border", "2px solid #6441a5", "important");
  304. this.style.setProperty("box-shadow", "1px 1px 1px rgb(100, 65, 165), 0px 1px 0px rgba(0, 0, 0, 0.15) inset", "important");
  305. });
  306. $("#myContainer3").fadeTo("fast", 1.0).css({"background":"url('http://i61.tinypic.com/ri80w5.png')"}).delay(300).css({"box-shadow":"inset 0 0 20px black"});
  307. showCheck3 = 1;
  308. }
  309. else if(showCheck3 == 2) {
  310. if (cDisp == "block") {
  311. $("#main_col").each(function () {
  312. this.style.setProperty("margin-right", zHeight);
  313. });
  314. }
  315. else {
  316. $("#main_col").each(function () {
  317. this.style.setProperty("margin-right", "0px");
  318. this.style.setProperty("width", "");
  319. });
  320. }
  321. $("#main_col").each(function () {
  322. this.style.setProperty("margin-left", tHeight);
  323. });
  324. $("#main_col").css("width", "");
  325. if (cDisp == "block") {
  326. $("#main_col").each(function () {
  327. this.style.setProperty("margin-right", "340px");
  328. });
  329. }
  330. else {
  331. $("#main_col").css("margin-right", "0", "important");
  332. }
  333. $("#myContainer3").fadeTo("fast", 0.5).delay(300).css({"box-shadow":"inset 0 0 20px navy"});
  334. showCheck3 = 0;
  335. }
  336. else if(showCheck3 == 3) {
  337. }
  338. }
  339. });
  340.  
  341. //--- Style our newly added elements using CSS.
  342. GM_addStyle ( multilineStr ( function () {/*!
  343. #myContainer3 {
  344. position: absolute;
  345. background: url("http://i57.tinypic.com/10dxqhc.png");
  346. background-size: contain !important;
  347. box-shadow: inset 0 0 20px black;
  348. bottom: 0;
  349. left: 0;
  350. font-size: 13px;
  351. border: 0px outset black;
  352. margin-left: 160px;
  353. margin-bottom: 0px;
  354. opacity: 0.5;
  355. width: 27px !important;
  356. height: 27px !important;
  357. z-index: 999;
  358. padding: 0px 0px;
  359. }
  360. #myButton3 {
  361. cursor: pointer;
  362. background: transparent;
  363. border: none !important;
  364. width: 27px !important;
  365. height: 27px !important;
  366. color: purple;
  367. font-weight: bold;
  368. }
  369. #myContainer3 p {
  370. color: purple;
  371. background: transparent;
  372. }
  373. */} ) );
  374.  
  375. function multilineStr (dummyFunc) {
  376. var str = dummyFunc.toString ();
  377. str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
  378. .replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
  379. //--- .replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
  380. ;
  381. return str;
  382. }