v4c/InstaSynch Additional Features

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

目前为 2015-01-09 提交的版本。查看 最新版本

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