v4c/InstaSynch Additional Features

Provides many additional features to enhance the experience of watching the same videos every day. Created by biggles; all credit given in script source.

目前為 2015-04-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name v4c/InstaSynch Additional Features
  3. // @namespace v4c
  4. // @description Provides many additional features to enhance the experience of watching the same videos every day. Created by biggles; all credit given in script source.
  5. // @include *://*.instasync.com/r/*
  6. // @include *://instasync.com/r/*
  7. // @match *://*.instasync.com/r/*
  8. // @match *://instasync.com/r/*
  9. // @version 2.009
  10. // @grant none
  11. // @author biggles
  12. // ==/UserScript==
  13.  
  14. //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).
  15.  
  16. /*
  17. <InstaSync - Watch Videos with friends.>
  18. Copyright (C) 2015 InstaSync
  19. */
  20.  
  21. window.messages = 0;
  22. String.prototype.repeat = function(num) {
  23. return new Array(num + 1).join(this);
  24. };
  25.  
  26. //for emote script creators, put this at the end: script.delayedTasks.push(name_of_emote_function);
  27. //script.delayedTasks is a list of functions (sans arguments) executed 700ms after everything else
  28. //or add all emotes to script.$externalEmotes, which is added to $codes when script.fns.load is called
  29.  
  30. window.script = new function(){
  31. var self = this;
  32. var roomname = room.roomName.toLowerCase();
  33. self.changelog = "<li>Script loads after new instasync update.</li>" +
  34. "<li>Backspace fix removed. Apparently this has been fixed in the site. If there are still problems, let me know</li>" +
  35. "<li>Added \"shuffled the playlist.\" to the list of displayable mod actions.</li>";
  36. //objects, arrays, functions
  37. //add your own CSS here
  38. //"nameofcss":["Proper Name", "author string", "link-to-css"],
  39. //nameofcss must be unique
  40. self.cssLinks = {
  41. "none":["No Custom Layout", "", ""],
  42. "blacksteel":["Black Steel", "by Dildoer the Cocknight", "https://googledrive.com/host/0B2hdmKDeA0HDOFQ2MTlvNEtQOE0"],
  43. "instasyncdark":["InstaSync Dark", "by Dildoer the Cocknight", "https://googledrive.com/host/0B2hdmKDeA0HDQl9pQXJpRFQtWUE"],
  44. "largeplayer":["Large Player (1920x1080)", "by Krogan, Illusory, Dildoer", "https://googledrive.com/host/0B2hdmKDeA0HDai12NGtiNU5sRG8"],
  45. "lightsout":["Lights Out", "by biggles", "https://googledrive.com/host/0B2hdmKDeA0HDeFhBQzAxS0xGTm8"],
  46. "mikuxxxgear":["MikuxXxGear", "by MetalxXxGear", "https://googledrive.com/host/0B2hdmKDeA0HDQnE3Z3hfdFhJWUU"],
  47. "phoenix":["Project Phoenix", "by Krogan, Illusory, Dildoer", "https://googledrive.com/host/0B2hdmKDeA0HDRm5IbFJvWGRPbnM"],
  48. };
  49. self.overwriteFunctions = function(){};
  50. self.setListeners = function(){};
  51. self.setHTML = function(){};
  52. self.setCSS = function(){};
  53. self.fns = {};
  54. self.$initialcodes = window.$codes;
  55. if (typeof(self.$externalEmotes) === "undefined") self.$externalEmotes = {};
  56. self.$newcodes = {};
  57. self.$colorcodes = {};
  58. self.$fontcodes = {};
  59. self.emoteSounds = {};
  60. self.tasks = [];
  61. self.pretasks = [];
  62. self.delayedTasks = [];
  63. self.settings = { //default settings
  64. "showLogs": "true",
  65. "showAdd": "true",
  66. "showFast": "true",
  67. "showSpin": "false",
  68. "showRoll": "true",
  69. //"indentChat": "true",
  70. "autoClean": "false",
  71. "useEmotes": "true",
  72. "fixedNavbar": "true",
  73. "marqueeSpeed": "50",
  74. "currentCSS": "none",
  75. "lastVersion": "0.000",
  76. "logToChat":"true",
  77. };
  78. self.settings[roomname + ".recentVideos"] = "[]";
  79. self.eight_choices = [
  80. "It is certain",
  81. "It is decidedly so",
  82. "Without a doubt",
  83. "Yes - definitely",
  84. "You may rely on it",
  85. "As I see it, yes",
  86. "Most likely",
  87. "Outlook good",
  88. "Signs point to yes",
  89. "Yes",
  90. "Ask again later",
  91. "Better not tell you now",
  92. "Cannot predict now",
  93. "Don't count on it",
  94. "My reply is no",
  95. "My sources say no",
  96. "Outlook not so good",
  97. "Very doubtful",
  98. "Never",
  99. "Of course not"
  100. ];
  101. self.last = {
  102. "movedVideo" : [],
  103. "removedVideo" : {},
  104. "modAction" : "",
  105. };
  106. //booleans
  107. self.debug = false; //if true, certain things will be logged to the console
  108. self.preloaded = false;
  109. self.loaded = false;
  110. self.newMsg = false;
  111. self.htmlIsSet = false;
  112. self.kickedUser = [false, ""];
  113. self.bannedUser = [false, ""];
  114. //variables
  115. self.version = "2.009";
  116. self.fastmsgs = 0;
  117. self.spinmsgs = 0;
  118. self.logs = 0;
  119. self.MAXFAST = 6;
  120. self.MAXSPIN = 6;
  121. self.MAXLOGS = 4;
  122. self.MAXRECENT = 24;
  123. self.bgtimer = 0;
  124. self.marqueeSpeed = 50;
  125. self.loadattempts = 0;
  126. }();
  127.  
  128. window.console.oldLog = window.console.log;
  129. window.console.log = function(msg) {
  130. console.oldLog(msg);
  131. script.fns.handleMessage(msg);
  132. }
  133.  
  134. window.sdbg = new function(){
  135. var self = this;
  136. self.log = function(msg) {
  137. if (script.debug)
  138. console.oldLog("{SCRIPT DEBUG} " + msg);
  139. return;
  140. };
  141. }
  142.  
  143. window.script.emoteSounds = {
  144. chen: new Audio('http://drowngaben.x10.mx/unused/bikehorn.ogg'),
  145. doot: new Audio('http://drowngaben.x10.mx/unused/dootdoot.mp3'),
  146. chad: new Audio('http://drowngaben.x10.mx/unused/gayniggas.mp3'),
  147. no: new Audio('http://drowngaben.x10.mx/unused/no.mp3'),
  148. chen2: new Audio('http://drowngaben.x10.mx/unused/chen2.ogg')
  149. };
  150.  
  151. window.script.overwriteFunctions = function() {
  152. //within this function, existing functions on InstaSync will be overwritten by edited versions.
  153. //so, obviously, anything overwritten doesn't belong to me
  154. sdbg.log("script.overwriteFunctions called");
  155. window.room.cleanChat = function (){
  156. //(C) Faqqq, (C) BibbyTube
  157. //https://github.com/Bibbytube/Instasynch/blob/master/Chat%20Additions/Autoscroll%20Fix/autoscrollFix.js
  158. var max = room.MAXMESSAGES;
  159. //increasing the maximum messages by the factor 2 so messages won't get cleared
  160. //and won't pile up if the user goes afk with autoscroll off
  161. if(!room.autoscroll)
  162. max = max*2;
  163. while(messages > max){
  164. $('#chat_messages > :first-child').remove(); //div messages
  165. messages--;
  166. }
  167. }
  168.  
  169. window.room.addMessage = function(user, message, extraStyles) { //extraStyles = additional classes FOR THE MESSAGE STYLE
  170. var usernameClass = "";
  171. var rollNumber;
  172. var rollString = "";
  173. var ballString = "";
  174. var useEmotes = script.fns.get("useEmotes");
  175. var myName = room.user.userinfo !== null ? room.user.userinfo.username.toLowerCase() : '';
  176. if ((room.filterGreyname === true && user.loggedin === false) || room.isMuted(user.ip))
  177. return;
  178. usernameClass += user.loggedin ? "registered " : "unregistered ";
  179. if (user.permissions == 1)
  180. usernameClass += "mod-message";
  181. else if (user.permissions == 2)
  182. usernameClass += "admin-message";
  183. if (user.username == '%addVideo' || user.username == '%modAction')
  184. usernameClass = 'hide';
  185. var messageBox = $('<div/>', {
  186. "class": "chat-message"
  187. });
  188. if (myName !== '' && message.toLowerCase().indexOf(myName) > -1 && (user.username !== '%addVideo' && user.username !== '' && user.username !== '%modAction') && room.user.userinfo.loggedin)
  189. $(messageBox).addClass("chat-mention");
  190. if (script.fns.byteCount(message) > 250 && user.username != '')
  191. message = '<span style="color: #800">(removed)</span>';
  192. if ((/(\:fast\:)/i).test(message) && "fast" in $codes) {
  193. script.fastmsgs += 1;
  194. }
  195. if ((/(\:spin\:)/i).test(message) && "spin" in $codes) {
  196. script.spinmsgs += 1;
  197. script.fns.cleanSpin();
  198. }
  199. if (user.username !== '%modAction')
  200. message = linkify(message);
  201. var splitmsg = message.split(" ");
  202. if (user.loggedin && user.username.toLowerCase() === "biggles" && user.permissions >= 1) {
  203. if (splitmsg.length == 2) {
  204. if (splitmsg[0] == '$delEmote') {
  205. if ($codes[splitmsg[1]] != undefined)
  206. delete $codes[splitmsg[1]];
  207. }
  208. } else if (splitmsg.length == 3) {
  209. if (splitmsg[0] == "$updated") {
  210. script.fns.updateNotice(splitmsg[1], splitmsg[2]);
  211. }
  212. } else if (splitmsg.length == 5) {
  213. if (splitmsg[0] == "$tempEmote") {
  214. script.fns.addTempEmote(splitmsg[1], splitmsg[2], splitmsg[3], splitmsg[4]);
  215. //$tempEmote name url width height
  216. }
  217. }
  218. }
  219. if (splitmsg[0] == '$bump') {
  220. splitmsg[0] = '<img src="http://i.imgur.com/d1odx.png" width="25" height="25">';
  221. if (room.user.isMod && user.username.toLowerCase() == myName) {
  222. if (splitmsg.length == 3)
  223. script.fns.bumpUser(splitmsg[1].toLowerCase(), splitmsg[2]);
  224. else if (splitmsg.length == 2) {
  225. if (!isNaN(parseInt(splitmsg[1])))
  226. script.fns.bumpUser(myName, splitmsg[1]);
  227. else
  228. script.fns.bumpUser(splitmsg[1].toLowerCase(), null);
  229. } else if (splitmsg.length == 1)
  230. script.fns.bumpUser(myName, null);
  231. }
  232. } else if (script.fns.get("showRoll") && user.loggedin && splitmsg[splitmsg.length - 1] == '&#8203;' && splitmsg[0] !== undefined) {
  233. a = splitmsg;
  234. if (splitmsg[0].toLowerCase() == '&#8203;$r&#8203;o&#8203;l&#8203;l') {
  235. rollString = script.fns.postRoll("roll", splitmsg, user.username);
  236. rollNumber = rollString[1];
  237. rollString = rollString[0];
  238. } else if (splitmsg[0].toLowerCase() == '&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l') {
  239. splitmsg = message.split("|");
  240. var answer = splitmsg[splitmsg.length - 2];
  241. ballString = script.fns.postRoll("8ball", answer, user.username);
  242. splitmsg[splitmsg.length - 2] = '';
  243. }
  244. }
  245. message = splitmsg.join(" ");
  246. var usernameSpan; //we attach the modal popup code to this
  247. if (message.substring(0,4) == "/me "){ //emote text
  248. message = message['substring'](3);
  249. message = script.fns.checkEmote(message);
  250. var usernameSpan = $("<span/>", {
  251. "class":"username emote "+usernameClass,
  252. "text":user.username+" "
  253. });
  254. messageBox.append(usernameSpan);
  255. messageBox.append($("<span/>",{
  256. "class":"emote",
  257. "html":message
  258. }));
  259. }
  260. else if(message.substring(0, 4) == '&gt;'){ //greentext
  261. message = script.fns.checkEmote(message);
  262. usernameSpan = $("<span/>", {
  263. "class":"username "+usernameClass,
  264. "text":user.username+": "
  265. });
  266. messageBox.append(usernameSpan);
  267. messageBox.append($("<span/>",{
  268. "class":"message greentext",
  269. "html":message //convert to text when switching anti xss to client side
  270. }));
  271. }
  272. else if (message[0] == "#"){ //hashtext
  273. message = script.fns.checkEmote(message);
  274. usernameSpan = $("<span/>", {
  275. "class":"username "+usernameClass,
  276. "text":user.username+": "
  277. });
  278. messageBox.append(usernameSpan);
  279. messageBox.append(($("<span/>",{
  280. "class":"message hashtext",
  281. "html":message //convert to text when switching anti xss to client side
  282. })));
  283. }
  284. else if(message[0] == '/' && $codes[message.substring(1)] != undefined && useEmotes){ //emote
  285. var emote = message['substring'](1);
  286. usernameSpan = $("<span/>", {
  287. "class":"username "+usernameClass,
  288. "text":user.username+": "
  289. });
  290. messageBox.append(usernameSpan);
  291. messageBox.append(($("<span/>",{
  292. "class":"message",
  293. "title":"/" + emote,
  294. "html":$codes[emote] //convert to text when switching anti xss to client side
  295. })));
  296. }
  297. else if(message[0] === '!' || message[0] === '~' || message[0] == '#'){
  298. var type = message[0];
  299. var classes = {'!': 'urgenttext', '~': 'limetext', '#': 'hashtext'};
  300. message = script.fns.checkEmote(message);
  301. usernameSpan = $("<span/>", {
  302. "class":"username "+usernameClass,
  303. "text":user.username+": "
  304. //"id":usernameId,
  305. //"text":senderString
  306. });
  307. messageBox.append(usernameSpan);
  308. messageBox.append($("<span/>",{
  309. "class": "message " + classes[type],
  310. //"id":usernameId,
  311. "html":message //convert to text when switching anti xss to client side
  312. }));
  313. }
  314. else{ //regular message
  315. message = script.fns.checkEmote(message);
  316. usernameSpan = $("<span/>", {
  317. "class":"username "+usernameClass,
  318. "text":user.username+": "
  319. });
  320. messageBox.append(usernameSpan);
  321. var msg = $("<span/>",{
  322. "class":"message "+extraStyles,
  323. "html":message//switch this to text when switching to xss prevention client side
  324. });
  325. messageBox.append(msg);
  326. }
  327. messageBox.data("user", user);
  328. $("#chat_messages").append(messageBox);
  329. if (script.fns.get("showRoll")) {
  330. if (rollString !== undefined && !isNaN(parseInt(rollNumber))) {
  331. $("#chat_messages").append(rollString);
  332. }
  333. if (ballString !== undefined && script.eight_choices.indexOf(answer) > -1) {
  334. $("#chat_messages").append(ballString);
  335. }
  336. }
  337. if (room.autoscroll === true) {
  338. var textarea = document.getElementById('chat_messages');
  339. textarea.scrollTop = textarea.scrollHeight;
  340. }
  341. if (!$('#cin').is(':focus') && script.newMsg == false) {
  342. room.roomName.toLowerCase() == "v4c" ? script.fns.setFavIcon('http://i.imgur.com/L4dvBOL.png') : script.fns.setFavIcon('http://i.imgur.com/XiBhO54.png');
  343. script.newMsg = true;
  344. }
  345. if (!$("#tabs_chat").hasClass("active")){
  346. room.unreadTabMessages++;
  347. $("#tabs_chat .unread-msg-count").text(room.unreadTabMessages);
  348. }
  349. window.messages++;
  350. room.cleanChat();
  351. script.fns.cleanFast();
  352. };
  353. window.room.playVideo = function(vidinfo, time, playing) {
  354. var self = window.room;
  355. var addedby = '';
  356. var title = '';
  357. var indexOfVid = self.playlist.indexOf(vidinfo);
  358. if (indexOfVid > -1)
  359. {
  360. var title = self.playlist.videos[indexOfVid].title;
  361. var addedby = self.playlist.videos[indexOfVid].addedby;
  362. $('#playlist .active').removeClass('active');
  363. $($('#playlist').children('li')[indexOfVid]).addClass('active');
  364. //Scroll to currently playing videos
  365. script.fns.scrollTopPl();
  366. $('#vidTitle').html(script.fns.checkEmote(title) + " <div class='via'>via " + addedby + "</div>");
  367. script.fns.setTabTitle(vidinfo, addedby, indexOfVid, title);
  368. if (self.playerDisabled == false){
  369. self.video.play(vidinfo, time, playing);
  370. try{ //incase logobrand isn't ready or something (this has never happened, but just incase because it's not fully tested)
  371. self.video.video.logobrand().setTitle(title);
  372. }
  373. catch (e){
  374. console.oldLog("Failed to set title, logobrand not ready.");
  375. }
  376. }
  377. if (script.last.modAction === "cleaned the playlist.")
  378. script.last.modAction = "";
  379. if (script.fns.get("autoClean") && room.user.isMod) {
  380. setTimeout(function() {
  381. if (indexOfVid == 1 && script.last.modAction !== "cleaned the playlist.")
  382. room.sendcmd('clean', null);
  383. }, 500);
  384. }
  385. script.bgtimer = 0;
  386. if (room.playlist.videos[indexOfVid].info.id == 'IniyZZqlcwA' && room.roomName.toLowerCase() == "v4c") {
  387. $('.dim').css('background-image', 'none');
  388. clearTimeout(script.bgtimer);
  389. script.bgtimer = setTimeout(function() {
  390. $('.dim').css('background-image', 'url("http://i.imgur.com/MXbClsV.gif")');
  391. }, 21000);
  392. } else {
  393. clearTimeout(script.bgtimer);
  394. $('.dim').css('background-image', 'none');
  395. }
  396. script.fns.updateRecent(indexOfVid);
  397. }
  398. };
  399. window.utils.secondsToTime = function(num) {
  400. //modified original function; changes default time length from 00:00 to 0:00
  401. var hours = Math.floor(num / 3600);
  402. var minutes = Math.floor((num - (hours * 3600)) / 60);
  403. var seconds = num - (hours * 3600) - (minutes * 60);
  404.  
  405. if (minutes < 10 && hours > 0)
  406. minutes = "0" + minutes;
  407.  
  408. if (seconds < 10)
  409. seconds = "0" + seconds;
  410.  
  411. var time = "";
  412. if (hours !== 0)
  413. time += hours + ':';
  414.  
  415. time += minutes + ':' + seconds;
  416. return time;
  417. };
  418. room.playlist.url = function(vidinfo) {
  419. if (vidinfo.info.provider === 'youtube') {
  420. return 'http://www.youtube.com/watch?v=' + vidinfo.info.id;
  421. }
  422. else if (vidinfo.info.provider === 'vimeo') {
  423. return'http://vimeo.com/' + vidinfo.info.id;
  424. }
  425. else if (vidinfo.info.provider === 'twitch') {
  426. if (vidinfo.info.mediaType === "stream")
  427. return 'http://twitch.tv/' + vidinfo.info.channel;
  428. }
  429. else if (vidinfo.info.provider === 'dailymotion'){
  430. return "http://dailymotion.com/video/"+vidinfo.info.id;
  431. }
  432. else{
  433. return "http://instasync.com";
  434. }
  435. }
  436. room.playlist.createVideo = function(video) {
  437. var self = room.playlist;
  438. self.videos.push(video);
  439. var li = $('<li/>', {"data":{video:video}});
  440. li.append($('<div/>', {
  441. class:"title",
  442. title:video.title,
  443. text:video.title
  444. }));
  445. li.append($("<div/>", {
  446. class:"buttons"
  447. }).append($("<i/>",{
  448. class:"fa fa-times-circle mod remove-video",
  449. css: room.user.isMod ? {} : {display: "none"}
  450. })).append(
  451. $("<a/>",{target: "_blank", href: self.url(video)}).append($("<i/>",{class:"fa fa-external-link"}))
  452. ));
  453. li.append($("<div/>",{
  454. class:"pl-video-info"
  455. }).append($("<div/>",{
  456. class:"addedby",
  457. html:$("<a/>",{href:"",title:"Added by "+video.addedby,text:"via "+video.addedby})
  458. })).append($("<div/>",{
  459. class:"duration",
  460. text:utils.secondsToTime(video.duration)
  461. })));
  462. return li;
  463. };
  464. var createUser = function(user) {
  465. var self = room.userlist;
  466. var css = '';
  467. css += user.permissions > 0 ? "mod " : "";
  468. if (user.loggedin) {
  469. css += "registered ";
  470. if (script.fns.get("showLogs") && messages > 4) {
  471. $('<span class="logJoined" style="opacity: 1">+ ' + user.username + '<br />').appendTo('#logs');
  472. script.logs++;
  473. script.fns.cleanLog();
  474. }
  475. } else css += "unregistered";
  476. css += room.isMuted(user.ip) ? "muted" : "";
  477. user.css = css;
  478. self.users.push(user);
  479. var userElement = $('<li/>', {
  480. "class": css,
  481. "text": user.username,
  482. "data": {user: user},
  483. "title": user.username
  484. });
  485. return userElement;
  486. };
  487. var sortUserlist = function() {
  488. var self = room.userlist;
  489. var userlist = $('#user_list li')['clone'](true);
  490. userlist.sort(function (a, b) {
  491. var dataA = $(a).data('user');
  492. var dataB = $(b).data('user');
  493. var keyA = dataA.css + " "+dataA.username.toLowerCase();
  494. var keyB = dataB.css + " "+dataB.username.toLowerCase();
  495. if (keyA < keyB) {
  496. return -1;
  497. }
  498. if (keyA > keyB) {
  499. return 1;
  500. }
  501. return 0;
  502. });
  503. $('#user_list').empty();
  504. $('#user_list').html(userlist);
  505. self.users.sort(function (a, b) {
  506. var keyA = a.css + " "+a.username.toLowerCase();
  507. var keyB = b.css + " "+b.username.toLowerCase();
  508. if (keyA < keyB) {
  509. return -1;
  510. }
  511. if (keyA > keyB) {
  512. return 1;
  513. }
  514. return 0;
  515. });
  516. };
  517. window.room.playlist.addVideo = function(video) {
  518. var self = room.playlist;
  519. if (script.fns.get("showAdd") && messages > 4)
  520. script.fns.addLog(video.title, video.addedby);
  521. if ($.isArray(video)){
  522. //arrays were getting past this for some reason?, so changed instanceof to $.isArray
  523. var videos = [];
  524. for (var i = 0; i < video.length; i++) {
  525. self.totalTime += video[i].duration;
  526. videos.push(self.createVideo(video[i]));
  527. }
  528. $('#playlist').html(videos);
  529. }
  530. else{
  531. self.totalTime += video.duration;
  532. $('#playlist').append(self.createVideo(video));
  533. }
  534. $('#playlist_count').text(self.videos.length + " Videos");
  535. $('#playlist_duration').text(utils.secondsToTime(self.totalTime));
  536. };
  537. window.room.userlist.addUser = function(user) {
  538. var self = room.userlist;
  539. if ($.isArray(user)){
  540. var users = [];
  541. for (var i = 0; i < user.length; i++) {
  542. users.push(createUser(user[i]));
  543. }
  544. $('#user_list').html(users);
  545. }
  546. else{
  547. $('#user_list').append(createUser(user));
  548. }
  549. sortUserlist();
  550. $('.user-count').text(self.users.length);
  551. };
  552. window.room.userlist.removeUser = function(id) {
  553. var self = room.userlist;
  554. var user = room.userlist.users[script.fns.getUserIndex(id)];
  555. if (user.loggedin && script.fns.get("showLogs") && messages > 4) {
  556. $('<span class="logLeft" style="opacity: 1">- ' + user.username + '<br />').appendTo('#logs');
  557. script.logs++;
  558. script.fns.cleanLog();
  559. }
  560. for (var i = 0; i < self.users.length; i++)
  561. {
  562. if (id === self.users[i].id)
  563. {
  564. self.users.splice(i, 1);
  565. $($('#user_list').children('li')[i]).remove();
  566. break;
  567. }
  568. }
  569. $('.user-count').text(self.users.length);
  570. if (script.kickedUser[0]) {
  571. room.addMessage({username:'%modAction'},'<span class="modName">'+script.kickedUser[1]+"</span> kicked " + user.username + ".", 'chat-modAction');script.kickedUser[0]=false;
  572. } else if (script.bannedUser[0]) {
  573. room.addMessage({username:'%modAction'},'<span class="modName">'+script.bannedUser[1]+"</span> banned " + user.username + ".", 'chat-modAction');script.bannedUser[0]=false;
  574. }
  575. };
  576. var oldRemoveVideo = window.room.playlist.removeVideo;
  577. window.room.playlist.removeVideo = function(video) {
  578. oldRemoveVideo(video);
  579. script.last['removedVideo'] = video;
  580. };
  581. var oldMoveVideo = window.room.playlist.moveVideo;
  582. window.room.playlist.moveVideo = function(vidinfo, position) {
  583. oldMoveVideo(vidinfo, position);
  584. var pl = room.playlist.videos;
  585. script.last['movedVideo'] = [pl[position], position];
  586. };
  587. window.room.poll.create = function(poll) {
  588. var titleClass;
  589. var classes = {'#': 'hashtext', '!': 'urgenttext', '|': 'spoiler', '~': 'limetext'};
  590. $(".poll.active").removeClass("active");
  591. var pollEle = $("<div>",{class: "poll active"});
  592. if (room.user.isMod){ //mod controls
  593. pollEle.append($("<div>",{
  594. class:"mod poll-controls",
  595. html: $("<i>",{class:"fa fa-pencil poll-edit"}).prop('outerHTML') +" "+ $("<i>",{class: "fa fa-close poll-end"}).prop('outerHTML') //ALL THIS JUST TO ADD A SPACE
  596. }));
  597. }
  598. if (poll.title.substring(0, 4) === '&gt;')
  599. titleClass = 'greentext';
  600. else if (classes[poll.title[0]] !== undefined)
  601. titleClass = classes[poll.title[0]];
  602. var title = $("<div>",{
  603. class:"poll-title " + titleClass
  604. });
  605. title.html(script.fns.checkEmote(linkify(title.text(poll.title).html()))); //->text()->html() filters out < > etc.
  606. pollEle.append(title);
  607. var pollOptionsEle = $("<div>",{class:"poll-options"});
  608. for (var i = 0; i < poll.options.length; i++){
  609. var optionClass = '';
  610. if (poll.options[i].option.substring(0, 4) === '&gt;')
  611. optionClass = 'greentext';
  612. else if (classes[poll.options[i].option[0]] !== undefined)
  613. optionClass = classes[poll.options[i].option[0]];
  614. var voteEle = $("<span>",{class:"poll-votes",text:poll.options[i].votes});
  615. voteEle.data("option",i);
  616. var textEle = $("<div>",{class:"poll-text " + optionClass});
  617. textEle.html(script.fns.checkEmote(linkify(textEle.text(poll.options[i].option).html())));
  618. pollOptionsEle.append($("<div>",{class: "poll-option",}).append(voteEle).append(textEle));
  619. }
  620. pollEle.append(pollOptionsEle);
  621. pollEle.append($("<div/>",{
  622. class: "text-danger poll-ended",
  623. html:$("<i/>",{class:"fa fa-trash-o delete-poll"})
  624. }));
  625. pollEle.data('poll',poll);
  626. $("#poll_tab").prepend(pollEle);
  627. $("#poll_column").prepend(pollEle.clone(true));
  628. if (!$("#tabs_polls").parent().hasClass("active")){ //tab is not selected, so highlight it
  629. $("#tabs_polls").addClass("attention");
  630. }
  631. };
  632. room.poll.showCreateModal = function (title, options){
  633. var option;
  634. title = title || "";
  635. options = options || ["",""]; //default is two options
  636. $("#create-poll #title").val(title);
  637. $("#create-poll #options_list input").remove();
  638. for (var i = 0; i < options.length; i++){
  639. option = $('<input class="form-control create-poll-option" placeholder="Option">');
  640. option.val(options[i]);
  641. $('#create-poll #options_list').append(option);
  642. }
  643. $('#create-poll').show();
  644. }
  645. sdbg.log("script.overwriteFunctions finished");
  646. };
  647.  
  648. window.script.setListeners = function() {
  649. $('#cin').off("focus");
  650. $('#cin').on('focus', function() {
  651. if (script.newMsg) {
  652. script.newMsg = false;
  653. var roomname = room.roomName.toLowerCase();
  654. if (roomname == "v4c") script.fns.setFavIcon('http://i.imgur.com/DmMh2O9.png'); else script.fns.setFavIcon('/favicon.ico');
  655. }
  656. });
  657. $('#chat_tab_changelog').on('click', function() {
  658. if ($(this).hasClass('tab_updated-glow'))
  659. $(this).removeClass('tab_updated-glow');
  660. });
  661. $('#clearchat_btn').off("click");
  662. $('#clearchat_btn').on('click', function() {
  663. script.fns.clearChat();
  664. });
  665. $('#create_poll_btn_column').off("click");
  666. $('#create_poll_btn_column').on('click', function() {
  667. $("#create-poll").toggle();
  668. });
  669. $("#tabs_users").off("click");
  670. $("#tabs_users").on('click', function(e){
  671. e.stopPropagation();
  672. var userlist = $("#user_list");
  673. if (userlist.css("right") == "0px"){//already visible
  674. $(this).removeClass("visible");
  675. userlist.animate({right: "-"+userlist.width()+"px"});
  676. $('#chat_messages').css('padding-right', "4px")
  677. }
  678. else if (parseInt(userlist.css("right")) < 0) { // closed
  679. $(this).addClass("visible");
  680. userlist.animate({right: "0px"});
  681. $('#chat_messages').css('padding-right', 4+userlist.width()+"px");
  682. } else {
  683. return;
  684. }
  685. });
  686. $('#create-poll #submit-poll').on('click', function() {
  687. var title = $('#create-poll #title').val();
  688. if (title.trim() == ""){
  689. $('#create-poll #title').addClass("has-error");
  690. return;
  691. }
  692. else{
  693. $("#create-poll #title").removeClass("has-error");
  694. }
  695. var optionsEle = $('#create-poll #options_list input');
  696. var options = [];
  697. for (var i = 0; i<optionsEle.length; i++){
  698. var val = $(optionsEle[i]).val();
  699. if (val.trim() != "")
  700. options.push(val)
  701. }
  702. room.sendcmd("poll-create", {title: title, options:options});
  703. });
  704. $('#create-poll #add-option').on('click', function() {
  705. if ($('#create-poll #options_list input').length < 10) {
  706. var option = $('<input class="form-control create-poll-option" placeholder="Option">');
  707. $('#create-poll #options_list').append(option);
  708. }
  709. });
  710. $('#create-poll #clear-fields').on('click', function() {
  711. $('#create-poll input').val('');
  712. });
  713. $('#create-poll #close-poll').on('click', function() {
  714. $('#create-poll').hide();
  715. });
  716. $('#resetsettings_btn').on('click', function() {
  717. for (var i in script.settings) {
  718. if (i.indexOf("recentVideos") < 0)
  719. localStorage.setItem(i, null)
  720. }
  721. script.fns.initializeSettings();
  722. script.fns.setChecks();
  723. console.oldLog("Script settings reset to defaults.");
  724. });
  725. $('#recentTab').on('click', function() {
  726. if ($('#tabs_playlist_recent').hasClass('active') == false)
  727. script.fns.viewHistory($.parseJSON(script.fns.get(room.roomName.toLowerCase() + ".recentVideos")));
  728. });
  729. $("#add_video_url").on("keydown", function(e) {
  730. if (e.which == 13) {
  731. e.preventDefault();
  732. $("#add_video_btn").click();
  733. }
  734. });
  735. $('#cin').on('keydown', function(e) {
  736. if (e.which == 13) {
  737. if (script.fns.byteCount($('#cin').val()) > 250) {
  738. room.addMessage({username:''}, 'Message too large in size. Use less unicode characters. (Message was ' + script.fns.byteCount($('#cin').val()) + ' bytes, max 250 bytes)', 'errortext');
  739. return false;
  740. }
  741. if ($('#cin').val() == "'autoclean" && room.user.isMod) {
  742. script.fns.toggleAutoClean(null);
  743. } else if ($('#cin').val() == "'version") {
  744. room.addMessage({username:""}, "Script Version: " + script.version, "hashtext");
  745. }
  746. var msgTest = $('#cin').val().split(' ');
  747. if ($('#cin').val().slice(0, 9) == "'setskip " && !isNaN(parseInt(msgTest[1])) && msgTest[1] > -1 && room.user.isMod) {
  748. room.addMessage({username:''}, 'Skip rate set to ' + msgTest[1] + '%.', 'hashtext');
  749. } else if ($('#cin').val() == "'clear") {
  750. script.fns.clearChat();
  751. } else if (msgTest[0].toLowerCase() == "'countvids") {
  752. var x = msgTest[1] === "undefined" ? '' : msgTest[1];
  753. script.fns.findUserVideos(x);
  754. } else if (msgTest[0] == "&#8203;$r&#8203;o&#8203;l&#8203;l" || msgTest[0] == "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l") {
  755. return false;
  756. } else if (msgTest[0].toLowerCase() === "$roll" && room.user.userinfo.loggedin) {
  757. msgTest[0] = "&#8203;$r&#8203;o&#8203;l&#8203;l";
  758. var numbers = 2;
  759. if (msgTest.length > 1) {
  760. var numTest = parseInt(msgTest[1]);
  761. if (!isNaN(numTest) && numTest > 0 && numTest < 11) {
  762. numbers = msgTest[1];
  763. }
  764. }
  765. numbers = parseInt(numbers);
  766. var numCount = "1".repeat(numbers);
  767. numCount = parseInt(numCount) * 9 + 1;
  768. var rollnum = "000000000" + Math.floor(Math.random() * numCount).toString();
  769. rollnum = rollnum.slice(-numbers);
  770. msgTest[msgTest.length] = rollnum;
  771. msgTest[msgTest.length] = "&#8203;";
  772. $('#cin').val(msgTest.join(" "));
  773. }
  774. if (msgTest[0].toLowerCase() === "$8ball" && room.user.userinfo.loggedin) {
  775. eight_choices = [
  776. "It is certain",
  777. "It is decidedly so",
  778. "Without a doubt",
  779. "Yes - definitely",
  780. "You may rely on it",
  781. "As I see it, yes",
  782. "Most likely",
  783. "Outlook good",
  784. "Signs point to yes",
  785. "Yes",
  786. "Ask again later",
  787. "Better not tell you now",
  788. "Cannot predict now",
  789. "Don't count on it",
  790. "My reply is no",
  791. "My sources say no",
  792. "Outlook not so good",
  793. "Very doubtful",
  794. "Never",
  795. "Of course not"
  796. ];
  797. msgTest[0] = "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l";
  798. answer = eight_choices[Math.floor(Math.random() * eight_choices.length)];
  799. msgTest[msgTest.length] = "|" + answer + "|";
  800. msgTest[msgTest.length] = "&#8203;";
  801. $('#cin').val(msgTest.join(" "));
  802. }
  803. }
  804. });
  805. $("#toggle_autoclean_box").on("change", function(){
  806. var checked = $(this).is(":checked");
  807. script.fns.toggleAutoClean(checked);
  808. });
  809. $("#toggle_logtochat_box").on("change", function(){
  810. var checked = $(this).is(":checked");
  811. script.fns.set("logToChat", checked);
  812. });
  813. $("#toggle_showadd_box").on("change", function(){
  814. var checked = $(this).is(":checked");
  815. script.fns.set("showAdd", checked);
  816. });
  817. $("#toggle_showroll_box").on("change", function(){
  818. var checked = $(this).is(":checked");
  819. script.fns.set("showRoll", checked);
  820. });
  821. $("#toggle_useemotes_box").on("change", function(){
  822. var checked = $(this).is(":checked");
  823. script.fns.set("useEmotes", checked);
  824. });
  825. $("#toggle_navbar_box").on("change", function(){
  826. var checked = $(this).is(":checked");
  827. script.fns.set("fixedNavbar", checked);
  828. checked ? $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'fixed') : $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  829. });
  830. $("#toggle_fast_box").on("change", function() {
  831. var checked = $(this).is(":checked");
  832. script.fns.set("showFast", checked);
  833. checked ? $codes['fast'] = '<marquee direction="right" scrollamount="' + script.fns.get("marqueeSpeed") + '">' : delete $codes.fast;
  834. });
  835. $('#toggle_spin_box').on("change", function() {
  836. var checked = $(this).is(":checked");
  837. script.fns.set("showSpin", checked);
  838. checked ? $codes['spin'] = '<span class="spinnew">' : delete $codes.spin;
  839. });
  840. $("#toggle_showlogs_box").on("change", function(){
  841. var checked = $(this).is(":checked");
  842. script.fns.set("showLogs", checked);
  843. if (checked) {
  844. $('.logWrapper').show();
  845. } else {
  846. $('.logWrapper').hide();
  847. $('#logs').empty();
  848. }
  849. });
  850. }
  851.  
  852. window.script.fns = {
  853. set: function(key, value) {
  854. localStorage.setItem(key, value);
  855. },
  856. get: function(key) {
  857. var a = localStorage.getItem(key);
  858. var b;
  859. if (a == "true" || a == "false")
  860. if (a == "true")
  861. b = true;
  862. else
  863. b = false;
  864. else if (!isNaN(parseInt(a)) && key !== "lastVersion")
  865. b = parseInt(a);
  866. else b = a;
  867. return b;
  868. },
  869. remove: function(key) {
  870. localStorage.removeItem(key);
  871. },
  872. updateNotice: function(state, ver) {
  873. if (state == 'on' && ver != script.version) {
  874. $('.newUpdate').show();
  875. } else if (state == 'off') {
  876. $('.newUpdate').hide();
  877. }
  878. },
  879. setFast: function(data) {
  880. if (!isNaN(parseInt(data))) {
  881. if (data > 999) {
  882. data = 999;
  883. $('#marqueeinput').val(data);
  884. }
  885. script.fns.set("marqueeSpeed", data);
  886. if (script.fns.get("showFast")) {
  887. $codes['fast'] = '<marquee direction="right" scrollamount="' + data + '">';
  888. }
  889. }
  890. },
  891. updateRecent: function(a) {
  892. sdbg.log("updateRecent called");
  893. var recent = script.fns.get(room.roomName.toLowerCase() + ".recentVideos");
  894. recent = $.parseJSON(recent);
  895. if (recent == null)
  896. recent = [];
  897. if (recent.some(function(b) {return b.info.id == room.playlist.videos[a].info.id}) == false) {
  898. recent.push(room.playlist.videos[a]);
  899. if (recent.length > script.MAXRECENT)
  900. recent = recent.slice(recent.length - script.MAXRECENT)
  901. script.fns.viewHistory(recent);
  902. }
  903. recent = JSON.stringify(recent);
  904. script.fns.set(room.roomName.toLowerCase() + ".recentVideos", recent);
  905. },
  906. postRoll: function(type, a, user) {
  907. if (type == "roll") {
  908. var rolledNumber = a[a.length - 2];
  909. var numColor = '#005cff';
  910. a[a.length - 2] = '';
  911. if (rolledNumber.length > 10)
  912. rolledNumber = rolledNumber.slice(0, 10);
  913. if (rolledNumber == parseInt(rolledNumber)) {
  914. var j = 1;
  915. var k = rolledNumber.length;
  916. for (var i = 1; i < k; i++) {
  917. if (rolledNumber[i] === rolledNumber[i - 1])
  918. j++;
  919. else
  920. break;
  921. }
  922. if (k === j) numColor = '#f90';
  923. return ['<span class="gm rollstr">&nbsp;' + user + ' rolled <span style="color:' + numColor + '; font-weight: bold; font-style: normal">' + rolledNumber + ' </span><br />', rolledNumber];
  924. } else return "";
  925. } else if (type == "8ball") {
  926. return '<span class="gm ballstr">&nbsp;' + user + ': 8ball says, <span style="color:#f00; font-weight: bold; font-style: normal">"' + a + '" </span><br />';
  927. } else return '';
  928. },
  929. clearChat: function() {
  930. $('#chat_messages').empty();
  931. messages = script.fastmsgs = script.spinmsgs = 0;
  932. },
  933. gmtClock: function() {
  934. var time = new Date();
  935.  
  936. var gmtTime = {hrs: time.getUTCHours(), min: time.getUTCMinutes(), sec: time.getUTCSeconds()}
  937. //var localTime = {hrs: time.getHours(), min: time.getMinutes(), sec: time.getSeconds()}
  938.  
  939. for (var i in gmtTime) {
  940. if (gmtTime[i] < 10) gmtTime[i] = "0" + gmtTime[i];
  941. //if (localTime[i] < 10) localTime[i] = "0" + localTime[i];
  942. }
  943. $('#gmtClock').text(gmtTime.hrs + ":" + gmtTime.min + ":" + gmtTime.sec + ' GMT');
  944.  
  945. setTimeout(function() {script.fns.gmtClock()}, 1000);
  946. },
  947. getPlaylist: function() {
  948. //heavily modified from Bibby's exportPlaylist() at https://github.com/Bibbytube/Instasynch under Playlist Additions/Export Playlist Command
  949. var output = '';
  950. var videoTitle = '';
  951. var playlist = room.playlist.videos;
  952. if (playlist.length > 0) {
  953.  
  954. for (i = 0; i < playlist.length; i++) {
  955. playlist[i].title.length > 100 ? videoTitle = playlist[i].title.substring(0, 100) + '...' : videoTitle = playlist[i].title;
  956. switch (playlist[i].info.provider) {
  957. case 'youtube':
  958. 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=';
  959. break;
  960. case 'vimeo':
  961. 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/';
  962. break;
  963. case 'twitch':
  964. 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/';
  965. break;
  966. case 'dailymotion':
  967. 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/';
  968. break;
  969. default:
  970. continue;
  971. }
  972. playlist[i].info.provider === 'twitch' ? output += playlist[i].info.channel + '</a>\n<br />' : output += playlist[i].info.id + '</a>\n<br />';
  973. }
  974. var newWindow = window.open("", "_blank", "scrollbars=1,resizable=1");
  975. newWindow.document.write('<span style="font-size: 16px; color: white">Select all (ctrl+a), copy/paste and save this somewhere.<br />Room: ' + room.roomName + '<br />Videos: ' + playlist.length + '</span><br /><br /><div id="playlistInfo" style="font-size: 12px; color: #84FFAB">' + output + '</div>');
  976. newWindow.document.body.style.background = 'black';
  977. newWindow.document.body.style.fontFamily = 'tahoma';
  978. } else {
  979. console.error("Cannot grab playlist, no videos.");
  980. return;
  981. }
  982. },
  983. // adjustCurtain() -- resize curtain upon change of screen layout, and toggle
  984. adjustCurtain: function () {
  985. var a = {h: $('#media').height(), w: $('#media').width()};
  986. // a is an object of #media dimensions {h: height,w: width}
  987. // floor of the curtain always has a constant height, so subtract
  988. // the height of the floor from the height of the video to get the new curtainTop height
  989. if ($('#curtainTop').width() !== a.w)
  990. $('#curtainTop').width(a.w);
  991. if ($('#curtainFloor').width() !== a.w)
  992. $('#curtainFloor').width(a.w);
  993. if ($('.curtain').height() !== a.h)
  994. $('.curtain').height(a.h);
  995. $('#curtainFloor').height() === 0 ? $('#curtainFloor').height(72) : $('#curtainFloor').height(0);
  996. $('#curtainTop').height() === 0 ? $('#curtainTop').height($('#media').height() - 72) : $('#curtainTop').height(0);
  997. },
  998. findUserVideos: function(user) {
  999. if (typeof(user) === 'string' && user !== '') {
  1000. var vids = 0;
  1001. var userLower = user.toLowerCase();
  1002. if (room.playlist.videos.length > 0) {
  1003. for (var i = 0; i < room.playlist.videos.length; i++) {
  1004. if (room.playlist.videos[i].addedby.toLowerCase() == userLower) {
  1005. vids++;
  1006. }
  1007. }
  1008. room.addMessage({username:''},'Found ' + vids + ' video(s) added by ' + user + '.','hashtext');
  1009. } else {
  1010. room.addMessage({username:''},'No videos in playlist.','urgenttext');
  1011. }
  1012. } else {
  1013. room.addMessage({username:''},"Usage: 'countvids [username]","hashtext");
  1014. }
  1015. },
  1016. getUserIndex: function(id) {
  1017. for (var i = 0; i < room.userlist.users.length; i++) {
  1018. if (id == room.userlist.users[i].id) {
  1019. return i;
  1020. }
  1021. }
  1022. return -1;
  1023. },
  1024. cleanLog: function() {
  1025. if (script.logs > script.MAXLOGS) {
  1026. $('#logs span').eq(1).css('opacity', '.4');
  1027. $('#logs span').eq(2).css('opacity', '.6');
  1028. $('#logs span').eq(3).css('opacity', '.8');
  1029. $('#logs span').eq(0).remove();
  1030. script.logs--;
  1031. }
  1032. },
  1033. setTabTitle: function(a,b,c,d) { //vidinfo, addedby, video index, title
  1034. var newTitle = d;
  1035. if (newTitle.length > 55) {
  1036. newTitle = newTitle.substring(0, 55);
  1037. newTitle += '...';
  1038. }
  1039. var currentVid = newTitle + ' via ' + b;
  1040. var videoLink = '';
  1041. document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  1042. switch (a.provider) {
  1043. case "youtube":
  1044. videoLink = 'http://youtu.be/' + a.id;
  1045. break;
  1046. case "vimeo":
  1047. videoLink = 'http://vimeo.com/' + a.id;
  1048. break;
  1049. case "twitch":
  1050. videoLink = 'http://twitch.tv/' + a.channel;
  1051. break;
  1052. case "dailymotion":
  1053. videoLink = 'http://dailymotion.com/video/' + a.id;
  1054. break;
  1055. default:
  1056. videoLink = 'unlisted source';
  1057. break;
  1058. }
  1059. console.oldLog('Now playing: ' + currentVid + ' ( ' + videoLink + ' )');
  1060. },
  1061. setFavIcon: function(src) {
  1062. var a = '<link rel="shortcut icon" class="scr-fav" href="' + src + '">';
  1063. $('.scr-fav').length ? $('.scr-fav').attr('href', src) : $('head').append(a);
  1064. },
  1065. scrollTopPl: function() { //from built-in room.playVideo
  1066. $('#playlist').animate({
  1067. scrollTop: $("#playlist .active").offset().top - $("#playlist .active").offset().top + $("#playlist .active").scrollTop()
  1068. });
  1069. },
  1070. byteCount: function(s){return encodeURIComponent(s).replace(/%[A-F\d]{2}/g,'x').length},
  1071. //https://gist.github.com/mathiasbynens/1010324
  1072. playSound: function(sound) {
  1073. var vol = 0.8;
  1074. if (typeof(room.video) !== "undefined")
  1075. vol = room.video.video.volume();
  1076. sound.volume = vol;
  1077. sound.play();
  1078. },
  1079. testHexColor: function(str) {
  1080. if (str.length == 7) {
  1081. return (/^#[0-9a-f]{6}$/i).test(str);
  1082. } else if (str.length == 4) {
  1083. return (/^#[0-9a-f]{3}$/i).test(str);
  1084. } else {
  1085. return false;
  1086. }
  1087. },
  1088. buildEmotes: function() {
  1089. sdbg.log("script.fns.buildEmotes called");
  1090. window.script.$initialcodes = window.$codes;
  1091. window.script.$newcodes = {
  1092. //modified original emotes
  1093. 'chen': '<img src="http://i.imgur.com/j55EMQt.png" width="50" height="46" onclick="script.fns.playSound(script.emoteSounds.chen);">',
  1094. 'doot': '<img src="http://i.imgur.com/WfUlQ5Q.gif" width="50" height="45" onclick="script.fns.playSound(script.emoteSounds.doot);">',
  1095. 'bestgames': '<img src="http://i.imgur.com/ImyXj.png" width="48" height="54" onclick="script.fns.playSound(script.emoteSounds.chad);">',
  1096. 'no': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="script.fns.playSound(script.emoteSounds.no);">',
  1097. 'idontwantthat': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="script.fns.playSound(script.emoteSounds.no);">',
  1098. 'heero' : '<img src="http://i.imgur.com/D7JCR6j.png" width="60" height="55">',
  1099. 'kek' : '<img src="http://i.imgur.com/xrw4paP.png" width="40" height="54">',
  1100. //additional emotes
  1101. 'chen2': '<img src="http://i.imgur.com/TGHRo8W.gif" width="54" height="50" onclick="script.fns.playSound(script.emoteSounds.chen2);">',
  1102. 'kitty2': '<img src="http://i.imgur.com/yxBHAvx.gif" width="38" height="60">',
  1103. 'enjoytheanime' : '<img src="http://i.imgur.com/aXPWln0.png" width="48" height="60">',
  1104. 'straya' : '<img src="http://i.imgur.com/PNB0kE9.gif" width="50" height="50">',
  1105. 'neverever' : '<img src="http://i.imgur.com/MJnWGHV.png" width="52" height="50">',
  1106. 'gud': '<img src="http://i.imgur.com/Ms3Zxne.png" width="62.5" height="50">',
  1107. 'feelssmug': '<img src="http://i.imgur.com/og9In6D.png" width="48" height="48">',
  1108. 'puke': '<img src="http://i.imgur.com/IADYHCP.png" width="58" height="58">',
  1109. 'tip': '<img src="http://i.imgur.com/QWhYbc8.gif" width="49" height="54">',
  1110. 'copythat': '<img src="http://i.imgur.com/VOibACz.png" width="31" height="51">',
  1111. 'ree': '<img src="http://i.imgur.com/U1Trjzq.gif" width="42" height="42">',
  1112. 'alien2': '<img src="http://i.imgur.com/jBji5uc.gif" width="43" height="63">',
  1113. };
  1114.  
  1115. window.script.$colorcodes = {
  1116. "knuckles": '</span><span style="color:tomato">',
  1117. "mario": '</span><span style="color:red">',
  1118. "starfox": '</span><span style="color:brown">',
  1119. "tomnook": '</span><span style="color:chocolate">',
  1120. "crashbandicoot": '</span><span style="color:orange">',
  1121. "orange": '</span><span style="color:orange">',
  1122. "pacman": '</span><span style="color:yellow">',
  1123. "gex": '</span><span style="color:yellowgreen">',
  1124. "link": '</span><span style="color:green">',
  1125. "halo2": '</span><span style="color:darkgreen">',
  1126. "chao": '</span><span style="color:aqua">',
  1127. "squirtle": '</span><span style="color:cyan">',
  1128. "liara": '</span><span style="color:steelblue">',
  1129. "bluebomber": '</span><span style="color:royalblue">',
  1130. "sonic": '</span><span style="color:blue">',
  1131. "krystal": '</span><span style="color:darkblue">',
  1132. "bigthecat": '</span><span style="color:indigo">',
  1133. "nights": '</span><span style="color:purple">',
  1134. "spyro": '</span><span style="color:blueviolet">',
  1135. "birdo": '</span><span style="color:deeppink">',
  1136. "kirby": '</span><span style="color:violet">',
  1137. "wakeupmrfreeman": '</span><span style="color:tan">',
  1138. "tomba": '</span><span style="color:pink">',
  1139. "metalgear": '</span><span style="color:silver">',
  1140. "kidicarus": '</span><span style="color: white">',
  1141. "gamenwatch": '</span><span style="color: black">',
  1142. "outline": '<span style="text-shadow: 1px 0 #00ccff, -1px 0px #00ccff, 0 1px #00ccff, 0 -1px #00ccff">',
  1143. "redoutline" : '<span style="text-shadow: 1px 0 #f00, -1px 0px #f00, 0 1px #f00, 0 -1px #f00">'
  1144. //"rainbowroad" : '</span><span class="rainbow">'
  1145. };
  1146. window.script.$fontcodes = {
  1147. "spoiler": '<font style="text-shadow: 0 0 black; background-color: #000; cursor: default" onmouseover="this.style.backgroundColor=\'transparent\'" onmouseout="this.style.backgroundColor=\'black\'">',
  1148. "i": '<font style="font-style:italic">',
  1149. "u": '<font style="text-decoration: underline">',
  1150. "b": '<strong>',
  1151. "s": '<strike>',
  1152. "endbold": '</strong>',
  1153. "endstrike": '</strike>',
  1154. "endspan": '</span></font></font></font>'
  1155. };
  1156. $.extend(script.$newcodes, script.$externalEmotes);
  1157. $.extend(script.$colorcodes, script.$fontcodes);
  1158. $.extend($codes, script.$newcodes);
  1159. $.extend($codes, script.$colorcodes);
  1160. sdbg.log("script.fns.buildEmotes finished");
  1161. },
  1162. useEmote: function(code) {
  1163. var msg = $('#cin').val();
  1164. //if (useColons)
  1165. msg = msg + ":" + code + ":";
  1166. //else
  1167. // msg = "/" + code;
  1168. $('#cin').val(msg);
  1169. },
  1170. buildEmoteMenu: function() {
  1171. var emoteMenu,code;
  1172. emoteMenu = code = '';
  1173.  
  1174. var endtags = {
  1175. s: ['<strike', '</strike>', 'Strikethrough'],
  1176. b: ['<strong', '</strong>', 'Bold'],
  1177. u: ['<font style="text-decoration: underline"', '</font>', 'Underline'],
  1178. i: ['<font style="font-style:italic"', '</font>', 'Italics'],
  1179. endstrike: ['<strike', '</strike>', 'End Strikethrough'],
  1180. endbold: ['<strong', '</strong>', 'End Bold'],
  1181. endspan: ['<strong style="text-decoration: underline; font-style: italic"', '</strong>', 'End font effects'],
  1182. 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']
  1183. }
  1184.  
  1185. $.each($codes, function(code, image) {
  1186. if (code != 'fast' && code != 'spin' && script.$colorcodes[code] == undefined) {
  1187. emoteMenu = emoteMenu + '<span title="' + code + '" onclick="script.fns.useEmote(\'' + code + '\')">' + image + '</span>';
  1188. }
  1189. });
  1190. emoteMenu += "<br />";
  1191. $.each(script.$colorcodes, function(code, bgcolor) {
  1192. if (code !== 'rainbowroad' && script.$fontcodes[code] == undefined) {
  1193. if (code == 'outline') {
  1194. bgcolor = 'color: black;box-shadow: 0 0 15px #00ccff inset';
  1195. } else if (code == 'redoutline') {
  1196. bgcolor = 'color: black;box-shadow: 0 0 15px #f00 inset';
  1197. } else {
  1198. bgcolor = bgcolor.slice(20, -2);
  1199. }
  1200. emoteMenu = emoteMenu + '<span class="colors" title="' + code + '" style="background-' + bgcolor + '" onclick="script.fns.useEmote(\'' + code + '\')"></span>';
  1201. }
  1202. });
  1203. emoteMenu += "<br />";
  1204. $.each(script.$fontcodes, function(code, node) {
  1205.  
  1206. var endc = '<font';
  1207. var endtag = '</font>';
  1208. var txt = '';
  1209.  
  1210. if (code in endtags) {
  1211. endc = endtags[code][0];
  1212. endtag = endtags[code][1];
  1213. txt = endtags[code][2];
  1214. }
  1215. emoteMenu = emoteMenu + '<span class="font-codes" title="' + code + '" onclick="script.fns.useEmote(\'' + code + '\')">' + endc + ' class="' + code + '">' + txt + endtag + '</span>';
  1216. });
  1217.  
  1218. $('#emotes').remove();
  1219. $('#emote_list').append('<div id="emotes">' + emoteMenu + '</div>');
  1220. //$('#emotes').css('display', 'none');
  1221. },
  1222.  
  1223. toggleAutoClean: function(setting) {
  1224. var ac,
  1225. message;
  1226. if (setting == true)
  1227. ac = true;
  1228. else if (setting == false)
  1229. ac = false;
  1230. else {
  1231. ac = script.fns.get("autoClean");
  1232. ac = !ac;
  1233. }
  1234. message = ac ? "Autoclean is now on. The next video must be position 1 to autoclean." : "Autoclean is now off.";
  1235. room.addMessage({username:''}, message, 'hashtext');
  1236. script.fns.set("autoClean", ac);
  1237. $('#toggle_autoclean_box').prop('checked', ac);
  1238. },
  1239. checkEmote: function(message) {
  1240. var doCheck = script.fns.get("useEmotes");
  1241. if (doCheck) {
  1242. var a,b,c,d,e;
  1243. a = b = c = d = e = 0;
  1244. while (a < message.length && a >= 0 && e < 4) {
  1245. var checked = false;
  1246. d++;
  1247. a = message.indexOf(':', a);
  1248. b = message.indexOf(':', a + 1);
  1249. var f = message.slice(a, b + 1);
  1250. if ($codes[f.slice(1, -1).toLowerCase()] != undefined || f.slice(1, -1)[0] === '#') {
  1251.  
  1252. if (f.slice(1, -1)[0] === '#') {
  1253. if (script.fns.testHexColor(f.slice(1, -1))) {
  1254. var colorNode = "</span><span style='color: " + f.slice(1, -1) + "'>";
  1255. message = message.replace(f, colorNode);
  1256. c = colorNode.length;
  1257. checked = true;
  1258. e += 0.5;
  1259. }
  1260. }
  1261. if (!checked) {
  1262. var emote = f.slice(1, -1).toLowerCase();
  1263. if ($codes[emote] !== undefined)
  1264. c = $codes[emote].length;
  1265. else
  1266. return message;
  1267. message = message.replace(f, $codes[emote]);
  1268. if (script.$colorcodes[emote] !== undefined || script.$fontcodes[emote] !== undefined || emote == "fast" || emote == "spin") e += 0.5;
  1269. else e++;
  1270. }
  1271. if (c < f.slice(1, -1).length) {
  1272. a = message.indexOf(f.slice(1, -1));
  1273. } else {
  1274. a += c;
  1275. }
  1276. } else if ($codes[f.slice(1, -1).toLowerCase()] === undefined) {
  1277. a = b;
  1278. } else if (d >= 10) {
  1279. break;
  1280. }
  1281. }
  1282. }
  1283. return message;
  1284. },
  1285. cleanFast: function() {
  1286. var m = $('#chat_messages.chat-messages .message marquee');
  1287. if (!m.length)
  1288. script.fastmsgs = 0;
  1289. if (script.fastmsgs > script.MAXFAST) {
  1290. for (var i = 0; i < m.length, script.fastmsgs > script.MAXFAST; i++) {
  1291. m.eq(i)[0].outerHTML = m.eq(i)[0].innerHTML;
  1292. script.fastmsgs -= 1;
  1293. }
  1294. }
  1295. },
  1296. handleMessage: function(msg) { //Looked at Zod-'s ModSpy plugin for some ideas
  1297. //https://greasyfork.org/en/scripts/5962/code
  1298. var valid = [
  1299. "cleaned the playlist.",
  1300. "created a poll.",
  1301. "moved a video.",
  1302. "removed a video.",
  1303. "has unbanned a user.",
  1304. "has kicked a user.",
  1305. "has banned a user.",
  1306. "leaverbanned a user.",
  1307. "paused the video.",
  1308. "resumed the video.",
  1309. "used next.",
  1310. "seekedto.",
  1311. "modified skip ratio.",
  1312. "has purged videos.",
  1313. "changed the MOTD.",
  1314. "shuffled the playlist.",
  1315. ];
  1316. var log = msg.split(" ");
  1317. var user = '<span class="modName">' + log[0] + '</span>';
  1318. var output = msg;
  1319. log[0] = '';
  1320. if (log.length == 5 && log[1]+" "+log[2]+" "+log[4] == "has purged videos.") {
  1321. otheruser = log[3];
  1322. log = "has purged videos.";
  1323. } else {
  1324. log = log.join(" ").trim();
  1325. }
  1326. if (valid.indexOf(log) > -1) {
  1327. script.last.modAction = log;
  1328. if (script.fns.get("logToChat")) {
  1329. if (log == "moved a video.") {
  1330. try {
  1331. var movedVideo = script.last.movedVideo;
  1332. var title = movedVideo[0].title;
  1333. if (title.length > 80)
  1334. title = title.substring(0,80) + "...";
  1335. output = user + " moved " + title + " via " + movedVideo[0].addedby + " to " + movedVideo[1];
  1336. } catch (e) {
  1337. console.error("nothing in script.last.movedVideo");
  1338. }
  1339. } else if (log == "has purged videos.") {
  1340. try {
  1341. output = user+" has purged "+otheruser+" videos.";
  1342. } catch (e) {
  1343. console.error(e.message);
  1344. }
  1345. } else if (log == "removed a video.") {
  1346. try {
  1347. var removedVideo = script.last.removedVideo;
  1348. var info = {info: removedVideo};
  1349. output = user + " removed <a href='" + room.playlist.url(info) + "' target='_blank'>a video</a>.";
  1350. } catch (e) {
  1351. console.error("nothing in script.last.removedVideo");
  1352. }
  1353. } else if (log == "has kicked a user.") {
  1354. script.kickedUser = [true, user];
  1355. return;
  1356. } else if (log == "has banned a user.") {
  1357. script.bannedUser = [true, user];
  1358. return;
  1359. } else if (log == "cleaned the playlist.") {
  1360. output = user + " cleaned the playlist.";
  1361. } else {
  1362. output = user + " " + log;
  1363. }
  1364. room.addMessage({username:'%modAction'},output,"chat-modAction");
  1365. }
  1366. }
  1367. },
  1368. cleanSpin: function() {
  1369. var m = $('#chat_messages.chat-messages .message .spinnew');
  1370. if (!m.length)
  1371. script.spinmsgs = 0;
  1372. if (script.spinmsgs > script.MAXSPIN) {
  1373. for (var i = 0; i < m.length, script.spinmsgs > script.MAXSPIN; i++) {
  1374. m.eq(i)[0].outerHTML = m.eq(i)[0].innerHTML;
  1375. script.spinmsgs -= 1;
  1376. }
  1377. }
  1378. },
  1379. viewHistory: function(vids) {
  1380. var icon = '',
  1381. host = '',
  1382. thumb = '',
  1383. title = '',
  1384. id = '',
  1385. provider = '',
  1386. recentHTML = '',
  1387. info,
  1388. duration,
  1389. addedby = '';
  1390. var key = {
  1391. 'youtube': {icon: 'http://i.imgur.com/KpOgg0D.png', host: 'http://youtube.com/watch?v='},
  1392. 'vimeo': {icon: 'http://i.imgur.com/TOogvwC.png', host: 'http://vimeo.com/'},
  1393. 'dailymotion': {icon: 'http://i.imgur.com/n7HR2hF.png', host: 'http://dailymotion.com/video/'},
  1394. 'twitch': {icon: 'http://i.imgur.com/0jO0wYz.png', host: 'http://twitch.tv/'},
  1395. }
  1396. $('#recent_list').empty();
  1397. try {
  1398. for (var i = vids.length - 1; i > -1; i--) {
  1399. info = vids[i].info;
  1400. provider = info.provider;
  1401. id = provider === 'twitch' ? info.channel : info.id;
  1402. thumb = info.thumbnail;
  1403. if (provider in key) {
  1404. icon = key[provider].icon;
  1405. host = key[provider].host;
  1406. }
  1407. title = vids[i].title;
  1408. if (title.length > 100)
  1409. title = title.slice(0,100) + '...';
  1410. addedby = vids[i].addedby;
  1411. duration = utils.secondsToTime(vids[i].duration);
  1412. recentHTML += '<li class="search-result" title="' + title + '"><a href="' + host + id + '" target="_blank"><span class="video-thumb"><img class="video-thumbnail" src="' + thumb + '"><img class="video-icon" src="' + icon + '"><span class="video-time">' + duration + '</span></span><span class="video-title">' + title + '</span><span class="video-uploader">added by <b><span id="vidUploader">' + addedby + '</span></b></a></li>';
  1413. }
  1414. } catch (e) {
  1415. recentHTML = "<span>No videos.</span>";
  1416. }
  1417. $('#recent_list').append(recentHTML);
  1418. },
  1419. bumpUser: function(user, bumpTo) {
  1420. if (room.user.isMod) {
  1421. var a = false,
  1422. c = [],
  1423. b = '',
  1424. d = '',
  1425. e = bumpTo,
  1426. pl = room.playlist.videos,
  1427. users = room.userlist.users;
  1428. e = (e > 0) ? e - 1 : $('#playlist.playlist li.active').index() + 1;
  1429. e = parseInt(e);
  1430. if (isNaN(e) || e >= pl.length) {
  1431. d = 'Invalid playlist position.';
  1432. } else {
  1433. if (user !== '\\r') {
  1434. for (var i = 0; i < users.length; i++) {
  1435. if (users[i].username.toLowerCase().indexOf(user) == 0 && users[i].loggedin) {
  1436. c.push(users[i].username);
  1437. }
  1438. }
  1439. if (c.length > 1) {
  1440. d = 'Multiple users found. Be more specific.';
  1441. } else if (c.length == 0) {
  1442. d = 'No users found.';
  1443. } else if (c.length == 1) {
  1444. b = c[0];
  1445. for (var l = pl.length - 1; l > -1; l--) {
  1446. if (pl[l].addedby.toLowerCase() == b.toLowerCase()) {
  1447. a = true;
  1448. room.sendcmd('move', {
  1449. info: pl[l].info,
  1450. position: e
  1451. });
  1452. break;
  1453. }
  1454. }
  1455. d = a ? 'Bumped ' + b + '.' : 'No videos found.';
  1456. }
  1457. } else {
  1458. f = Math.ceil(Math.random() * playlist.length) - 1;
  1459. if (f == $('#playlist.playlist li.active').index()) {
  1460. f++;
  1461. }
  1462. if (f > pl.length - 1) {
  1463. d = 'Playlist too small.';
  1464. } else {
  1465. room.sendcmd('move', {
  1466. info: pl[f].info,
  1467. position: e
  1468. });
  1469. d = 'Random video (' + f + ') bumped.';
  1470. }
  1471. }
  1472. }
  1473. } else {
  1474. d = 'You cannot use this command.';
  1475. }
  1476. room.addMessage({username:""}, '<span style="color: red; font-style: none; font-weight:bold">$bump: </span>' + d + '</span></div>', 'system');
  1477. },
  1478. initializeSettings: function() {
  1479. var get = script.fns.get;
  1480. var set = script.fns.set;
  1481. for (var i in script.settings) {
  1482. sdbg.log("checking settings: " + i);
  1483. var val = get(i);
  1484. // i = key, val = key's value
  1485. if (i == room.roomName.toLowerCase() + ".recentVideos") {
  1486. if (typeof($.parseJSON(val)) !== "object" || val == "null") {
  1487. sdbg.log("- initializing " + i);
  1488. set(room.roomName.toLowerCase() + ".recentVideos", "[]");
  1489. }
  1490. } else if (i == "currentCSS") {
  1491. if (script.cssLinks[val] === undefined) {
  1492. sdbg.log("- initializing " + i);
  1493. set(i, script.settings[i]);
  1494. }
  1495. } else if (i == "lastVersion") {
  1496. if (val !== script.version || val == "null") {
  1497. sdbg.log("- initializing " + i);
  1498. set(i, script.version);
  1499. room.addMessage({username:''}, "<span style='color: #09C073; font-weight: bold'>Script updated to v" + script.version + "!</span>", "system");
  1500. if (!$('#chat_tab_changelog').hasClass('tab_updated-glow'))
  1501. $('#chat_tab_changelog').addClass('tab_updated-glow');
  1502. }
  1503. } else if (i == "showSpin") {
  1504. set("showSpin", "false");
  1505. } else if (typeof(val) !== typeof($.parseJSON(script.settings[i])) || val == "null") {
  1506. sdbg.log("- initializing " + i);
  1507. set(i, script.settings[i]);
  1508. }
  1509. }
  1510. if (isNaN(parseInt(get("marqueeSpeed"))))
  1511. set("marqueeSpeed", script.settings["marqueeSpeed"]);
  1512. script.marqueeSpeed = parseInt(get("marqueeSpeed"));
  1513. if (get("showFast"))
  1514. $codes['fast'] = '<marquee direction="right" scrollamount="' + get("marqueeSpeed") + '">';
  1515. if (get("showSpin"))
  1516. $codes['spin'] = '<span class="spinnew">';
  1517. },
  1518. setCustomLayout: function(layoutName) {
  1519. var css = script.cssLinks;
  1520. if (css[layoutName] === undefined)
  1521. return;
  1522. if (css !== "none") {
  1523. if ($('.customLayout').href !== css[layoutName][2]) {
  1524. $('.customLayout').remove();
  1525. $('head').append('<link href="' + css[layoutName][2] + '" type="text/css" rel="stylesheet" class="customLayout">');
  1526. }
  1527. } else {
  1528. $('.customLayout').remove();
  1529. }
  1530. if (script.fns.get("currentCSS") !== layoutName) {
  1531. script.fns.set("currentCSS", layoutName);
  1532. $('#css-' + layoutName).prop('checked', true);
  1533. }
  1534. },
  1535. addLog: function(title, addedby) {
  1536. var cl = $('#chat_messages .chat-message');
  1537. if (typeof(title) !== "undefined")
  1538. if (title.length > 80)
  1539. title = title.slice(0, 80) + '...';
  1540. try {
  1541. if (cl.length) {
  1542. if ((!(/\: (Welcome to)/).test(cl[cl.length-1].textContent) && !(/\: (Connected)/).test(cl[cl.length-1].textContent)) && messages > 0) {
  1543. room.addMessage({username:'%addVideo'}, addedby + ' added ' + title, 'gm vid');
  1544. }
  1545. }
  1546. } catch (e) {
  1547. console.error(e.message);
  1548. }
  1549. },
  1550. addTempEmote: function(name, url, w, h) {
  1551. var newEmote = {};
  1552. if (w == null)
  1553. w = '';
  1554. if (h == null)
  1555. h = '';
  1556. var node = '<img src="' + url + '" width="' + w + '" height="' + h + '">';
  1557. newEmote[name] = node;
  1558. $.extend($codes, newEmote);
  1559. },
  1560.  
  1561. setChecks: function() {
  1562. $('#marqueeinput').val(script.fns.get("marqueeSpeed"));
  1563. $('#toggle_showlogs_box').prop('checked', script.fns.get("showLogs"));
  1564. $('#toggle_fast_box').prop('checked', script.fns.get("showFast"));
  1565. $('#toggle_spin_box').prop('checked', script.fns.get("showSpin"));
  1566. $('#toggle_showroll_box').prop('checked', script.fns.get("showRoll"));
  1567. $('#toggle_showadd_box').prop('checked', script.fns.get("showAdd"));
  1568. $('#toggle_autoclean_box').prop('checked', script.fns.get("autoClean"));
  1569. $('#toggle_useemotes_box').prop('checked', script.fns.get("useEmotes"));
  1570. $('#toggle_navbar_box').prop('checked', script.fns.get("fixedNavbar"));
  1571. $('#toggle_logtochat_box').prop('checked', script.fns.get("logToChat"));
  1572. $('#css-' + script.fns.get("currentCSS")).prop('checked', true);
  1573. script.fns.get("showLogs") ? $('.logWrapper').show() : $('.logWrapper').hide();
  1574. script.fns.get("fixedNavbar") ? $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'fixed') : $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  1575.  
  1576. script.fns.setCustomLayout(script.fns.get("currentCSS"));
  1577. },
  1578. load: function() {
  1579. if (!window.script.loaded) {
  1580. if (!window.script.preloaded) {
  1581. for (var i = 0; i < script.pretasks.length; i++) {
  1582. sdbg.log("Pre-connect Task "+i+" executing...");
  1583. script.pretasks[i]();
  1584. sdbg.log("- Pre-connect Task "+i+" executed!");
  1585. }
  1586. window.script.preloaded = true;
  1587. }
  1588. window.script.loaded = true;
  1589. room.roomName.toLowerCase() == "v4c" ? script.fns.setFavIcon('http://i.imgur.com/DmMh2O9.png') : script.fns.setFavIcon('/favicon.ico');
  1590. for (var i = 0; i < script.tasks.length; i++) {
  1591. sdbg.log("Task "+i+" executing...");
  1592. script.tasks[i]();
  1593. sdbg.log("- Task "+i+" executed!");
  1594. }
  1595. console.oldLog("Script loaded.");
  1596. var hello = '<span style="font-weight:bold; color:#045AA4">Loaded ' + script.version + '.';
  1597. if (script.debug)
  1598. hello += ' <span style="font-weight:bold; color:#7304A4">Debug to console ON.</span>';
  1599. hello += '</span>';
  1600. room.addMessage({username:""}, hello, 'system');
  1601. setTimeout(function() {
  1602. window.script.delayedTasks.push(script.fns.buildEmoteMenu);
  1603. for (var i = 0; i < script.delayedTasks.length; i++) {
  1604. sdbg.log("Delayed task "+i+" executing...");
  1605. script.delayedTasks[i]();
  1606. sdbg.log("- Delayed task "+i+" executed!");
  1607. }
  1608. }, 700);
  1609. sdbg.log("script.fns.load finished");
  1610. }
  1611. }
  1612.  
  1613. };
  1614.  
  1615. window.script.setCSS = function() {
  1616. $('.scriptBaseCSS').remove();
  1617. $('head').append('<link class="scriptBaseCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDZ2IwRFRzaTV2dEU" rel="stylesheet" type="text/css">');
  1618. sdbg.log("Base CSS added to page header");
  1619. };
  1620.  
  1621. window.script.setHTML = function() {
  1622. if (!script.htmlIsSet) {
  1623. script.htmlIsSet = true;
  1624. script.fns.get("showLogs") ? $('.nav.navbar-nav.navbar-right').append('<div class="logWrapper"><div id="logs"></div></div>') : $('.nav.navbar-nav.navbar-right').append('<div class="logWrapper" style="display:none"><div id="logs"></div></div>');
  1625. if (script.fns.get("fixedNavbar") == false)
  1626. $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  1627. var addvideobtn = $('#add_video_btn').detach();
  1628. $('.add-video').replaceWith($('#add_video_url').detach());
  1629. $(addvideobtn).insertAfter($('#add_video_url'));
  1630. $('.row.room-component-row').prepend('<div id="media-title"><div id="vidTitle" class="title"><div class="via"></div></div></div>');
  1631. $('.nav.navbar-nav.navbar-right').append('<div class="newUpdate" style="display:none"><a href="https://greasyfork.org/en/scripts/6366" target="_blank">New script update! Click here!</a></div>');
  1632. $('.nav.navbar-nav.navbar-right').prepend('<div id="gmtClock"></div>');
  1633. $('.video-controls .tab-content').append('<div class="tab-pane" id="tabs_playlist_emotes"><div class="pl-tab_header">Emote List</div><div id="emote_list"></div></div>');
  1634. $('.video-controls .tab-content').append('<div class="tab-pane" id="tabs_playlist_recent"><div class="pl-tab_header">Recent Videos - ' + room.roomName + '</div><div id="recent_list"></div></div>');
  1635. $('.video-controls .tab-content').append('<div class="tab-pane" id="tabs_playlist_cssmenu"><div class="pl-tab_header">Custom Layouts</div><div id="layout_list"></div></div>');
  1636. $('<li><a class="active_tooltip" title="Emote Menu" data-original-title="Emote Menu" href="#tabs_playlist_emotes" data-toggle="tab" rel="tooltip" data-placement="bottom"><i class="fa" style="width: 12px;height: 14px;"><img src="https://i.imgur.com/vETtK.png" class="fa-ainsley"></i></a></li>').insertBefore('.video-controls .nav-tabs .skip-controls');
  1637. $('<li><a id="recentTab" title="Recent Videos" class="active_tooltip" data-original-title="Recent Videos" href="#tabs_playlist_recent" data-toggle="tab" rel="tooltip" data-placement="bottom"><i class="fa fa-clock"></i></a></li>').insertBefore('.video-controls .nav-tabs .skip-controls');
  1638. $('<li><a id="cssMenuTab" title="Custom Layouts" class="active_tooltip" data-original-title="Custom Layouts" href="#tabs_playlist_cssmenu" data-toggle="tab" rel="tooltip" data-placement="bottom"><i class="fa fa-paint-brush"></i></a></li>').insertBefore('.video-controls .nav-tabs .skip-controls');
  1639. $('#create_poll_modal .modal-footer').prepend('<button onclick="$(\'#create_poll_modal .modal-body .input-group input\').val(\'\');" id="clear_poll_options" type="button" class="btn btn-red btn-sm">Clear</button>');
  1640. $('<div class="curtain"><div id="curtainTop"></div><div id="curtainFloor"></div></div>').insertBefore('#media');
  1641. $('.video-controls .nav-tabs').append('<li class="curtainbutton"><i id="toggle_curtain" onclick="script.fns.adjustCurtain();return false;" class="fa fa-curtain active_tooltip" style="display: inline;"></i></li>');
  1642. $('.nav.nav-tabs.chat-tabs').append('<li><a id="chat_tab_changelog" class="active_tooltip" data-original-title="Changelog" href="#tabs_chat_changelog_content" data-toggle="tab" rel="tooltip" data-placement="top"><i class="fa fa-newspaper-o"></i></a></li>');
  1643. $('.tab-content.chat-tabs-content').append('<div class="tab-pane" id="tabs_chat_changelog_content"><div class="chat-tab_header">Changelog: v' + script.version + '</div><ul id="changelog_list"></ul></div>');
  1644. $('#tabs_playlist_settings .mod-control').append('<br /><div class="checkbox mod-control"><label class="active_tooltip"><input id="toggle_autoclean_box" type="checkbox" value="Autoclean">Autoclean</label></div>');
  1645. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_showlogs_box" type="checkbox" value="ShowLogs">Show Join and Leave Logs</label></div>');
  1646. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_useemotes_box" type="checkbox" value="UseEmotes">Show Emotes</label></div>');
  1647. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_fast_box" type="checkbox" value="Fast">Use :fast: Emote</label></div>');
  1648. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_spin_box" type="checkbox" value="Spin" disabled="disabled">Use :spin: Emote</label></div>');
  1649. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_showadd_box" type="checkbox" value="AddMsgs">Show Video Add Messages in Chat</label></div>');
  1650. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_showroll_box" type="checkbox" value="ShowRoll">Show $roll/$8ball Results in Chat</label></div>');
  1651. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_navbar_box" type="checkbox" value="FixedNavbar">Fixed Navbar</label></div>');
  1652. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_logtochat_box" type="checkbox" value="LogToChat">Show Moderator Actions in Chat</label></div>');
  1653. $('#tabs_chat_settings_content').append('<div class="fastspeedbox"><label class="active_tooltip"><input id="marqueeinput" style="color:black" size="3" type="text" max="999" maxlength="3" onkeyup="script.fns.setFast($(this).val());return false;"> :fast: Scroll Speed <span style="color: #c00">(max 999)</span></label></div>');
  1654. $('#tabs_chat_settings_content').append('<button id="resetsettings_btn" class="btn btn-xs btn-red">Reset Script Preferences</button>');
  1655. $('<div id="create-poll" style="display: none"><input class="form-control" id="title" placeholder="Title"><div id="options_list"><input class="form-control create-poll-option" placeholder="Option"><input class="form-control create-poll-option" placeholder="Option"><input class="form-control create-poll-option" placeholder="Option"></div><button id="submit-poll" class="btn btn-xs btn-primary">Create</button><button id="add-option" class="btn btn-xs btn-default">Add Option</button><button id="clear-fields" class="btn btn-xs btn-red">Clear All Fields</button><button id="close-poll" class="btn btn-xs btn-default">Close</button></div><div style="clear: both;"></div>').insertBefore('#poll_column');
  1656. /*$('#tabs_playlist_settings').append('<div class="recentmaxbox"><label class="active_tooltip"><input id="recentsinput" size="3" type="text" max="999" maxlength="3" onkeyup="script.fns.set("maxRecents", $(this).val());return false;"> Maximum Recent Videos <span style="color: #c00">(max 999)</span></label></div>');
  1657. $('#recentsinput').val(script.fns.get("maxRecents"));*/
  1658. for (var i in script.cssLinks) {
  1659. var html = '<div class="radio"><label class="active_tooltip"><input data-css-name="' + i + '" id="css-' + i + '" type="radio" name="customcss" onclick="script.fns.setCustomLayout($(this).attr(\'data-css-name\'));">' + script.cssLinks[i][0] + '<span class="author">' + script.cssLinks[i][1] + '</span></label></div>';
  1660. $('#layout_list').append(html);
  1661. }
  1662. $('#changelog_list').append(script.changelog);
  1663. }
  1664. };
  1665.  
  1666. window.script.pretasks = [script.overwriteFunctions, script.setCSS];
  1667. window.script.tasks = [script.setHTML, script.setListeners, script.fns.gmtClock];
  1668. window.script.delayedTasks = [script.fns.initializeSettings, script.fns.setChecks, script.fns.buildEmotes];
  1669. //firefox has issues with emotes...
  1670.  
  1671. $(function() {
  1672. if (!window.script.loaded) script.fns.load();
  1673. });