Monster Twitch

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

当前为 2014-05-04 提交的版本,查看 最新版本

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