v4c/InstaSynch Additional Features

gives many additional features on instasynch. created by biggles, unless otherwise noted in script source.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greatest.deepsurf.us/scripts/7323/30758/v4cInstaSynch%20Additional%20Features.js

  1. // ==UserScript==
  2. // @name v4c/InstaSynch Additional Features
  3. // @namespace v4c
  4. // @description gives many additional features on instasynch. created by biggles, unless otherwise noted in script source.
  5. // @locale en
  6. // @include *://*.instasynch.com/*
  7. // @include *://instasynch.com/*
  8. // @match *://*.instasynch.com/*
  9. // @match *://instasynch.com/*
  10. // @require https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js
  11. // @require http://openuserjs.org/src/libs/TimidScript/TSL_-_jsColorGM.js
  12. // @version 1.886
  13. // @grant none
  14. // @author biggles
  15. // ==/UserScript==
  16.  
  17. //REL 1.886
  18.  
  19. //Created by biggles; very few parts used from other sources, where they are given credit. Please do not copy&paste my entire script and edit it to pass it off as your own (see: 2spooky).
  20. //Edited by Snoop_Dank, Added a few emotes. I Take no credit for this script.
  21.  
  22. /*
  23. <InstaSynch - Watch Videos with friends.>
  24. Copyright (C) 2013-2014 InstaSynch
  25.  
  26. <Instasynch modified code>
  27. Copyright (C) 2013-2014 biggles (unless otherwise noted)
  28.  
  29. This program is free software: you can redistribute it and/or modify
  30. it under the terms of the GNU General Public License as published by
  31. the Free Software Foundation, either version 3 of the License, or
  32. (at your option) any later version.
  33.  
  34. This program is distributed in the hope that it will be useful,
  35. but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. GNU General Public License for more details.
  38.  
  39. You should have received a copy of the GNU General Public License
  40. along with this program. If not, see <http://www.gnu.org/licenses/>.
  41.  
  42. http://opensource.org/licenses/GPL-3.0
  43. */
  44.  
  45. window.secondsToTime = function(num) {
  46. var hours = Math.floor(num / 3600);
  47. var minutes = Math.floor((num - (hours * 3600)) / 60);
  48. var seconds = num - (hours * 3600) - (minutes * 60);
  49.  
  50. if (minutes < 10 && hours > 0)
  51. minutes = "0" + minutes;
  52.  
  53. if (seconds < 10)
  54. seconds = "0" + seconds;
  55.  
  56. var time = "";
  57. if (hours !== 0)
  58. time += hours + ':';
  59.  
  60. time += minutes + ':' + seconds;
  61. return time;
  62. };
  63. var postConnect = [];
  64. var reconnectFns = [];
  65.  
  66. loadedFunctions = loadedGlobalVariables = loadedCSS = loadedConnected = loadedCookies = loadedClock = loadedChatListeners = loadedEmoteMenu = loadedHTML = loadedBinds = initialLoad = false;
  67.  
  68. window.postConnectDo = function(a) { /* modified postConnect, originally by Faqqq */
  69. // bool a: if false, use initial function list
  70. // else, load functions in the reconnect list (used when changing rooms)
  71.  
  72. if ($('.users #userlist li').length < 1) {
  73. setTimeout(function() {
  74. postConnectDo(initialLoad);
  75. }, 100);
  76. return;
  77. }
  78. if (!a) {
  79. for (var i = 0; i < postConnect.length; i++) {
  80. postConnect[i]();
  81. }
  82. initialLoad = true;
  83. } else {
  84. for (var i = 0; i < reconnectFns.length; i++) {
  85. reconnectFns[i]();
  86. }
  87. }
  88. }
  89.  
  90. window.reloadFunctions = function() {
  91.  
  92. }
  93.  
  94. $('head').append('<link rel="stylesheet" type="text/css" href="https://googledrive.com/host/0B2hdmKDeA0HDak92NTA2amhMZ2s?v=001"/>');
  95.  
  96. function loadGlobalVariables() {
  97. window.scriptVer = "1.886";
  98. window.maxemotes = window.MAXLOGS = window.MAXFAST = 4;
  99. currentVid = '';
  100. isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  101. chenSound = new Audio('http://drowngaben.x10.mx/unused/bikehorn.ogg');
  102. dootSound = new Audio('http://drowngaben.x10.mx/unused/dootdoot.mp3');
  103. chadSound = new Audio('http://drowngaben.x10.mx/unused/gayniggas.mp3');
  104. noSound = new Audio('http://drowngaben.x10.mx/unused/no.mp3');
  105. window.emoteSounds = {chen: chenSound, doot: dootSound, chad: chadSound, no: noSound};
  106. logTraffic = logVids = impone = showRoll = sameUserMessages = useColons = true;
  107. logs = fastmsgs = 0;
  108. recentVidInfo = [];
  109. marqueeSpeed = 50;
  110. autoClean = isv4c = largePlayer = largerPlayer = shuffling = false;
  111. loadedGlobalVariables = true;
  112. stageBase = 675;
  113. userStyleList = ['registered ', 'registered um0 ', 'registered um1 ', 'registered ummb ', 'registered umbiggles '];
  114. customUsers = ['manboss'];
  115. eight_choices = [
  116. "It is certain",
  117. "It is decidedly so",
  118. "Without a doubt",
  119. "Yes - definitely",
  120. "You may rely on it",
  121. "As I see it, yes",
  122. "Most likely",
  123. "Outlook good",
  124. "Signs point to yes",
  125. "Yes",
  126. "Ask again later",
  127. "Better not tell you now",
  128. "Cannot predict now",
  129. "Don't count on it",
  130. "My reply is no",
  131. "My sources say no",
  132. "Outlook not so good",
  133. "Very doubtful",
  134. "Never",
  135. "Of course not"
  136. ];
  137. }
  138.  
  139. function loadCSS() {
  140.  
  141. loadedCSS = true;
  142. $('.scriptCSS').remove();
  143. switch ($.cookie('largePlayerSetting')) {
  144. case '0':
  145. largePlayer = false;
  146. largerPlayer = false;
  147. $('.jspContainer').attr('style', 'width: 536px; height: 327px;');
  148. break;
  149. case '1':
  150. largePlayer = true;
  151. largerPlayer = false;
  152. $('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDVHVVWFBoMzZqdUU?d=20140526&v=000" type="text/css" />');
  153. stageBase = 890;
  154. $('.jspContainer').attr('style', 'width: 735px; height: 398px;');
  155. $('#videos').attr('style', 'width: 739px');
  156. break;
  157. case '2':
  158. largePlayer = false;
  159. largerPlayer = true;
  160. $('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDSkxuR1J0MUppRnc?d=20140526&v=000" type="text/css" />');
  161. stageBase = 1393;
  162. $('.jspContainer').attr('style', 'width: 1346px; height: 519px;');
  163. $('#videos').attr('style', 'width: 1350px');
  164. break;
  165. }
  166. }
  167.  
  168. function connected() {
  169.  
  170. loadedConnected = true;
  171.  
  172. addMessage({username:'[v' + scriptVer + ']Script'}, '<span style="font-weight:bold; color:#23B323">Loaded.</span>', 'system');
  173. isMod = false;
  174. if (userInfo['permissions'] > 0)
  175. isMod = true;
  176. //window.scrollTo(0, 120);
  177.  
  178. $('.stage').height(stageBase);
  179. setTimeout(function() {
  180. var names = {};
  181. if (isv4c)
  182. names = {
  183. manboss: 'manboss',
  184. captainfalcon: 'user_cap',
  185. grinsly: 'grins',
  186. gingersnap: 'ginger',
  187. biggles: 'biggles'
  188. };
  189. names[ROOMNAME.toLowerCase()] = 'admin';
  190. for (var k = 0; k < users.length; k++) {
  191. var i = $('#userlist li').eq(k);
  192. var j = $('#userlist li')[k].textContent.toLowerCase();
  193. if (j in names) {
  194. i.addClass(names[j]);
  195. }
  196. }
  197. }, 1000);
  198. }
  199.  
  200. loadFunctions = function() {
  201.  
  202. loadedFunctions = true;
  203. window.setMediaShadow = function(a) { // a = video provider
  204. var shadows = {'youtube': '#CC181E', 'vimeo': '#00ADEF', 'twitch': '#B9A3E3', 'dailymotion': '#FF0'}
  205. if (a in shadows)
  206. $('#media').css('box-shadow', '0 0 10px ' + shadows[a]);
  207. }
  208. window.playVideo = function(vidinfo, time, playing) {
  209. var addedby,title;
  210. addedby = title = '';
  211. var indexOfVid = getVideoIndex(vidinfo);
  212. if (indexOfVid > -1) {
  213. if (mediashadow)
  214. setMediaShadow(vidinfo.provider);
  215. title = checkEmote(playlist[indexOfVid].title);
  216. addedby = playlist[indexOfVid].addedby;
  217. $('.video.active .video-info').css('color', '#888');
  218. $('.video.active .video-info .duration').css('color', '#888');
  219. $('.video.active').removeClass('active');
  220. $($('#video-list').children('li')[indexOfVid]).addClass('active');
  221. $('.video.active .video-info').css('color', '#000');
  222. $('.video.active .video-info .duration').css('color', '#000');
  223. $('#vidTitle').html(title + ' <div class=\'via\'> via ' + addedby + '</div>');
  224. $('#vidTitle .via').css('color', '#ccc');
  225. updateRecent(indexOfVid);
  226. setTabTitle(vidinfo, addedby, indexOfVid);
  227. video.play(vidinfo, time, playing);
  228. $('#skip-count').attr('style', 'color: #fff!important');
  229. if (autoClean && isMod) {
  230. setTimeout(function() {
  231. if (indexOfVid == 1)
  232. global.sendcmd('clean', null);
  233. }, 1000);
  234. }
  235. var bgtimer = '';
  236. if (playlist[indexOfVid].info.id == 'IniyZZqlcwA') {
  237. clearTimeout(bgtimer);
  238. window.bgtimer = setTimeout(function() {
  239. $('#stage').css('background-image', 'url("http://whereduaneat.org/duane.gif")');
  240. }, 21000);
  241. } else {
  242. clearTimeout(bgtimer);
  243. $('#stage').css('background-image', 'none');
  244. }
  245. }
  246. };
  247. window.setFast = function(data) {
  248. if (!isNaN(parseInt(data))) {
  249. if (data > 99) {
  250. data = 99;
  251. $('#marqueeinput').val(data);
  252. }
  253. marqueeSpeed = data;
  254. if (typeof($codes.fast) === 'string') {
  255. $codes['fast'] = '<marquee direction="right" scrollamount="' + marqueeSpeed + '">';
  256. }
  257. }
  258. };
  259. window.updateColor = function(id, hex) {
  260. switch (id) {
  261. case 'pickerButtons': $('.vjs-default-skin .vjs-play-control, .vjs-mute-control, .vjs-fullscreen-control').css('color', '#'+hex); break;
  262. case 'pickerHandles': $('.vjs-slider-handle').css('color', '#'+hex); break;
  263. case 'pickerProgress': $('.vjs-play-progress, .vjs-volume-level').css('background-color', '#'+hex); break;
  264. case 'pickerText': $('.vjs-current-time-display, .vjs-time-divider, .vjs-duration-display, .vjs-quality-button').css('color', '#'+hex); break;
  265. }
  266. };
  267. window.showChangelog = function() {
  268. $('#chat-messages').append('<div class="message changelog"><strong style="color: #f0f">============= Changelog =============</strong></div>');
  269. $('#chat-messages').append('<div class="message changelog"><strong style="color: #00a">[1.881b]</strong> Emote menu no longer stays between room switches. General fixes.</div>');
  270. $('#chat-messages').append('<div class="message changelog"><strong style="color: #00a">[1.882]</strong> New toggle in Script Options for black chat. New emote: /tip. Added "Script Help" link at the top. Decreased Script Menu width. Changed update message.</div>');
  271. $('#chat-messages').append('<div class="message changelog"><strong style="color: #0f0">[1.883]</strong> Updated a few functions. Added onClick sound to /no. Added "Shuffle Playlist" button to playlist menu. Fixed curtain not working after changing rooms. Emote menu fades in/out.</div>');
  272. $('#chat-messages').append('<div class="message changelog"><strong style="color: #f0f">====================================</strong></div>');
  273. messages += 5;
  274. chatScroll();
  275. };
  276. window.swapEmoteStyle = function() {
  277. useColons = !useColons;
  278. if (useColons)
  279. $('#op-button.switchemotestyle').html('Emote Menu: use <span style="color: #0f0">/emote</span> instead');
  280. else
  281. $('#op-button.switchemotestyle').html('Emote Menu: use <span style="color: #0f0">:emote:</span> instead');
  282. }
  283.  
  284. window.byteCount = function(str) {
  285. return encodeURI(str).split(/%..|./).length - 1;
  286. }; /*Lauri Oherd on stackoverflow*/
  287.  
  288. jQuery.lazyCookie = function() {
  289. if (jQuery.cookie(arguments[0]) === null) return;
  290. jQuery.cookie.apply(this, arguments);
  291. }; /*by Jacob Relkin on stackoverflow*/
  292. window.playSound = function(sound) {
  293. var vol = video.video.volume();
  294. sound.volume = vol;
  295. sound.play();
  296. };
  297.  
  298. window.getUserIndex = function(id) {
  299. for (var i = 0; i < users.length; i++) {
  300. if (id == users[i].id) {
  301. return i;
  302. }
  303. }
  304. return -1;
  305. };
  306.  
  307. // adjustCurtain() -- resize curtain, if it's open, upon change of screen layout
  308. window.adjustCurtain = function() {
  309. var cHeights = {top: $('#curtainTop').height(), bottom: $('#curtainFloor').height()};
  310. var a = {h: $('#media').height(), w: $('#media').width()};
  311. // a is an object of #media dimensions {h: height,w: width}
  312. // floor of the curtain always has a constant height, so subtract
  313. // the height of the floor from the height of the video to get the new curtainTop height
  314. $('#curtainTop').width(a.w);
  315. $('#curtainFloor').width(a.w);
  316. switch (a.h) {
  317. case 320:
  318. if (cHeights.top > a.h)
  319. $('#curtainTop').height(248)
  320. break;
  321. case 436:
  322. if (cHeights.top > a.h || (cHeights.top > 0 && cHeights.top < 364))
  323. $('#curtainTop').height(364)
  324. break;
  325. case 796:
  326. if (cHeights.top > a.h || (cHeights.top > 0 && cHeights.top < 724))
  327. $('#curtainTop').height(724)
  328. break;
  329. }
  330. }
  331. window.switchResolution = function(level) {
  332. var switchRes = false;
  333. switch (level) {
  334. case 0:
  335. $.cookie('largePlayerSetting', '0');
  336. largePlayer = false;
  337. largerPlayer = false;
  338. var currentCSS = $('.scriptCSS');
  339. $('.jspContainer').attr('style', 'width: 536px; height: 327px;');
  340. $('#videos').attr('style', 'width: 539px');
  341. stageBase = 675;
  342. $('#players a.normal').attr('style', 'color: white!important; text-decoration: none!important');
  343. $('#players a.normal').attr('href', null);
  344. $('#players a.large, #players a.larger').attr('style', 'color: #ccc!important; text-decoration: underline!important');
  345. $('#players a.large, #players a.larger').attr('href', '#');
  346. $('.stage').height(stageBase);
  347. currentCSS.remove();
  348. break;
  349. case 1:
  350. $.cookie('largePlayerSetting', '1');
  351. largePlayer = true;
  352. largerPlayer = false;
  353. var currentCSS = $('.scriptCSS');
  354. $('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDVHVVWFBoMzZqdUU?d=20140526&v=000" type="text/css" />');
  355. stageBase = 890;
  356. $('#players a.large').attr('style', 'color: white!important; text-decoration: none!important');
  357. $('#players a.large').attr('href', null);
  358. $('#players a.larger, #players a.normal').attr('style', 'color: #ccc!important; text-decoration: underline!important');
  359. $('#players a.larger, #players a.normal').attr('href', '#');
  360. $('.stage').height(stageBase);
  361. $('.jspContainer').attr('style', 'width: 735px; height: 398px;');
  362. $('#videos').attr('style', 'width: 739px');
  363. currentCSS.remove();
  364. break;
  365. case 2:
  366. $.cookie('largePlayerSetting', '2');
  367. largePlayer = false;
  368. largerPlayer = true;
  369. var currentCSS = $('.scriptCSS');
  370. $('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDSkxuR1J0MUppRnc?d=20140526&v=000" type="text/css" />');
  371. stageBase = 1393;
  372. $('#players a.larger').attr('style', 'color: white!important; text-decoration: none!important');
  373. $('#players a.larger').attr('href', null);
  374. $('#players a.large, #players a.normal').attr('style', 'color: #ccc!important; text-decoration: underline!important');
  375. $('#players a.large, #players a.normal').attr('href', '#');
  376. $('.stage').height(stageBase);
  377. $('.jspContainer').attr('style', 'width: 1346px; height: 519px;');
  378. $('#videos').attr('style', 'width: 1350px');
  379. currentCSS.remove();
  380. break;
  381. }
  382. adjustCurtain();
  383. };
  384.  
  385. window.addLog = function(title, addedby) {
  386. var cl = $('#chat-messages .message');
  387. if (cl[cl.length - 1].textContent !== ': Reconnected to chat server.' && messages > 2) {
  388. if (title.length > 80)
  389. title = title.slice(0, 80) + '...';
  390. addMessage({username:'%addVideo'}, addedby + ' added ' + title, 'gm vid');
  391. }
  392. };
  393.  
  394. window.updateNotice = function(state, ver) {
  395. if (state == 'on' && ver != scriptVer) {
  396. $('#newUpdate').show();
  397. } else if (state == 'off') {
  398. $('#newUpdate').hide();
  399. }
  400. };
  401.  
  402. window.addTempEmote = function(name, url, w, h) {
  403. var newEmote = {};
  404. var node = '<img src="' + url + '" width="' + w + '" height="' + h + '">';
  405. newEmote[name] = node;
  406. $.extend($codes, newEmote);
  407. };
  408.  
  409. window.findUserVideos = function(user) {
  410. var vids = 0;
  411. var userLower = user.toLowerCase();
  412. if (playlist.length !== 0) {
  413. for (var i = 0; i < playlist.length; i++) {
  414. if (playlist[i].addedby.toLowerCase() == userLower) {
  415. vids++;
  416. }
  417. }
  418. addMessage({username:''},'Found ' + vids + ' video(s) added by ' + user + '.','hashtext');
  419. } else {
  420. addMessage({username:''},'No videos in playlist.','urgenttext');
  421. }
  422. };
  423.  
  424. window.checkMod = function(user) {
  425. user = user.toLowerCase();
  426. for (var i = 0; i < users.length; i++) {
  427. if (users[i].username.toLowerCase() == user) {
  428. var p = users[i].permissions;
  429. var Mod;
  430. if (p == "1" && customUsers.indexOf(user) < 0) {
  431. Mod = 1; //normal mod
  432. } else if (p == 2) {
  433. Mod = 2; //admin of room
  434. } else if (customUsers.indexOf(user) > -1) {
  435. Mod = 3; //user in custom admin list
  436. } else {
  437. Mod = 0; //normal user
  438. }
  439. return Mod;
  440. }
  441. }
  442. };
  443.  
  444. window.checkEmote = function(message) {
  445. var a,b,c,d,e;
  446. a = b = c = d = e = 0;
  447. while (a < message.length && a >= 0 && e < 4) {
  448. d++;
  449. a = message.indexOf(':', a);
  450. b = message.indexOf(':', a + 1);
  451. var f = message.slice(a, b + 1);
  452. if ($codes[f.slice(1, -1).toLowerCase()] !== undefined) {
  453.  
  454. c = $codes[f.slice(1, -1).toLowerCase()].length;
  455.  
  456. var emote = f.slice(1, -1).toLowerCase();
  457. message = message.replace(f, $codes[emote]);
  458. if ($colorcodes[emote] !== undefined || $fontcodes[emote] !== undefined) e += 0.5;
  459. else e++;
  460.  
  461. if (c < f.slice(1, -1).length) {
  462. a = message.indexOf(f.slice(1, -1));
  463. } else {
  464. a = ($codes[f.slice(1, -1).toLowerCase()].length + a);
  465. }
  466.  
  467. } else if ($codes[f.slice(1, -1).toLowerCase()] === undefined) {
  468. a = b;
  469. } else if (d >= 10) {
  470. break;
  471. }
  472. }
  473. return message;
  474. };
  475.  
  476. window.expandEmotes = function() {
  477. $('#facecodesmenu').fadeToggle();
  478. $('#facecodesmenu #emotes').fadeToggle();
  479. };
  480.  
  481. window.setFavIcon = function(src) {
  482. var a = '<link rel="shortcut icon" class="scr-fav" href="' + src + '">';
  483. $('.scr-fav').remove();
  484. $('head').append(a);
  485. };
  486.  
  487. window.cssCommand = function(mode, item, c) {
  488. if (mode == 'glow') {
  489. if (c == 'off') {
  490. $(item).css('box-shadow', 'none');
  491. } else {
  492. $(item).css('box-shadow', '0 0 15px ' + c);
  493. }
  494. } else if (mode == 'bg') {
  495. if (c == 'off') {
  496. $(item).css('background-image', 'none');
  497. } else {
  498. $(item).css('background-image', 'url(' + c + ')');
  499. }
  500. }
  501. };
  502.  
  503. window.clearChat = function() {
  504. $('#chat-messages').empty();
  505. messages = fastmsgs = 0;
  506. };
  507.  
  508. window.cleanLog = function() {
  509. if (logs > MAXLOGS) {
  510. $('#logs span').eq(1).css('opacity', '.2');
  511. $('#logs span').eq(2).css('opacity', '.4');
  512. $('#logs span').eq(3).css('opacity', '.6');
  513. $('#logs span').eq(0).remove();
  514. logs--;
  515. }
  516. };
  517.  
  518. String.prototype.repeat = function(num) {
  519. return new Array(num + 1).join(this);
  520. };
  521.  
  522. window.toggleAutoClean = function() {
  523. autoClean = !autoClean;
  524. if (autoClean) {
  525. addMessage({username:''}, 'Autoclean is now on. The next video must be position 1 to autoclean.', 'hashtext');
  526. } else {
  527. addMessage({username:''}, 'Autoclean is now off.', 'hashtext');
  528. }
  529. };
  530.  
  531. window.viewHistory = function(vids) {
  532. var icon = '';
  533. var host = '';
  534. var thumb = '';
  535. var title = '';
  536. var key = {
  537. 'youtube': {icon: 'http://i.imgur.com/KpOgg0D.png', host: 'http://youtube.com/watch?v='},
  538. 'vimeo': {icon: 'http://i.imgur.com/TOogvwC.png', host: 'http://vimeo.com/'},
  539. 'dailymotion': {icon: 'http://i.imgur.com/n7HR2hF.png', host: 'http://dailymotion.com/video/'},
  540. 'twitch': {icon: 'http://i.imgur.com/0jO0wYz.png', host: 'http://twitch.tv/'},
  541. }
  542. $('#viewHistory').empty();
  543. $('#viewHistory').append('<div class="close-history x" onclick="$(\'#gethistory\').click();"></div>');
  544. for (var i = vids.length - 1; i > -1; i--) {
  545. thumb = vids[i].info.thumbnail;
  546. if (vids[i].info.provider in key) {
  547. icon = key[vids[i].info.provider].icon;
  548. host = key[vids[i].info.provider].host;
  549. if (vids[i].info.provider === 'twitch')
  550. vids[i].info.id = vids[i].info.channel;
  551. }
  552. title = vids[i].title;
  553. if (title.length > 100)
  554. title = title.slice(0,100) + '...';
  555. $('#viewHistory').append('<li class="search-result" title="' + title + '"><a href="' + host + vids[i].info.id + '" target="_blank"><span class="video-thumb"><img class="video-thumbnail" src="' + thumb + '"><img class="video-icon" src="' + icon + '"><span class="video-time">' + secondsToTime(vids[i].duration) + '</span></span><span class="video-title">' + title + '</span><span class="video-uploader">added by <b><span id="vidUploader">' + vids[i].addedby + '</span></b></a></li>');
  556. }
  557. }
  558.  
  559. window.addUser = function(user, sort) {
  560. var css = '';
  561. if (user['loggedin']) {
  562. css += 'registered ';
  563. if (logTraffic) {
  564. $('<span class="logJoined" style="opacity: 1">+ ' + user.username + '<br />').appendTo('#logs');
  565. logs++;
  566. cleanLog();
  567. }
  568. }
  569. if (user.permissions > 0) {
  570. css += 'm ';
  571. }
  572. if (user.permissions == "1" || user.permissions == 2) {
  573. var name = user.username.toLowerCase();
  574. var names = {};
  575. if (isv4c)
  576. names = {
  577. manboss: 'manboss',
  578. captainfalcon: 'user_cap ',
  579. grinsly: 'grins ',
  580. gingersnap: 'ginger ',
  581. biggles: 'biggles '
  582. };
  583. names[ROOMNAME.toLowerCase()] = 'admin ';
  584. if (name in names) {
  585. css += names[name];
  586. }
  587. }
  588. css += isMuted(user.ip) ? "muted" : "";
  589. user.css = css;
  590. users.push(user);
  591. var userElement = $('<li/>', {
  592. "class": css,
  593. "text":user.username,
  594. "data": {username: String(user.username), id: user.id, css: css, loggedin: user.loggedin, ip: user.ip},
  595. "click": function () {
  596. $('#cin')['val']($('#cin')['val']() + $(this).data('username'));
  597. $('#cin')['focus']();
  598. }
  599. });
  600. userElement.hover(function ()
  601. {
  602. var thisElement = $(this);
  603. $(this).data('hover', setTimeout(function ()
  604. {
  605. $('#bio-username').text(thisElement.data('username').toUpperCase());
  606. $("#user_bio_hover").css('top', $(thisElement).offset().top - $("#chat").offset().top + 10);
  607. $('#bio-image').attr('src', '');
  608. $('#bio-text').text('');
  609. //reset
  610. $('#ban').data('id', "");
  611. $('#kick').data('id', "");
  612. $('#mute-button').data('ip', "");
  613. //
  614. $('#user_bio_hover').show();
  615. if (thisElement.data('loggedin') == true)
  616. {
  617. getUserInfo(thisElement.data('username'), function (avatar, bio) {
  618. $('#bio-image').attr('src', avatar);
  619. $('#bio-text').text(bio);
  620. });
  621. } else {
  622. $('#bio-text').html("<span style='color: grey; font-style:italic'>User is not registered.</span>");
  623. }
  624. $('#ban').data('id', user['id']);
  625. $('#kick').data('id', user['id']);
  626. $('#mute-button').data('ip', user.ip);
  627. //show or hide mute/unmute buttons
  628. if (isMuted(user.ip))
  629. {
  630. $("#mute-button").removeClass("");
  631. $("#mute-button").addClass("");
  632. }
  633. else
  634. {
  635. $("#mute-button").removeClass("");
  636. $("#mute-button").addClass("");
  637. }
  638. }, 600));
  639. }, function () {
  640. clearTimeout($(this).data('hover'));
  641. setTimeout(function () {
  642. if (!mouseOverBio) {
  643. $('#user_bio_hover').hide();
  644. }
  645. }, 50);
  646. });
  647. $('#userlist').append(userElement);
  648. $('#viewercount').text(users.length);
  649. if (sort === true) {
  650. sortUserlist();
  651. }
  652. if (users.length >= 100) {
  653. if (users.length < 200) {
  654. if (!$('#viewercount').hasClass('highviewcount'))
  655. $('#viewercount').addClass('highviewcount');
  656. if ($('#viewercount').hasClass('higherviewcount'))
  657. $('#viewercount').removeClass('higherviewcount');
  658. } else if (users.length >= 200) {
  659. if ($('#viewercount').hasClass('highviewcount'))
  660. $('#viewercount').removeClass('highviewcount');
  661. $('#viewercount').addClass('higherviewcount');
  662. }
  663. } else {
  664. if ($('#viewercount').hasClass('highviewcount'))
  665. $('#viewercount').removeClass('highviewcount');
  666. if ($('#viewercount').hasClass('higherviewcount'))
  667. $('#viewercount').removeClass('higherviewcount');
  668. }
  669. };
  670.  
  671. window.removeUser = function(id) {
  672. var user = users[getUserIndex(id)];
  673. if (user.loggedin && logTraffic) {
  674. $('<span class="logLeft" style="opacity: 1">- ' + user.username + '<br />').appendTo('#logs');
  675. logs++;
  676. cleanLog();
  677. }
  678. for (var i = 0; i < users.length; i++)
  679. {
  680. if (id === users[i].id)
  681. {
  682. users['splice'](i, 1);
  683. $($('#userlist').children('li')[i]).remove();
  684. break;
  685. }
  686. }
  687. $('#viewercount').html(users.length);
  688. if (users.length >= 100) {
  689. if (users.length < 200) {
  690. if (!$('#viewercount').hasClass('highviewcount'))
  691. $('#viewercount').addClass('highviewcount');
  692. if ($('#viewercount').hasClass('higherviewcount'))
  693. $('#viewercount').removeClass('higherviewcount');
  694. } else if (users.length >= 200) {
  695. if ($('#viewercount').hasClass('highviewcount'))
  696. $('#viewercount').removeClass('highviewcount');
  697. $('#viewercount').addClass('higherviewcount');
  698. }
  699. } else {
  700. if ($('#viewercount').hasClass('highviewcount'))
  701. $('#viewercount').removeClass('highviewcount');
  702. if ($('#viewercount').hasClass('higherviewcount'))
  703. $('#viewercount').removeClass('higherviewcount');
  704. }
  705. };
  706.  
  707. window.bumpUser = function(user, bumpTo) {
  708. if (isMod) {
  709. var a = false;
  710. var c = [];
  711. var b = '';
  712. var d = '';
  713. var e = bumpTo;
  714. if (e === null)
  715. e = $('.video.active').index() + 1;
  716. e = parseInt(e);
  717. if (isNaN(e) || e >= playlist.length) {
  718. d = 'Invalid playlist position.';
  719. } else {
  720. if (user !== '\\r') {
  721. for (var i = 0; i < users.length; i++) {
  722. if (users[i].username.toLowerCase().indexOf(user) == 0 && users[i].loggedin) {
  723. c.push(users[i].username);
  724. }
  725. }
  726. if (c.length > 1) {
  727. d = 'Multiple users found. Be more specific.';
  728. } else if (c.length == 0) {
  729. d = 'No users found.';
  730. } else if (c.length == 1) {
  731. b = c[0];
  732. for (var l = playlist.length - 1; l > -1; l--) {
  733. if (playlist[l].addedby.toLowerCase() == b.toLowerCase()) {
  734. a = true;
  735. global.sendcmd('move', {
  736. info: playlist[l].info,
  737. position: e
  738. });
  739. break;
  740. }
  741. }
  742. if (a) {
  743. d = 'Bumped ' + b + '.';
  744. } else {
  745. d = 'No videos found.';
  746. }
  747. }
  748. } else {
  749. f = Math.ceil(Math.random() * playlist.length) - 1;
  750. if (f == $('.video.active').index()) {
  751. f++;
  752. }
  753. if (f > playlist.length - 1) {
  754. d = 'Playlist too small.';
  755. } else {
  756. global.sendcmd('move', {
  757. info: playlist[f].info,
  758. position: e
  759. });
  760. d = 'Random video (' + f + ') bumped.';
  761. }
  762. }
  763. }
  764. } else {
  765. d = 'You cannot use this command.';
  766. }
  767. $('<div class="message"><span class="cm gm"><span style="color: red; font-style: none; font-weight:bold">$bump: </span>' + d + '</span></div>').appendTo('#chat-messages');
  768. messages++;
  769. chatScroll();
  770. };
  771.  
  772. window.addVideo = function(vidinfo, updateScrollbar) {
  773. playlist.push({info: vidinfo.info, title: vidinfo.title, addedby: vidinfo.addedby, duration: vidinfo.duration});
  774. var dur = '';
  775. var thisTitle = vidinfo.title;
  776. if (logVids && messages > 3)
  777. addLog(vidinfo.title, vidinfo.addedby);
  778. if (vidinfo.info.provider == 'twitch')
  779. dur = 'Twitch Stream';
  780. else
  781. dur = secondsToTime(vidinfo.duration);
  782. if (thisTitle.length > 200)
  783. thisTitle = thisTitle.slice(0,200) + '...';
  784. var li = $('<li/>', {"class":"video","data":{info: vidinfo.info}});
  785. var vidInfo = $('<div/>', {"class":"video-info"})
  786. .append($('<div/>',{"class":"title","text":thisTitle, "title":thisTitle}))
  787. .append($('<div/>',{"class":"via", "text":"via " + vidinfo.addedby}))
  788. .append($('<div/>',{"class":"duration","text":dur}));
  789. var buttons = $('<div/>',{"class":"buttons"})
  790. .append($('<div/>',{
  791. "class":"info",
  792. "title":"More information about this video.",
  793. "click":function()
  794. {
  795. $(".detailed-info").fadeIn(); //to show loading spinner
  796. getVideoInfo(vidinfo.info, function(err, data){
  797. if (err){
  798. //output error
  799. }
  800. else{
  801. showVideoInfo(vidinfo.info, data);
  802. }
  803. });
  804. }
  805. }))
  806. .append($('<a/>',{
  807. "class":"link",
  808. "title":"Open this video in a new tab.",
  809. "href":url(vidinfo),
  810. "target":"_blank",
  811. "style":"display: inline-block"
  812. }));
  813. if (isMod) //if mod,
  814. {
  815. buttons.append($('<div/>',
  816. {
  817. "class":"remove",
  818. "title":"Remove video",
  819. "click":function()
  820. {
  821. global.sendcmd('remove', {info: vidinfo.info});
  822. }
  823. }));
  824. }
  825. $(vidInfo).on('click', function()
  826. {
  827. if ($("#video-list").hasClass("noclick")) //Don't make the video play if sorting video
  828. {
  829. $("#video-list").removeClass('noclick');
  830. }
  831. else
  832. {
  833. if (isLeader)
  834. {
  835. global.sendcmd('play', {info: vidinfo.info});
  836. }
  837. else
  838. {
  839. $('#cin').val($('#cin').val() + getVideoIndex(vidinfo.info) + ' ');
  840. $('#cin').focus();
  841. }
  842. }
  843. });
  844. li.append(vidInfo).append(buttons);
  845. $('#video-list').append(li);
  846. totalTime += vidinfo.duration;
  847. $('#total-videos').html(playlist.length);
  848. $('#total-duration').html(secondsToTime(totalTime));
  849. if (updateScrollbar)
  850. $("#videos").data("jsp").reinitialise(); //uses alot of resources
  851. };
  852. window.chatScroll = function() {
  853. if (autoscroll) {
  854. var textarea = document.getElementById('chat-messages');
  855. textarea.scrollTop = textarea.scrollHeight;
  856. }
  857. };
  858.  
  859. window.useEmote = function(code) {
  860. var msg = $('#cin').val();
  861. if (useColons)
  862. msg = msg + ":" + code + ":";
  863. else
  864. msg = "/" + code;
  865. $('#cin').val(msg);
  866. };
  867.  
  868. window.updateRecent = function(a) {
  869. if (recentVidInfo.indexOf(playlist[a]) < 0)
  870. recentVidInfo.push(playlist[a]);
  871. if (recentVidInfo.length > 12)
  872. recentVidInfo = recentVidInfo.slice(recentVidInfo.length - 12)
  873. };
  874.  
  875. window.setTabTitle = function(a,b,c) {
  876. var newTitle = playlist[c].title;
  877. if (newTitle.length > 55) {
  878. newTitle = newTitle.substring(0, 55);
  879. newTitle += '...';
  880. }
  881. currentVid = newTitle + ' via ' + b;
  882. document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  883. if (a.provider == 'youtube') videoLink = 'http://youtu.be/' + a.id;
  884. else if (a.provider == 'vimeo') videoLink = 'http://vimeo.com/' + a.id;
  885. else if (a.provider == 'twitch') videoLink = 'http://twitch.tv/' + a.channel;
  886. else if (a.provider == 'dailymotion') videoLink = 'http://dailymotion.com/video/' + a.id;
  887. if (isChrome) console.log('%c Now playing: ' + currentVid + ' ( ' + videoLink + ' ) ', 'background-color: black; color: #00ecff'); else console.log('Now playing: ' + currentVid + ' ( ' + videoLink + ' )');
  888. };
  889.  
  890. window.cleanFast = function() {
  891. if ($('#chat-messages.messages .message marquee')[0] === undefined)
  892. fastmsgs = 0;
  893. while (fastmsgs > MAXFAST) {
  894. $('#chat-messages.messages .message marquee')[0].remove();
  895. fastmsgs--;
  896. }
  897. };
  898.  
  899. window.addMessage = function(user, message, extraStyles) { //extraStyles = additional classes FOR THE MESSAGE STYLE
  900.  
  901. var lastUser = {};
  902. if ($('#chat-messages .message .username').length > 0) {
  903. lastUser['n'] = $('#chat-messages .message .username').slice(-1)[0];
  904. lastUser['user'] = lastUser.n.textContent.slice(0, lastUser.n.textContent.length - 2).toLowerCase();
  905. }
  906. var senderString = user.username + ': ';
  907. var usernameId = '';
  908. var usernameClass = "";
  909. if (user.username !== undefined)
  910. var name = user.username.toLowerCase();
  911. if (filterGreyname === true)
  912. if (user.loggedin === false)
  913. return;
  914. if (isMuted(user.ip))
  915. return;
  916. if (user.loggedin)
  917. usernameClass += 'registered ';
  918. else
  919. usernameClass += 'unregistered ';
  920. if (name == '%addvideo')
  921. usernameClass = 'hide';
  922. var messageBox = $('<div/>', {
  923. "class": "message"
  924. });
  925. if (name !== '' && sameUserMessages && $('.message').length > 0 && message.substring(0,4) !== "/me " && name !== '%addvideo' && user.loggedin && typeof(lastUser.n !== 'undefined') && typeof(lastUser.user !== 'undefined')) {
  926. if (lastUser.n.id == name || lastUser.user == name) {
  927. usernameId = name;
  928. senderString = '';
  929. $(messageBox).addClass("same");
  930. }
  931. }
  932. var rollString, ballString;
  933. var rawMessage = message;
  934.  
  935. if (message.indexOf(':fast:') > -1 && typeof($codes.fast) !== undefined) {
  936. fastmsgs++;
  937. cleanFast();
  938. }
  939. if (userStyleList.indexOf(usernameClass) > -1) { //'um' stands for name in message, used for mod names in chat
  940. if (checkMod(name) == 1) {
  941. if (name == 'biggles') usernameClass += 'umbiggles ';
  942. else usernameClass += 'um0 '
  943. } else if (checkMod(name) == 2) {
  944. usernameClass += 'um1 '
  945. } else if (checkMod(name) == 3 && isv4c) {
  946. if (name.toLowerCase() == 'manboss') usernameClass += 'ummb '
  947. }
  948. }
  949. message = linkify(message);
  950. var bumpTest = message.split(" ");
  951. test = message.split(" ");
  952. if (test[0] == '$bump')
  953. test[0] = '<img src="http://i.imgur.com/d1odx.png" width="25" height="25">';
  954. if (name == 'biggles' && usernameClass == 'registered umbiggles ') {
  955. var testRaw = rawMessage.split(" ");
  956. if (testRaw[0] == '$css')
  957. cssCommand(testRaw[1], testRaw[2], testRaw[3]);
  958. else if (testRaw[0] == '$delEmote') {
  959. if ($codes[testRaw[1]] != undefined)
  960. $codes.splice($codes[testRaw[1]], 1);
  961. }
  962. else if (testRaw[0] == '$tempEmote') {
  963. if ($codes[testRaw[1]] != undefined)
  964. $codes.splice($codes[testRaw[1]], 1);
  965. var jstest = rawMessage.split('|');
  966. addTempEmote(testRaw[1], testRaw[2], testRaw[3], testRaw[4], jstest[1]);
  967. }
  968. else if (testRaw[0] == '$updated')
  969. updateNotice(testRaw[1], testRaw[2]);
  970. else if (testRaw[0] == '$stopShuffle') {
  971. if (shuffling) {
  972. clearTimeout(recurTime);
  973. $('#shuffleProgress').text('Shuffle stopped...');
  974. setTimeout(function() {$('#shuffle').fadeOut(); shuffling = false; autosynch = true}, 2000);
  975. }
  976. }
  977. }
  978. if (byteCount(rawMessage) > 250 && name != '') {
  979. message = '<span style="color: #800">(removed)</span>';
  980. test = '';
  981. rawMessage = '';
  982. }
  983. if (showRoll && userStyleList.indexOf(usernameClass) > -1 && test[test.length - 1] == '&#8203;' && test[0] !== undefined) {
  984. if (test[0].toLowerCase() == '&#8203;$r&#8203;o&#8203;l&#8203;l') {
  985. var rolledNumber = test[test.length - 2];
  986. test[test.length - 2] = '';
  987. if (rolledNumber.length > 10)
  988. rolledNumber = rolledNumber.slice(0, 10);
  989. if (rolledNumber == parseInt(rolledNumber)) {
  990. var j = 1;
  991. var k = rolledNumber.length;
  992. for (var i = 1; i < k; i++) {
  993. if (rolledNumber[i] === rolledNumber[i - 1])
  994. j++;
  995. else
  996. break
  997. }
  998. if (k === j) var numColor = '#f90'; else var numColor = '#005cff';
  999. rollString = '<span class="gm rollstr">&nbsp;' + user.username + ' rolled <span style="color:' + numColor + '; font-weight: bold; font-style: normal">' + rolledNumber + ' </span><br />';
  1000. }
  1001. } else if (test[0].toLowerCase() == '&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l') {
  1002. var ballTest = message.split("|");
  1003. var answer = ballTest[ballTest.length - 2];
  1004. ballTest[ballTest.length - 2] = '';
  1005. test = ballTest;
  1006. ballString = '<span class="gm ballstr">&nbsp;' + user.username + ': 8ball says, <span style="color:#f00; font-weight: bold; font-style: normal">"' + answer + '" </span><br />';
  1007. }
  1008. }
  1009. message = test.join(' ');
  1010. if (userInfo.username.toLowerCase() !== '' && message.toLowerCase().indexOf(userInfo.username.toLowerCase()) > -1 && name !== '%addvideo' && userInfo.loggedin)
  1011. $(messageBox).addClass("mentionMsg");
  1012. if (message.substring(0,4) == "/me "){ //emote text
  1013. message = message['substring'](4);
  1014. message = checkEmote(message);
  1015. messageBox.append($("<span/>",{
  1016. "class":"metext",
  1017. "html":user.username + " " + message
  1018. }));
  1019. }
  1020. else if(message.substring(0, 4) == '&gt;'){ //greentext
  1021. message = checkEmote(message);
  1022. messageBox.append($("<span/>", {
  1023. "class":"username "+usernameClass,
  1024. "id":usernameId,
  1025. "text":senderString
  1026. }));
  1027. messageBox.append($("<span/>",{
  1028. "class":"text greentext",
  1029. "id":usernameId,
  1030. "html":message //convert to text when switching anti xss to client side
  1031. }));
  1032. }
  1033. else if(message[0] === '!' || message[0] === '~' || message[0] == '#'){ //urgenttext, limetext, hashtext
  1034. message = checkEmote(message);
  1035. var classes = {'!': 'text urgenttext', '~': 'text limeg', '#': 'text hashtext'};
  1036. messageBox.append($("<span/>", {
  1037. "class":"username "+usernameClass,
  1038. "id":usernameId,
  1039. "text":senderString
  1040. }));
  1041. messageBox.append($("<span/>",{
  1042. "class": classes[message[0]],
  1043. "id":usernameId,
  1044. "html":message //convert to text when switching anti xss to client side
  1045. }));
  1046. }
  1047. else if(message[0] == '/' && $codes[message.substring(1)] != undefined){ //emote
  1048. var emote = message['substring'](1);
  1049. messageBox.append($("<span/>", {
  1050. "class":"username "+usernameClass,
  1051. "id":usernameId,
  1052. "text":senderString
  1053. }));
  1054. messageBox.append($("<span/>",{
  1055. "class":"",
  1056. "title": '/' + emote,
  1057. "html":$codes[emote]
  1058. }));
  1059. }
  1060. else{ //regular message
  1061. message = checkEmote(message);
  1062. messageBox.append($("<span/>", {
  1063. "class":"username "+usernameClass,
  1064. "id":usernameId,
  1065. "text":senderString
  1066. }));
  1067. var msg = $("<span/>",{
  1068. "class":"text "+extraStyles,
  1069. "html":message//switch this to text when switching to xss prevention client side
  1070. });
  1071. messageBox.append(msg);
  1072. }
  1073. $("#chat-messages").append(messageBox);
  1074. if (bumpTest[0] == '$bump' && isMod && name == userInfo.username.toLowerCase()) {
  1075. if (bumpTest.length == 3)
  1076. bumpUser(bumpTest[1].toLowerCase(), bumpTest[2]);
  1077. else if (bumpTest.length == 2) {
  1078. if (!isNaN(parseInt(bumpTest[1])))
  1079. bumpUser(userInfo.username.toLowerCase(), bumpTest[1]);
  1080. else
  1081. bumpUser(bumpTest[1].toLowerCase(), null);
  1082. } else if (bumpTest.length == 1)
  1083. bumpUser(userInfo.username.toLowerCase(), null);
  1084. }
  1085. if (showRoll) {
  1086. if (rollString !== undefined && parseInt(rollString) !== NaN && showRoll) {
  1087. $("#chat-messages").append(rollString);
  1088. }
  1089. if (ballString !== undefined && eight_choices.indexOf(answer) > -1 && showRoll) {
  1090. $("#chat-messages").append(ballString);
  1091. }
  1092. }
  1093. if (autoscroll === true) {
  1094. var textarea = document.getElementById('chat-messages');
  1095. textarea.scrollTop = textarea.scrollHeight;
  1096. }
  1097. if (!$('#cin').is(':focus') && newMsg == false) {
  1098. if (isv4c) setFavIcon('http://i.imgur.com/L4dvBOL.png'); else setFavIcon('http://i.imgur.com/XiBhO54.png');
  1099. newMsg = true;
  1100. document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  1101. global.page.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  1102. }
  1103. messages += 1;
  1104. cleanChat();
  1105. };
  1106.  
  1107. window.createPoll = function(poll) { //poll.title, poll.options = array of {option, votes}
  1108. $(".st-poll").show();
  1109. var titleClass;
  1110. var classes = {'#': 'hashtext', '!': 'urgenttext', '|': 'spoiler', '~': 'limeg'}
  1111. poll.title = linkify(poll.title, false, true);
  1112. poll.title = checkEmote(poll.title);
  1113.  
  1114. if (poll.title.substring(0, 4) === '&gt;')
  1115. titleClass = 'greentext';
  1116. else if (classes[poll.title[0]] !== undefined)
  1117. titleClass = classes[poll.title[0]];
  1118.  
  1119. $('.poll-title').attr('class', 'poll-title');
  1120. $('.poll-title').attr('class', $('.poll-title').attr('class') + ' ' + titleClass);
  1121. $(".poll-title").html(poll.title);
  1122. var choices = $(".poll-results.choices");
  1123. $(choices).empty();
  1124. for (var i = 0; i < poll.options.length; i++) {
  1125. var optionClass;
  1126. poll.options[i].option = linkify(poll.options[i].option, false, true);
  1127. poll.options[i].option = checkEmote(poll.options[i].option);
  1128. if (poll.options[i].option.substring(0, 4) === '&gt;')
  1129. optionClass = 'greentext';
  1130. else if (classes[poll.options[i].option[0]] !== undefined)
  1131. optionClass = classes[poll.options[i].option[0]];
  1132. var choice =
  1133. $("<div/>",
  1134. {
  1135. "class":"poll-item choice"
  1136. }).append($("<span/>",
  1137. {
  1138. "class":"poll-vote-btn basic-btn vote_choice",
  1139. "html":poll.options[i].votes,
  1140. "data":{option: i},
  1141. "click": function(){
  1142. if (userInfo.loggedin)
  1143. {
  1144. global.sendcmd("poll-vote", {vote: $(this).data("option")});
  1145. }
  1146. else
  1147. {
  1148. addMessage({username: ""},"You must be logged in to vote on polls.","errortext");
  1149. }
  1150. }
  1151. })).append($("<span/>",
  1152. {
  1153. "class":"poll-vote-text" + ' ' + optionClass,
  1154. "html":poll.options[i].option
  1155. }));
  1156. $(choices).append(choice);
  1157. }
  1158. };
  1159. window.toggleScriptSetting = function(a,b,c) {
  1160. var toOn = false;
  1161. var toOff = false;
  1162. switch (a) {
  1163. case 'op-showadd':
  1164. logVids = !logVids;
  1165. if (logVids) {
  1166. toOn = true;
  1167. $.cookie('logvidSetting', '1');
  1168. } else {
  1169. toOff = true;
  1170. $.cookie('logvidSetting', '0');
  1171. }
  1172. break;
  1173. case 'op-showshadow':
  1174. mediashadow = !mediashadow;
  1175. if (mediashadow) {
  1176. toOn = true;
  1177. mediashadow = true;
  1178. setMediaShadow(playlist[$('.video.active').index()].info.provider);
  1179. $.cookie('mshadSetting', '1');
  1180. } else {
  1181. toOff = true;
  1182. mediashadow = false;
  1183. $('#media').css('box-shadow', 'none');
  1184. $.cookie('mshadSetting', '0');
  1185. }
  1186. break;
  1187. case 'op-fastemote':
  1188. if (typeof($codes.fast) === 'string') {
  1189. toOff = true;
  1190. $.cookie('fastSetting', '0');
  1191. delete $codes.fast;
  1192. $('marquee').remove();
  1193. fastmsgs = 0;
  1194. } else {
  1195. toOn = true;
  1196. $.cookie('fastSetting', '1');
  1197. $codes['fast'] = '<marquee direction="right" scrollamount="' + marqueeSpeed + '">';
  1198. }
  1199. break;
  1200. case 'op-showjoinleave':
  1201. logTraffic = !logTraffic;
  1202. if (logTraffic) {
  1203. toOn = true;
  1204. $.cookie('logsSetting', '1');
  1205. $('.logoutput').show();
  1206. } else {
  1207. toOff = true;
  1208. $.cookie('logsSetting', '0');
  1209. $('.logoutput').hide();
  1210. $('#logs').html('');
  1211. logs = 0;
  1212. }
  1213. break;
  1214. case 'op-showroll':
  1215. showRoll = !showRoll;
  1216. if (showRoll) {
  1217. toOn = true;
  1218. $.cookie('showRollSetting', '1');
  1219. } else {
  1220. toOff = true;
  1221. $.cookie('showRollSetting', '0');
  1222. }
  1223. break;
  1224. case 'op-filtergray':
  1225. filterGreyname = !filterGreyname;
  1226. if (filterGreyname) toOn = true;
  1227. else toOff = true;
  1228. break;
  1229. case 'op-sameuser':
  1230. sameUserMessages = !sameUserMessages;
  1231. if (sameUserMessages) {
  1232. toOn = true;
  1233. $.cookie('indentSameUser', '1');
  1234. } else {
  1235. toOff = true;
  1236. $.cookie('indentSameUser', '0');
  1237. }
  1238. break;
  1239. case 'op-autoclean':
  1240. if (isMod) {
  1241. toggleAutoClean();
  1242. if (autoClean) toOn = true;
  1243. else toOff = true;
  1244. }
  1245. break;
  1246. }
  1247. if (toOff)
  1248. $(c).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1249. else if (toOn)
  1250. $(c).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1251. };
  1252.  
  1253. window.getPlaylist = function() { //heavily modified from Bibby's exportPlaylist() at https://github.com/Bibbytube/Instasynch under Playlist Additions/Export Playlist Command
  1254. var output = '';
  1255. var videoTitle = '';
  1256.  
  1257. for (i = 0; i < playlist.length; i++) {
  1258. if (playlist[i].title.length > 100) {
  1259. videoTitle = playlist[i].title.substring(0, 100);
  1260. videoTitle += '...';
  1261. } else {
  1262. videoTitle = playlist[i].title;
  1263. }
  1264. switch (playlist[i].info.provider) {
  1265. case 'youtube':
  1266. output += i + '. <span style="color: #FFB0B0">' + videoTitle + ' <span style="color: #84FFAB">-</span></span> <a style="color: #4FDFFA" href="http://youtube.com/watch?v=' + playlist[i].info.id + '">http://youtube.com/watch?v=';
  1267. break;
  1268. case 'vimeo':
  1269. output += i + '. <span style="color: #61CCFF">' + videoTitle + ' <span style="color: #84FFAB">-</span></span> <a style="color: #4FDFFA" href="http://vimeo.com/' + playlist[i].info.id + '">http://vimeo.com/';
  1270. break;
  1271. case 'twitch':
  1272. output += i + '. <span style="color: #E8BEFF">' + videoTitle + ' <span style="color: #84FFAB">-</span></span> <a style="color: #4FDFFA" href="http://twitch.tv/' + playlist[i].info.channel + '">http://twitch.tv/';
  1273. break;
  1274. case 'dailymotion':
  1275. output += i + '. <span style="color: #F8FFA1">' + videoTitle + ' <span style="color: #84FFAB">-</span></span> <a style="color: #4FDFFA" href="http://dailymotion.com/video/' + playlist[i].info.id + '">http://dailymotion.com/video/';
  1276. break;
  1277. default:
  1278. continue;
  1279. }
  1280. if (playlist[i].info.provider === 'twitch')
  1281. output += playlist[i].info.channel + '</a>\n<br />';
  1282. else
  1283. output += playlist[i].info.id + '</a>\n<br />';
  1284. }
  1285. var newWindow = window.open("", "_blank", "scrollbars=1,resizable=1");
  1286. newWindow.document.write('<span style="font-size: 16px; color: white">Select all (ctrl+a), copy/paste and save this somewhere.<br />Room: ' + ROOMNAME + '<br />Videos: ' + playlist.length + '</span><br /><br /><div id="playlistInfo" style="font-size: 12px; color: #84FFAB">' + output + '</div>');
  1287. newWindow.document.body.style.background = 'black';
  1288. newWindow.document.body.style.fontFamily = 'tahoma';
  1289. };
  1290. window.toggleBlackChat = function() {
  1291. if ($('.blackCSS').length < 1)
  1292. $('head').append('<link href="https://googledrive.com/host/0B2hdmKDeA0HDdG1PWFc5LWcxQ2c" type="text/css" rel="stylesheet" class="blackCSS">');
  1293. else
  1294. $('.blackCSS').remove();
  1295. }
  1296.  
  1297. };
  1298.  
  1299. function buildEmoteMenu() {
  1300.  
  1301. loadedEmoteMenu = true;
  1302.  
  1303. var $newcodes = {
  1304. //modified original emotes
  1305. 'chen': '<img src="http://i.imgur.com/j55EMQt.png" width="50" height="46" onclick="playSound(emoteSounds.chen);">',
  1306. 'doot': '<img src="http://i.imgur.com/WfUlQ5Q.gif" width="50" height="45" onclick="playSound(emoteSounds.doot);">',
  1307. 'bestgames': '<img src="http://i.imgur.com/ImyXj.png" width="48" height="54" onclick="playSound(emoteSounds.chad);">',
  1308. 'no': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="playSound(emoteSounds.no);">',
  1309. 'idontwantthat': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="playSound(emoteSounds.no);">',
  1310. 'heero' : '<img src="http://i.imgur.com/D7JCR6j.png" width="60" height="55">',
  1311. 'kek' : '<img src="http://i.imgur.com/xrw4paP.png" width="40" height="54">',
  1312. //additional emotes
  1313. 'enjoytheanime' : '<img src="http://i.imgur.com/aXPWln0.png" width="48" height="60">',
  1314. 'straya' : '<img src="http://i.imgur.com/PNB0kE9.gif" width="50" height="50">',
  1315. 'neverever' : '<img src="http://i.imgur.com/MJnWGHV.png" width="52" height="50">',
  1316. 'gud': '<img src="http://i.imgur.com/Ms3Zxne.png" width="62.5" height="50">',
  1317. 'feelssmug': '<img src="http://i.imgur.com/og9In6D.png" width="48" height="48">',
  1318. 'puke': '<img src="http://i.imgur.com/IADYHCP.png" width="58" height="58">',
  1319. 'tip': '<img src="http://i.imgur.com/QWhYbc8.gif" width="49" height="54">',
  1320. 'strut': '<img src="http://i.imgur.com/199ZHvl.gif" width="54" height="55">',
  1321. '2scooby': '<img src="http://i.imgur.com/ZsVKjbE.gif" width="68" height="50">',
  1322. 'penguin': '<img src="http://i.imgur.com/FBcmjnJ.gif" width="75" height="43">',
  1323. 'kabi': '<img src="http://i.imgur.com/F5qdDtE.gif" width="125" height="45">',
  1324. 'yoshi': '<img src="http://i.imgur.com/B6bBva0.gif" width="45" height="45">',
  1325. 'dumbass': '<img src="http://i.imgur.com/Q029MEI.gif" width="62" height="50">',
  1326. 'ryu': '<img src="http://i.imgur.com/xv1O1si.gif" width="45" height="48">',
  1327. 'skeletal': '<img src="http://i.imgur.com/EOJVmvF.gif" width="53" height="55">',
  1328. 'mako': '<img src="http://i.imgur.com/1tME9i9.gif" width="50" height="49">',
  1329. };
  1330.  
  1331. $.extend($codes, $newcodes);
  1332. $colorcodes = {
  1333. "knuckles": '</span><span style="color:tomato">',
  1334. "mario": '</span><span style="color:red">',
  1335. "starfox": '</span><span style="color:brown">',
  1336. "tomnook": '</span><span style="color:chocolate">',
  1337. "crashbandicoot": '</span><span style="color:orange">',
  1338. "orange": '</span><span style="color:orange">',
  1339. "pacman": '</span><span style="color:yellow">',
  1340. "gex": '</span><span style="color:yellowgreen">',
  1341. "link": '</span><span style="color:green">',
  1342. "halo2": '</span><span style="color:darkgreen">',
  1343. "chao": '</span><span style="color:aqua">',
  1344. "squirtle": '</span><span style="color:cyan">',
  1345. "liara": '</span><span style="color:steelblue">',
  1346. "bluebomber": '</span><span style="color:royalblue">',
  1347. "sonic": '</span><span style="color:blue">',
  1348. "krystal": '</span><span style="color:darkblue">',
  1349. "bigthecat": '</span><span style="color:indigo">',
  1350. "nights": '</span><span style="color:purple">',
  1351. "spyro": '</span><span style="color:blueviolet">',
  1352. "birdo": '</span><span style="color:deeppink">',
  1353. "kirby": '</span><span style="color:violet">',
  1354. "wakeupmrfreeman": '</span><span style="color:tan">',
  1355. "tomba": '</span><span style="color:pink">',
  1356. "metalgear": '</span><span style="color:silver">',
  1357. "kidicarus": '</span><span style="color: white">',
  1358. "gamenwatch": '</span><span style="color: black">',
  1359. "outline": '<span style="text-shadow: 1px 0 #00ccff, -1px 0px #00ccff, 0 1px #00ccff, 0 -1px #00ccff">',
  1360. "redoutline" : '<span style="text-shadow: 1px 0 #f00, -1px 0px #f00, 0 1px #f00, 0 -1px #f00">'
  1361. //"rainbowroad" : '</span><span class="rainbow">'
  1362. };
  1363. $fontcodes = {
  1364. "spoiler": '<font style="text-shadow: 0 0 black; background-color: #000; cursor: default" onmouseover="this.style.backgroundColor=\'transparent\'" onmouseout="this.style.backgroundColor=\'black\'">',
  1365. "i": '<font style="font-style:italic">',
  1366. "u": '<font style="text-decoration: underline">',
  1367. "b": '<strong>',
  1368. "s": '<strike>',
  1369. "endbold": '</strong>',
  1370. "endstrike": '</strike>',
  1371. "endspan": '</span></font></font></font>'
  1372. };
  1373.  
  1374. var emoteMenu,code;
  1375. emoteMenu = code = '';
  1376.  
  1377. var endtags = {
  1378. s: ['<strike', '</strike>', 'Strikethrough'],
  1379. b: ['<strong', '</strong>', 'Bold'],
  1380. u: ['<font style="text-decoration: underline"', '</font>', 'Underline'],
  1381. i: ['<font style="font-style:italic"', '</font>', 'Italics'],
  1382. endstrike: ['<strike', '</strike>', 'End Strikethrough'],
  1383. endbold: ['<strong', '</strong>', 'End Bold'],
  1384. endspan: ['<strong style="text-decoration: underline; font-style: italic"', '</strong>', 'End font effects'],
  1385. spoiler: ['<font style="text-shadow: 0 0 black; background-color: #000; cursor: default" onmouseover="this.style.backgroundColor=\'transparent\'" onmouseout="this.style.backgroundColor=\'black\'"', '</font>', 'Spoiler']
  1386. }
  1387. $.each($codes, function(code, image) {
  1388. if (code != 'fast') {
  1389. emoteMenu = emoteMenu + '<a title="' + code + '" onclick="useEmote(\'' + code + '\')">' + image + '</a>';
  1390. }
  1391. });
  1392. $.each($colorcodes, function(code, bgcolor) {
  1393. if (code !== 'rainbowroad') {
  1394. if (code == 'outline') {
  1395. bgcolor = 'color: black;box-shadow: 0 0 15px #00ccff inset';
  1396. } else if (code == 'redoutline') {
  1397. bgcolor = 'color: black;box-shadow: 0 0 15px #f00 inset';
  1398. } else {
  1399. bgcolor = bgcolor.slice(20, -2);
  1400. }
  1401. emoteMenu = emoteMenu + '<div class="colors" title="' + code + '" style="background-' + bgcolor + '" onclick="useEmote(\'' + code + '\')"></div>';
  1402. }
  1403. });
  1404. $.each($fontcodes, function(code, node) {
  1405. var endc = '<font';
  1406. var endtag = '</font>';
  1407. var txt = '';
  1408. if (code in endtags) {
  1409. endc = endtags[code][0];
  1410. endtag = endtags[code][1];
  1411. txt = endtags[code][2];
  1412. }
  1413. emoteMenu = emoteMenu + '<div class="colors" title="' + code + '" onclick="useEmote(\'' + code + '\')">' + endc + ' class="' + code + '">' + txt + endtag + '</div>';
  1414. });
  1415.  
  1416. $('#facecodesmenu').remove();
  1417. $('.container').prepend('<div id="facecodesmenu"></div>');
  1418.  
  1419. $('#facecodesmenu').append('<div id="emotes" style="display: inline-block">' + emoteMenu + '</div>');
  1420. $('#facecodesmenu #emotes').css('display', 'none');
  1421.  
  1422. $.extend($codes, $colorcodes);
  1423. $.extend($codes, $fontcodes);
  1424.  
  1425. };
  1426.  
  1427. function setCookies() {
  1428. loadedCookies = true;
  1429.  
  1430. $.lazyCookie('mshadSetting', '1', {
  1431. expires: 1234,
  1432. path: '/'
  1433. });
  1434. $.lazyCookie('logsSetting', '1', {
  1435. expires: 1234,
  1436. path: '/'
  1437. });
  1438. $.lazyCookie('logvidSetting', '1', {
  1439. expires: 1234,
  1440. path: '/'
  1441. });
  1442. $.lazyCookie('largePlayerSetting', '0', {
  1443. expires: 1234,
  1444. path: '/'
  1445. });
  1446. $.lazyCookie('fastSetting', '1', {
  1447. expires: 1234,
  1448. path: '/'
  1449. });
  1450. $.lazyCookie('showRollSetting', '1', {
  1451. expires: 1234,
  1452. path: '/'
  1453. });
  1454. $.lazyCookie('indentSameUser', '1', {
  1455. expires: 1234,
  1456. path: '/'
  1457. });
  1458.  
  1459. if ($.cookie('fastSetting') == '1' && typeof($codes.fast) === 'undefined')
  1460. $codes['fast'] = '<marquee direction="right" scrollamount="' + marqueeSpeed + '">';
  1461.  
  1462. if ($.cookie('mshadSetting') === '1')
  1463. mediashadow = true;
  1464. else
  1465. mediashadow = false;
  1466. if ($.cookie('showRollSetting') === '1')
  1467. showRoll = true;
  1468. else
  1469. showRoll = false;
  1470. if ($.cookie('logvidSetting') === '1')
  1471. logVids = true;
  1472. else
  1473. logVids = false;
  1474. if ($.cookie('indentSameUser') === '1')
  1475. sameUserMessages = true;
  1476. else
  1477. sameUserMessages = false;
  1478. }
  1479.  
  1480. window.shuffle = function() {
  1481. if (isMod) {
  1482. shuffling = true;
  1483. autosynch = false;
  1484. var videoInfos = [];
  1485. var i = 0;
  1486. for (var j = 0; j < playlist.length; j++) {
  1487. if (j !== $('.video.active').index())
  1488. videoInfos.push(playlist[j].info);
  1489. }
  1490. var recur = function(a, i) {
  1491. recurTime = setTimeout(function() {
  1492. var k = a.length;
  1493. if (i <= k) {
  1494. $('#shuffleProgress').text('Shuffle Progress: ' + i + ' / ' + k);
  1495. var j = Math.ceil(Math.random() * playlist.length) - 1;
  1496. global.sendcmd('move', {
  1497. info: a[i],
  1498. position: j
  1499. });
  1500. i++;
  1501. recur(a, i);
  1502. } else {
  1503. $('#shuffleProgress').text('Shuffle complete!');
  1504. setTimeout(function() {$('#shuffle').fadeOut(); shuffling = false; autosynch = true}, 2000);
  1505. }
  1506. }, 200);
  1507. }
  1508. $('#shuffle').fadeIn();
  1509. recur(videoInfos, i);
  1510. } else {
  1511. console.error('Cannot shuffle. Must be a mod.');
  1512. }
  1513. }
  1514.  
  1515. window.gmtClock = function() {
  1516.  
  1517. if (!loadedClock)
  1518. loadedClock = true;
  1519.  
  1520. var time = new Date();
  1521.  
  1522. var gmtTime = {hrs: time.getUTCHours(), min: time.getUTCMinutes(), sec: time.getUTCSeconds()}
  1523.  
  1524. for (var i in gmtTime) {
  1525. if (gmtTime[i] < 10) gmtTime[i] = "0" + gmtTime[i]
  1526. }
  1527.  
  1528. $('#gmtTime').text(gmtTime.hrs + ":" + gmtTime.min + ":" + gmtTime.sec + ' GMT');
  1529.  
  1530. setTimeout(function() {gmtClock()}, 1000);
  1531. };
  1532.  
  1533. function addChatListeners() {
  1534.  
  1535. loadedChatListeners = true;
  1536.  
  1537. $('#cin').on('keydown', function(e) {
  1538. if (e.which == 13) {
  1539. if ($('#cin').val() == "'stopshuffle" && isMod && shuffling) {
  1540. clearTimeout(recurTime);
  1541. $('#shuffleProgress').text('Shuffle stopped...');
  1542. setTimeout(function() {$('#shuffle').fadeOut(); shuffling = false; autosynch = true;}, 2000);
  1543. }
  1544. if ($('#cin').val() == "'autoclean" && isMod) {
  1545. toggleAutoClean();
  1546. }
  1547. if (byteCount($('#cin').val()) > 250) {
  1548. addMessage({username:''}, 'Message too large in size. Use less unicode characters. (Message was ' + byteCount($('#cin').val()) + ' bytes, max 250 bytes)', 'errortext');
  1549. return false;
  1550. }
  1551. var msgTest = $('#cin').val().split(' ');
  1552. if ($('#cin').val().slice(0, 9) == "'setskip " && !isNaN(parseInt(msgTest[1])) && msgTest[1] > -1 && isMod) {
  1553. addMessage({username:''}, 'Skip rate set to ' + msgTest[1] + '%.', 'hashtext');
  1554. }
  1555. if ($('#cin').val() == "'clear") {
  1556. clearChat();
  1557. }
  1558. if (msgTest[0].toLowerCase() == "'countvids" && msgTest[1] !== undefined) {
  1559. findUserVideos(msgTest[1]);
  1560. }
  1561. if (msgTest[0] == "&#8203;$r&#8203;o&#8203;l&#8203;l" || msgTest[0] == "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l") {
  1562. return false;
  1563. }
  1564. if (msgTest[0].toLowerCase() === "$roll" && $.cookie("username") !== undefined) {
  1565. msgTest[0] = "&#8203;$r&#8203;o&#8203;l&#8203;l";
  1566. var numbers = 2;
  1567. if (msgTest.length > 1) {
  1568. var numTest = parseInt(msgTest[1]);
  1569. if (!isNaN(numTest) && numTest > 0 && numTest < 11) {
  1570. numbers = msgTest[1];
  1571. }
  1572. }
  1573. numbers = parseInt(numbers);
  1574. var numCount = "1".repeat(numbers);
  1575. numCount = parseInt(numCount) * 9 + 1;
  1576. var rollnum = "000000000" + Math.floor(Math.random() * numCount).toString();
  1577. rollnum = rollnum.slice(-numbers);
  1578. msgTest[msgTest.length] = rollnum;
  1579. msgTest[msgTest.length] = "&#8203;";
  1580. $('#cin').val(msgTest.join(" "));
  1581. }
  1582. if (msgTest[0].toLowerCase() === "$8ball" && $.cookie("username") !== undefined) {
  1583. eight_choices = [
  1584. "It is certain",
  1585. "It is decidedly so",
  1586. "Without a doubt",
  1587. "Yes - definitely",
  1588. "You may rely on it",
  1589. "As I see it, yes",
  1590. "Most likely",
  1591. "Outlook good",
  1592. "Signs point to yes",
  1593. "Yes",
  1594. "Ask again later",
  1595. "Better not tell you now",
  1596. "Cannot predict now",
  1597. "Don't count on it",
  1598. "My reply is no",
  1599. "My sources say no",
  1600. "Outlook not so good",
  1601. "Very doubtful",
  1602. "Never",
  1603. "Of course not"
  1604. ];
  1605. msgTest[0] = "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l";
  1606. answer = eight_choices[Math.floor(Math.random() * eight_choices.length)];
  1607. msgTest[msgTest.length] = "|" + answer + "|";
  1608. msgTest[msgTest.length] = "&#8203;";
  1609. $('#cin').val(msgTest.join(" "));
  1610. }
  1611. }
  1612. });
  1613. }
  1614.  
  1615. function resetHTML(a) {
  1616.  
  1617. $('<div id="togglechat"><img src="http://i.imgur.com/EZ7DAGs.png"></div><div id="togglevideo"></div><div id="gmtTime"></div>').insertAfter('.playlist-controls .controls .settings');
  1618. ($('#lead').detach()).insertBefore('.st-poll');
  1619. ($('#unlead').detach()).insertBefore('.st-poll');
  1620. ($('#create-pollBtn').detach()).insertBefore('.st-poll');
  1621. $('#lead').text('Lead');
  1622. $('#create-pollBtn.mod').text('Poll');
  1623. $('#title.formbox').width('374px');
  1624. $('.formbox.create-poll-option').width('374px');
  1625. $('#resynch').text('Resynch Video');
  1626. $('#reload').text('Reload Media');
  1627. var plistSettings = '<div class="menu-split"></div>';
  1628. if (isMod)
  1629. plistSettings += '<li id="shuffleplist" style="color: #006bfe">Shuffle Playlist</li>';
  1630. plistSettings += '<li id="getplist">Get Playlist Info</li><li id="gethistory">View Video History</li><li id="hardrefresh" onclick="document.location.reload(true)">Hard Refresh</li>';
  1631. $('#playlist-settings-menu').append(plistSettings);
  1632. if ($('.counter').children().eq(0).text().trim() == 'Skips')
  1633. $('.counter').children().eq(0).attr('class', 'invisible-item-script');
  1634. $('#chat .left').prepend('<div id="chatcontrols"><img id="emmenu" class="settings toggle" height="24" src="http://i.imgur.com/vETtK.png" width="16" onclick="expandEmotes();"></div>');
  1635. $('<br class="roomlinks" /><div class="st-room-links"><a id="st-live-room"><span class="st-room-link st-room-link-live st-room-link-active">Live</span></a><a href="http://drowngaben.x10.mx/v4c/script/help/" target="_blank"><span class="st-room-link st-room-link-help" style="color: #A0FFA0;">Script Help</span></a>' + a + '</div>').insertBefore($('.descr-stats'));
  1636. $('.stage').prepend('<div id="curtain"><div id="curtainTop"></div><div id="curtainFloor"></div></div><div class="logoutput" style="width: 120px;position: absolute;height: 48px;color: green;margin-top: -49px;font-size: 12px;overflow: hidden;"><div id="logs"></div></div>');
  1637. $('#create-poll').append('<button id="clear-options">Clear Options</button>');
  1638. $('.poll-container').append('<ul id="viewHistory" style="display: none"><div class="close-history x" onclick="$(\'#gethistory\').click();"></div></ul>');
  1639. $('#chat .left').prepend('<div id="newUpdate">Script updated! Update through your browser\'s plugin, or <a href="https://greatest.deepsurf.us/en/scripts/6366-v4c-instasynch-additional-features" target="_blank">get it here</a>!</div>');
  1640. $('<div class="players"><div id="players">layout:&nbsp;<a class="normal" href="#">normal</a>&nbsp;<a class="large" href="#">large</a>&nbsp;<a class="larger" href="#">larger</a></div></div>').insertAfter('.stage');
  1641. $('#unlead').attr('class', 'mod');
  1642. $('#logs').html('');
  1643. if ($.cookie('logsSetting') === '0') {
  1644. $('.logoutput').hide();
  1645. logTraffic = false;
  1646. $('#logs').html('');
  1647. }
  1648. if (userInfo.loggedin) {
  1649. for (var q = 0; q < users.length; q++) {
  1650. if ($('.users li')[q].textContent.toLowerCase() == userInfo.username.toLowerCase()) {
  1651. var userMe = $('.users li').eq(q);
  1652. userMe.attr('id', 'me');
  1653. break;
  1654. }
  1655. }
  1656. }
  1657. for (var i = 0; i < $('.OptionsSetting').length; i++) {
  1658. var op = $('.OptionsSetting')[i];
  1659. switch (op.parentNode.id) {
  1660. case 'op-showadd':
  1661. if (logVids)
  1662. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1663. else
  1664. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1665. break;
  1666. case 'op-showshadow':
  1667. if (mediashadow)
  1668. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1669. else
  1670. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1671. break;
  1672. case 'op-fastemote':
  1673. if (typeof($codes.fast) !== 'undefined')
  1674. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1675. else
  1676. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1677. break;
  1678. case 'op-showjoinleave':
  1679. if (logTraffic)
  1680. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1681. else
  1682. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1683. break;
  1684. case 'op-showroll':
  1685. if (showRoll)
  1686. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1687. else
  1688. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1689. break;
  1690. case 'op-filtergray':
  1691. if (filterGreyname)
  1692. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1693. else
  1694. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1695. break;
  1696. case 'op-autoclean':
  1697. if (isMod) {
  1698. if (autoClean)
  1699. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1700. else
  1701. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1702. } else
  1703. $(op).attr('src', 'http://i.imgur.com/bpWsVbY.png');
  1704. break;
  1705. case 'op-sameuser':
  1706. if (sameUserMessages)
  1707. $(op).attr('src', 'http://i.imgur.com/vsDcHjN.gif');
  1708. else
  1709. $(op).attr('src', 'http://i.imgur.com/ZEl3BsK.gif');
  1710. break;
  1711. case 'op-defqual':
  1712. $(op).attr('src', 'http://i.imgur.com/bpWsVbY.png');
  1713. break;
  1714. }
  1715. }
  1716. }
  1717.  
  1718. function setHTML() {
  1719.  
  1720. var desc = '';
  1721. var a = '';
  1722.  
  1723. var removenodes = [
  1724. '#togglechat',
  1725. '#togglevideo',
  1726. '#gmtTime',
  1727. '.menu-split',
  1728. '#getplist',
  1729. '#gethistory',
  1730. '#hardrefresh',
  1731. '#chatcontrols',
  1732. '#clear-options',
  1733. '#viewHistory',
  1734. '#newUpdate',
  1735. '.players',
  1736. '.st-descr-avatar',
  1737. '.roomlinks',
  1738. '.st-room-links',
  1739. '.logoutput',
  1740. '#curtain',
  1741. '.blackCSS'
  1742. ]
  1743. for (var i = 0; i < removenodes.length; i++) {
  1744. $(removenodes[i]).remove();
  1745. }
  1746. var currentURL = $(location).attr('href').toLowerCase();
  1747. if ($('#top.room-top img[src="http://instasynch.com/images/logoNoBG.png"]')[0] !== undefined)
  1748. var topimg = $('#top.room-top img[src="http://instasynch.com/images/logoNoBG.png"]');
  1749. else if ($('#top.room-top img[src="/images/logoNoBG.png"]')[0] !== undefined)
  1750. var topimg = $('#top.room-top img[src="/images/logoNoBG.png"]');
  1751. else
  1752. var topimg = $('#top.room-top img[src="http://i.imgur.com/DlZXK.png"]');
  1753. isv4c = false;
  1754. if (currentURL.indexOf('v4c') > -1) {
  1755. $('.top-descr').html($('.top-descr').html().toLowerCase().replace('v4c\'s room', 'Vidya4chan'));
  1756. a = '<a href="http://v4c.fathax.com/v4c/" target="_blank"><span class="st-room-link st-room-link-boards">Image Board</span></a>' +
  1757. '<a href="/rooms/anime4chan" target="_blank"><span class="st-room-link st-room-link-anime">Anime4chan</span></a>' +
  1758. '<a id="tcButton" title="Password is \'v4c\'." href="http://tinychat.com/vidya4chans" target="_blank"><span class="st-room-link st-room-link-tc">Tinychat</span></a>';
  1759. desc = '<div class="description-title">About Vidya4chan</div><div class="description"><span style="color: #DA3231; ' +
  1760. 'font-weight: bold">No bump begging. No skip begging.</span> No skip trains. No static videos. No furry/MLP videos. ' +
  1761. 'Try to keep music videos to a minimum. Polls must pass 3:1. In the interests of keeping things running smoothly please ' +
  1762. 'don\'t add static videos or music unless it actually has a video to go with it.<br><span style="color:#789922">&gt;unlike ' +
  1763. 'all the other rooms with power tripping mods.</span><br><br><strong style="text-align: center;display: block">Enjoy the anime with v4c: <a href="' +
  1764. '/rooms/anime4chan" style="color: #36c">http://instasynch.com/rooms/anime4chan</a><br>' +
  1765. '<span style="color:#DA3231;">WE CHAN NOW: </span><a href="http://v4c.fathax.com/v4c/" style="color: #36c">' +
  1766. 'http://v4c.fathax.com/v4c/</a></strong></div></div>';
  1767. isv4c = true;
  1768. } else if (currentURL.indexOf('anime4chan') > -1) {
  1769. $('.top-descr').html($('.top-descr').html().toLowerCase().replace('anime4chan\'s room', 'Anime4chan'));
  1770. a = '<a href="http://v4c.fathax.com/v4c/" target="_blank"><span class="st-room-link st-room-link-boards">Image Board</span></a>' +
  1771. '<a href="/rooms/v4c" target="_blank"><span class="st-room-link st-room-link-vidya">Vidya4chan</span></a>' +
  1772. '<a id="tcButton" title="Password is \'v4c\'." href="http://tinychat.com/vidya4chans" target="_blank"><span class="st-room-link st-room-link-tc">Tinychat</span></a>';
  1773. desc = '<div class="description-title">About Anime4chan</div><div class="description">There\'s nothing here at the moment... Enjoy the ' +
  1774. 'anime here with other users!<br><br><strong style="text-align: center;display: block">Return to Vidya4chan: <a href="' +
  1775. '/rooms/vidya4chan" style="color: #36c">http://instasynch.com/rooms/vidya4chan</a><br><span style="color:#DA3231;">WE CHAN NOW: </span>' +
  1776. '<a href="http://v4c.fathax.com/v4c/" style="color: #36c">http://v4c.fathax.com/v4c/</a></strong></div></div>';
  1777. isv4c = true;
  1778. }
  1779. if (isv4c) {
  1780. $('.roomFooter').html(desc);
  1781. setFavIcon('http://i.imgur.com/DmMh2O9.png');
  1782. topimg.css('margin-top', '5px');
  1783. topimg.width('84');
  1784. topimg.height('47');
  1785. topimg.attr('src', 'http://i.imgur.com/DlZXK.png');
  1786. $('.poll-container').css('background', 'url("http://drowngaben.x10.mx/v4c/rotate/")');
  1787. $('.top-descr').prepend('<div class="st-descr-avatar" style="float: left;margin-right: 10px;"><img height="50" width="40" src="http://i.imgur.com/2ktlex7.png"></div>');
  1788. } else {
  1789. $('.poll-container').css('background', '');
  1790. topimg.attr('src', 'http://instasynch.com/images/logoNoBG.png');
  1791. setFavIcon('http://instasynch.com/favicon.ico');
  1792. topimg.attr('style', null);
  1793. $('.st-descr-avatar').remove();
  1794. }
  1795. if ($('.descr-stat-value')[1].textContent.indexOf(',') < 0)
  1796. while (/(\d+)(\d{3})/.test($('.descr-stat-value')[1].textContent)) { //stackoverflow
  1797. $('.descr-stat-value')[1].textContent = $('.descr-stat-value')[1].textContent.replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
  1798. }
  1799. // ================ static node changes ================
  1800. if (!loadedHTML) {
  1801. loadedHTML = true;
  1802. var friendsList = $('.friendsList').detach();
  1803. var loginarea = $('#loginfrm').detach();
  1804. $('.container').prepend(friendsList);
  1805. $('.container').prepend('<div id="shuffle"><div id="shuffleProgress">Shuffle Progress: 0 / 0</div></div><div id="scriptOptions"><div id="optionLines"><span id="OptionsButton" class="sc-txt">Script Options</span><span id="OptionsVersion" class="sc-txt">' + scriptVer + '</span></div></div>');
  1806. $('.container').prepend(loginarea);
  1807. $('body').prepend('<div id="OptionsMenu"><div class="close-OptionMenu x"></div><div id="OptionsTop"><div id="OptionsTopImage"></div><strong>v4c\'s InstaSynch Addon Script</strong>' +
  1808. '<span class="OptionsVersion"></span></div><div id="OptionsBottom"><ul id="OptionsList"><div class="op-seperator">Toggles</div><li id="op-showadd"><img class="Options' +
  1809. 'Setting" />Show Video Add Messages<div class="OptionsButton">Toggle</div></li><li id="op-showshadow"><img class="OptionsSetting" />Display Video Source Shadow' +
  1810. '<div class="OptionsButton">Toggle</div></li><li id="op-fastemote"><img class="OptionsSetting" />:fast: Emote<div class="OptionsButton">Toggle</div></li>' +
  1811. '<li id="op-showjoinleave"><img class="OptionsSetting" />Display User Join/Leave Log<div class="OptionsButton">Toggle</div></li><li id="op-showroll"><img class=' +
  1812. '"OptionsSetting" />Display $roll and $8ball Messages<div class="OptionsButton">Toggle</div></li><li id="op-filtergray"><img class="OptionsSetting" />Filter ' +
  1813. 'Unregistered Messages<div class="OptionsButton">Toggle</div></li><li id="op-autoclean"><img class="OptionsSetting" />Playlist Autoclean<div class="OptionsButton">' +
  1814. 'Toggle</div></li><li id="op-sameuser"><img class="OptionsSetting" />Indent Same-User Messages<div class="OptionsButton">Toggle</div></li><li id="op-defqual">' +
  1815. '<img class="OptionsSetting" />Default Video Quality (no function yet)</li><li id="op-button" class="swapchatstyle" onclick="toggleBlackChat()">Toggle Black Chat</li><div class="op-seperator">Functions</div><li id="op-button" class="switchemotestyle" onclick="swapEmoteStyle()">Emote Menu: use <span style="color: #0f0">/emote</span> instead</li><br /><li id="op-button" onclick="clearChat()">Clear All Chat ' +
  1816. 'Messages</li><br /><li id="op-button" onclick="showChangelog()">Show Changelog in Chat</li><div class="op-seperator">Variables</div><li class="op-var">:fast: Scroll Speed ' +
  1817. '<input id="marqueeinput" value="50" size="2" type="text" max="99" maxlength="3" onkeyup="setFast($(this).val())"></li><div class="op-seperator">Styles</div><li id="op-style">' +
  1818. 'Player Button Color <input id="pickerButtons" size="6" value="CCCCCC" onchange="updateColor(\'pickerButtons\', $(this).val())"></li><li id="op-style">Slider Handle Color ' +
  1819. '<input id="pickerHandles" size="6" value="CCCCCC" onchange="updateColor(\'pickerHandles\', $(this).val())"></li><li id="op-style">Progress Bar Color <input id="pickerProgress" ' +
  1820. 'size="6" value="66A8CC" onchange="updateColor(\'pickerProgress\', $(this).val())"></li><li id="op-style">Player Text Color <input id="pickerText" size="6" value="CCCCCC" ' +
  1821. 'onchange="updateColor(\'pickerText\', $(this).val())"></li></ul></div><div id="OptionsBottomKey"><div id="OptionsKeyLeft"><img src="http://i.imgur.com/xGULibl.png"> = on; <img ' +
  1822. 'src="http://i.imgur.com/VhzbnB3.png" /> = off; <img src="http://i.imgur.com/bpWsVbY.png" /> = disabled</div><div id="OptionsKeyRight">script created by biggles</div></div></div>');
  1823. $('.OptionsVersion').text(scriptVer);
  1824. $('#OptionsVersion.sc-txt').text(scriptVer);
  1825. $('#add-friend').parent().parent().css('display', 'none');
  1826. $('<li><div><div class="category sAddFriend" onclick="$(\'#add-friend\').click()">Add a Friend</div></div></li>').appendTo('.friendsList-list');
  1827. $('.clicker#myName').append('<img src="http://i.imgur.com/kB8y50I.png" class="arrowDown">');
  1828. }
  1829. $('#shuffle').hide();
  1830. resetHTML(a);
  1831. getUserInfo(userInfo.username, function(avatar) {
  1832. var profimg = $('.clicker#myName img')[0];
  1833. profimg.src = avatar;
  1834. $(profimg).attr('width', '24');
  1835. $(profimg).attr('height', '24');
  1836. });
  1837. updateRecent($('.video.active').index());
  1838. if (typeof(buttonPicker) === 'undefined') {
  1839. window.buttonPicker = new jscolor.color(document.getElementById('pickerButtons'), {});
  1840. window.progressPicker = new jscolor.color(document.getElementById('pickerProgress'), {});
  1841. window.textPicker = new jscolor.color(document.getElementById('pickerText'), {});
  1842. window.handlesPicker = new jscolor.color(document.getElementById('pickerHandles'), {});
  1843. }
  1844. $('#togglechat').tipTip({
  1845. content: "Toggle Chat",
  1846. fadeIn: 0,
  1847. fadeOut: 0,
  1848. defaultPosition: "left"
  1849. });
  1850. $('#emmenu').tipTip({
  1851. content: "Emote Menu",
  1852. fadeIn: 0,
  1853. fadeOut: 0,
  1854. defaultPosition: "left"
  1855. });
  1856. $('#op-button.switchemotestyle').tipTip({
  1857. content: "Changes what the emote menu uses when an image is clicked. Inline emotes are visible by all script users only, while emotes used with backslashes can be seen by anyone.",
  1858. fadeIn: 0,
  1859. fadeOut: 0,
  1860. defaultPosition: "top"
  1861. });
  1862. $('#resynch').tipTip({
  1863. content: "Changes the time of the video to match the server's position.",
  1864. fadeIn: 0,
  1865. fadeOut: 0,
  1866. defaultPosition: "right"
  1867. });
  1868. $('#reload').tipTip({
  1869. content: "Kills and reloads the video without refreshing.",
  1870. fadeIn: 0,
  1871. fadeOut: 0,
  1872. defaultPosition: "right"
  1873. });
  1874. $('#getplist').tipTip({
  1875. content: "Opens a new window containing the current playlist information (video links, contributors, etc). <span style='color:red'>Pop-up.</span>",
  1876. fadeIn: 0,
  1877. fadeOut: 0,
  1878. defaultPosition: "right"
  1879. });
  1880. $('#shuffleplist').tipTip({
  1881. content: "Moves the current list of videos to random positions. Try not to use any commands while this is working. <span style='color:#006bfe'>Mods only.</span>",
  1882. fadeIn: 0,
  1883. fadeOut: 0,
  1884. defaultPosition: "right"
  1885. });
  1886. $('#gethistory').tipTip({
  1887. content: "Toggle. Lets you view the last 12 videos you've watched. <span style='color:lime'>Appears under the poll area.</span>",
  1888. fadeIn: 0,
  1889. fadeOut: 0,
  1890. defaultPosition: "right"
  1891. });
  1892. $('#hardrefresh').tipTip({
  1893. content: "Refreshes the page ignoring all locally cached files, forcing a reload of all site files. Does not clear cache.",
  1894. fadeIn: 0,
  1895. fadeOut: 0,
  1896. defaultPosition: "right"
  1897. });
  1898. $('#togglevideo').tipTip({
  1899. content: "Drops a curtain over the currently playing video. Toggle.",
  1900. fadeIn: 0,
  1901. fadeOut: 0,
  1902. defaultPosition: "left"
  1903. });
  1904. };
  1905.  
  1906. function setBinds() {
  1907.  
  1908. loadedBinds = true;
  1909.  
  1910.  
  1911. $('#skip').on('click', function() {
  1912. $('#skip-count').attr('style', 'color: #3F0!important');
  1913. });
  1914. $('#scriptOptions').on('click', function() {
  1915. $('#OptionsMenu').toggle();
  1916. });
  1917.  
  1918. $('#tcButton').on('click', function() {
  1919. alert('The password to the room is \'v4c\'.');
  1920. });
  1921. $('#players a.normal').on('click', function() {
  1922. if (largePlayer || largerPlayer)
  1923. switchResolution(0);
  1924. else return false;
  1925. });
  1926. $('#players a.large').on('click', function() {
  1927. if (!largePlayer || largerPlayer)
  1928. switchResolution(1);
  1929. else return false;
  1930. });
  1931. $('#players a.larger').on('click', function() {
  1932. if (largePlayer || !largerPlayer)
  1933. switchResolution(2);
  1934. else return false;
  1935. });
  1936. if (largePlayer && !largerPlayer) {
  1937. $('#players a.large').attr('style', 'color: white!important; text-decoration: none!important');
  1938. $('#players a.large').attr('href', null);
  1939. } else if (largerPlayer && !largePlayer) {
  1940. $('#players a.larger').attr('style', 'color: white!important; text-decoration: none!important');
  1941. $('#players a.larger').attr('href', null);
  1942. } else if (!largePlayer && !largerPlayer) {
  1943. $('#players a.normal').attr('style', 'color: white!important; text-decoration: none!important');
  1944. $('#players a.normal').attr('href', null);
  1945. }
  1946.  
  1947. $('#chat-messages').unbind('scroll');
  1948.  
  1949. //(C) BibbyTube, (C) Faqqq
  1950. //https://github.com/Bibbytube/Instasynch/blob/master/Chat%20Additions/Autoscroll%20Fix/autoscrollFix.js
  1951. //from instasynch's io.js with modified height multiplier
  1952. $('#chat-messages').on('scroll', function() {
  1953. var scrollHeight = $(this)[0].scrollHeight,
  1954. scrollTop = $(this).scrollTop(),
  1955. height = $(this).height();
  1956.  
  1957. //scrollHeight - scrollTop will be 290 when the scrollbar is at the bottom
  1958. //height of the chat window is 280, not sure where the 10 is from
  1959. if ((scrollHeight - scrollTop) < height * 2.5) {
  1960. autoscroll = true;
  1961. } else {
  1962. autoscroll = false;
  1963. }
  1964. });
  1965.  
  1966. $('#lead').on('click', function() {
  1967. if (isMod) {
  1968. $('#unlead').css('visibility', 'visible');
  1969. $('#playlistcontrols').height('49px');
  1970. $('.stage').stop().animate({
  1971. height: stageBase + $('#playlistcontrols').height() + 'px'
  1972. }, 200)
  1973. }
  1974. });
  1975.  
  1976. $('#unlead').on('click', function() {
  1977. if (isMod) {
  1978. $('#playlistcontrols').height('25px');
  1979. $('.stage').stop().animate({
  1980. height: stageBase + 'px'
  1981. }, 200)
  1982. }
  1983. });
  1984. $('.close-OptionMenu.x').on('click', function() {
  1985. $('#OptionsMenu').hide();
  1986. });
  1987.  
  1988. $("#add-option").on('click', function() {
  1989. if ($('.create-poll-option').length >= 10) {
  1990. $('#add-option').attr('disabled', 'true');
  1991. $('#add-option').text('Max options! (10)');
  1992. }
  1993. });
  1994.  
  1995. $('#getplist').on('click', function() {
  1996. getPlaylist();
  1997. });
  1998. $('#shuffleplist').on('click', function() {
  1999. if (isMod) {
  2000. if (shuffling === false)
  2001. shuffle();
  2002. else {
  2003. $('#chat-messages').append('<div class="message"><strong style="color: #f00">Currently shuffling the playlist. Please wait until it is finished.</strong></div>');
  2004. messages++;
  2005. cleanChat();
  2006. }
  2007. } else {
  2008. $('#chat-messages').append('<div class="message"><strong style="color: #f00">Sorry, you must be a mod to use this.</strong></div>');
  2009. messages++;
  2010. cleanChat();
  2011. }
  2012. });
  2013.  
  2014. $('#gethistory').on('click', function() {
  2015. if (recentVidInfo.length > 0) {
  2016. $('#viewHistory').toggle();
  2017. if ($('#viewHistory').css('display') !== 'none') {
  2018. viewHistory(recentVidInfo);
  2019. } else if ($('#viewHistory').css('display') === 'none') {
  2020. $('#viewHistory').empty();
  2021. }
  2022. }
  2023. });
  2024.  
  2025. $('#cin').on('focus', function() {
  2026. if (isv4c) setFavIcon('http://i.imgur.com/DmMh2O9.png'); else setFavIcon('/favicon.ico');
  2027. document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  2028. global.page.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  2029. newMsg = false;
  2030. });
  2031. $('#submit-poll').on('click', function() {
  2032. $('#create-poll').hide();
  2033. });
  2034.  
  2035. $('#togglechat').on('click', function() {
  2036. var fcm = $('#facecodesmenu');
  2037. if (fcm.css('display') != 'none' ) {
  2038. expandEmotes();
  2039. }
  2040. $('.logoutput').toggle();
  2041. $('#chat').toggle();
  2042. });
  2043. $('#togglevideo').on('click', function() {
  2044. var ctn = $('#curtainTop');
  2045. if ($('#curtainFloor').height() === 0) $('#curtainFloor').height(72)
  2046. else $('#curtainFloor').height(0);
  2047. if (ctn.height() === 0) $('#curtainTop').height($('#media').height() - 72)
  2048. else $('#curtainTop').height(0);
  2049. });
  2050.  
  2051. $('#add-option').on("click", function() {
  2052. $('.formbox.create-poll-option').width('374px');
  2053. });
  2054.  
  2055. $('#clear-options').on("click", function() {
  2056. $('#create-poll input').val('');
  2057. });
  2058.  
  2059. $("#URLinput").on("keyup", function(event) {
  2060. if (event.keyCode == 13) {
  2061. event.preventDefault();
  2062. $("#addUrl").click();
  2063. }
  2064. });
  2065.  
  2066. $("html").on("keyup", function(event) {
  2067.  
  2068. if (event.keyCode == 118 && isv4c) { //F7
  2069. event.preventDefault();
  2070. $('.poll-container').css('background', 'url("http://drowngaben.x10.mx/v4c/rotate/")');
  2071. }
  2072. if (event.keyCode == 120) { //F9
  2073. event.preventDefault();
  2074. $("#emmenu").click();
  2075. }
  2076.  
  2077. });
  2078. $('.click-nav .js').unbind('click');
  2079. $('.click-nav .js').on("click", function() {
  2080. var userMenu = $('#loggedInAs .click-nav .js li ul');
  2081. if (userMenu.height() !== 0)
  2082. userMenu.attr('style', 'height: 0px');
  2083. else userMenu.attr('style', 'height: 128px');
  2084. });
  2085. $('.OptionsButton').on("click", function() {
  2086. var buttonid = this.parentNode.id;
  2087. var optionstate = $(this).parent()[0].firstChild.className.split(' ')[1];
  2088. var imgdiv = $(this).parent()[0].firstChild;
  2089. toggleScriptSetting(buttonid, optionstate, imgdiv);
  2090. });
  2091.  
  2092. };
  2093.  
  2094. function unbindAll() {
  2095.  
  2096. var nodes = [
  2097. '.OptionsButton',
  2098. '.click-nav .js',
  2099. 'html',
  2100. '#URLinput',
  2101. '#clear-options',
  2102. '#add-option',
  2103. '#togglevideo',
  2104. '#togglechat',
  2105. '#submit-poll',
  2106. '#gethistory',
  2107. '#getplist',
  2108. '#add-option',
  2109. '.close-OptionMenu.x',
  2110. '#unlead',
  2111. '#lead',
  2112. '#chat-messages',
  2113. '#players a.larger',
  2114. '#players a.large',
  2115. '#players a.normal',
  2116. '#tcButton',
  2117. '#scriptOptions',
  2118. '#skip'
  2119. ];
  2120. for (var i = 0; i < nodes.length; i++) {
  2121. $(nodes[i]).off();
  2122. }
  2123. }
  2124.  
  2125. postConnect.push(loadGlobalVariables);
  2126. postConnect.push(loadFunctions);
  2127. postConnect.push(setCookies);
  2128. postConnect.push(buildEmoteMenu);
  2129. postConnect.push(setHTML);
  2130. postConnect.push(addChatListeners);
  2131. postConnect.push(loadCSS);
  2132. postConnect.push(setBinds);
  2133. postConnect.push(gmtClock);
  2134. postConnect.push(connected);
  2135.  
  2136. //reconnectFns.push(loadFunctions);
  2137. reconnectFns.push(loadGlobalVariables);
  2138. reconnectFns.push(setCookies);
  2139. reconnectFns.push(buildEmoteMenu);
  2140. reconnectFns.push(setHTML);
  2141. reconnectFns.push(unbindAll);
  2142. reconnectFns.push(addChatListeners);
  2143. reconnectFns.push(loadCSS);
  2144. reconnectFns.push(setBinds);
  2145. reconnectFns.push(connected);
  2146.  
  2147.  
  2148.  
  2149. global.onConnected = function() {
  2150. global.reconnectAttempt = 1;
  2151. messages = 0;
  2152. postConnectDo(initialLoad);
  2153. }
  2154.  
  2155. console.log('Reached end of script.');
  2156.  
  2157. window.errors = function() {
  2158. var errorMessage = '<div class="message urgenttext" style="background-color: black; font-weight: bold">Failed to load: ';
  2159. var errorList = '';
  2160. if (typeof(scriptVer) === 'undefined')
  2161. scriptVer = 'undefined';
  2162. if (!loadedFunctions) {
  2163. errorList += 'functions, ';
  2164. console.error(scriptVer + ': Failed to load functions');
  2165. }
  2166. if (!loadedGlobalVariables) {
  2167. errorList += 'globalVariables, ';
  2168. console.error(scriptVer + ': Failed to load global variables');
  2169. }
  2170. if (!loadedCSS) {
  2171. errorList += 'CSS, ';
  2172. console.error(scriptVer + ': Failed to load CSS');
  2173. }
  2174. if (!loadedConnected) {
  2175. errorList += 'connected, ';
  2176. console.error(scriptVer + ': Failed to load function "connected"');
  2177. }
  2178. if (!loadedCookies) {
  2179. errorList += 'cookies, ';
  2180. console.error(scriptVer + ': Failed to load cookies');
  2181. }
  2182. if (!loadedClock) {
  2183. errorList += 'gmtClock, ';
  2184. console.error(scriptVer + ': Failed to load GMT clock');
  2185. }
  2186. if (!loadedChatListeners) {
  2187. errorList += 'chatEvents, ';
  2188. console.error(scriptVer + ': Failed to load chat event listeners');
  2189. }
  2190. if (!loadedEmoteMenu) {
  2191. errorList += 'emotes, ';
  2192. console.error(scriptVer + ': Failed to load emote system');
  2193. }
  2194. if (!loadedHTML) {
  2195. errorList += 'HTML, ';
  2196. console.error(scriptVer + ': Failed to load HTML');
  2197. }
  2198. if (!loadedBinds) {
  2199. errorList += 'binds, ';
  2200. console.error(scriptVer + ': Failed to load HTML binds');
  2201. }
  2202. if (errorList == '') {
  2203. errorList = '<span style="color: lime">none</span>';
  2204. console.log('Seems like everything has loaded.')
  2205. }
  2206. errorMessage += errorList;
  2207. errorMessage += '</div>';
  2208. $('#chat-messages').append(errorMessage);
  2209. };
  2210.  
  2211. //if something is wrong, try typing errors() in the console