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-05-01 提交的版本。查看 最新版本

  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. // @require http://openuserjs.org/src/libs/TimidScript/TSL_-_jsColorGM.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/move.js/0.4.0/move.js
  11. // @version 2.013
  12. // @grant none
  13. // @author biggles
  14. // ==/UserScript==
  15.  
  16. //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).
  17.  
  18. /*
  19. <InstaSync - Watch Videos with friends.>
  20. Copyright (C) 2015 InstaSync
  21.  
  22. <InstaSync modified client code>
  23. Copyright (C) 2015 biggles
  24. */
  25.  
  26. window.messages = 0;
  27. String.prototype.repeat = function(num) {
  28. return new Array(num + 1).join(this);
  29. };
  30.  
  31. //for emote script creators, put this at the end: script.delayedTasks.push(name_of_emote_function);
  32. //script.delayedTasks is a list of functions (sans arguments) executed 700ms after everything else
  33. //or add all emotes to script.$externalEmotes, which is added to $codes when script.fns.load is called
  34.  
  35. window.script = new function(){
  36. var self = this;
  37. var roomname = room.roomName.toLowerCase();
  38. self.changelog ="<li>Added new JS library: move.js, used for animations.</li>" +
  39. "<li>Added a feature that allows chat messages to scroll across the video, similar to Nico Nico Douga. This, along with emotes in said messages, can be toggled on or off <span style='color: lime; background-color: black'>in the chat settings tab</span>.</li>" +
  40. "<li>Added CSS: 'Old.Instasync' created by 'fuckballs' of bibby.</li>" +
  41. "<li>Changed clock's timezone string from \"GMT\" to \"UTC\".</li>" +
  42. "<li>Added experimental Default Quality feature.</li>" +
  43. "<li>Some more small internal changes.</li>";
  44.  
  45. //objects, arrays, functions
  46. //add your own CSS here
  47. //"nameofcss":["Proper Name", "author string", "link-to-css"],
  48. //nameofcss must be unique
  49. self.cssLinks = {
  50. "none":["No Custom Layout", "", ""],
  51. "blacksteel":["Black Steel", "by Dildoer the Cocknight", "https://googledrive.com/host/0B2hdmKDeA0HDOFQ2MTlvNEtQOE0"],
  52. "instasyncdark":["InstaSync Dark", "by Dildoer the Cocknight", "https://googledrive.com/host/0B2hdmKDeA0HDQl9pQXJpRFQtWUE"],
  53. "largeplayer":["Large Player (1920x1080)", "by Krogan, Illusory, Dildoer", "https://googledrive.com/host/0B2hdmKDeA0HDai12NGtiNU5sRG8"],
  54. "largeplayerdark":["Large Player (Dark Chat)", "by Krogan, Illusory, Dildoer", "https://googledrive.com/host/0B2hdmKDeA0HDRlNNbDFWR3phRms"],
  55. "lightsout":["Lights Out", "by biggles", "https://googledrive.com/host/0B2hdmKDeA0HDeFhBQzAxS0xGTm8"],
  56. "lightsout2":["Lights Out Darker", "by biggles", "https://googledrive.com/host/0B2hdmKDeA0HDSW5YcG9SVEVDcGc"],
  57. "mikuxxxgear":["MikuxXxGear", "by MetalxXxGear", "https://googledrive.com/host/0B2hdmKDeA0HDQnE3Z3hfdFhJWUU"],
  58. "old.instasync":["Old.Instasync", "by fuckballs", "https://googledrive.com/host/0B2hdmKDeA0HDeUFUS2xmOGsxX0E"],
  59. "oldsynch":["Oldsynch", "by itscake and Krogan", "https://googledrive.com/host/0B2hdmKDeA0HDclpEX1ZfWVNvWkU"],
  60. "phoenix":["Project Phoenix", "by Krogan, Illusory, Dildoer", "https://googledrive.com/host/0B2hdmKDeA0HDRm5IbFJvWGRPbnM"],
  61. };
  62. self.overwriteFunctions = function(){};
  63. self.setListeners = function(){};
  64. self.setHTML = function(){};
  65. self.setCSS = function(){};
  66. self.fns = {};
  67. self.$initialcodes = window.$codes;
  68. if (typeof(self.$externalEmotes) === "undefined") self.$externalEmotes = {};
  69. self.$newcodes = {};
  70. self.$colorcodes = {};
  71. self.$fontcodes = {};
  72. self.emoteSounds = {};
  73. self.tasks = [];
  74. self.pretasks = [];
  75. self.delayedTasks = [];
  76. self.colorSettings = { //for color pickers
  77. "pickerButtons": "CCCCCC",
  78. "pickerButtonsHoverGlow": "FFFFFF",
  79. "pickerHandles": "CCCCCC",
  80. "pickerHandlesGlow": "FFFFFF",
  81. "pickerProgress": "66A8CC",
  82. "pickerVolume": "66A8CC",
  83. "pickerText": "CCCCCC",
  84. "pickerControlBar": "07141E",
  85. "pickerControlBarOpacity": 70,
  86. };
  87. self.eight_choices = [
  88. "It is certain",
  89. "It is decidedly so",
  90. "Without a doubt",
  91. "Yes - definitely",
  92. "You may rely on it",
  93. "As I see it, yes",
  94. "Most likely",
  95. "Outlook good",
  96. "Signs point to yes",
  97. "Yes",
  98. "Ask again later",
  99. "Better not tell you now",
  100. "Cannot predict now",
  101. "Don't count on it",
  102. "My reply is no",
  103. "My sources say no",
  104. "Outlook not so good",
  105. "Very doubtful",
  106. "Never",
  107. "Of course not"
  108. ];
  109. self.validModActions = { //message: active?
  110. "cleaned the playlist.":true,
  111. "created a poll.":true,
  112. "ended a poll.":true,
  113. "moved a video.":true,
  114. "removed a video.":true,
  115. "has unbanned a user.":true,
  116. "has kicked a user.":true,
  117. "has banned a user.":true,
  118. "leaverbanned a user.":true,
  119. "paused the video.":true,
  120. "resumed the video.":true,
  121. "used next.":true,
  122. "seekedto.":true,
  123. "modified skip ratio.":true,
  124. "has purged videos.":true,
  125. "changed the MOTD.":true,
  126. "shuffled the playlist.":true,
  127. };
  128. self.settings = { //default settings
  129. "showVidChat": 0,
  130. "showVidEmotes": "true",
  131. "showLogs": "true",
  132. "showAdd": "true",
  133. "showFast": "true",
  134. "showSpin": "false",
  135. "showRoll": "true",
  136. "autoClean": "false",
  137. "useEmotes": "true",
  138. "fixedNavbar": "true",
  139. "marqueeSpeed": "50",
  140. "currentCSS": "none",
  141. "lastVersion": "0.000",
  142. "logToChat":"true",
  143. "defaultQuality":"large",
  144. "cssSettings":self.colorSettings,
  145. "validActions":self.validModActions,
  146. };
  147. self.qualities = {
  148. "hd2160":2160, //4k
  149. "hd1440":1440, //1440p
  150. "hd1080":1080, //1080p
  151. "hd720":720, //720p
  152. "large":480, //480p
  153. "medium":360, //360p
  154. "small":240, //240p
  155. "tiny":144, //144p
  156. "auto":0 //auto
  157. };
  158. self.settings[roomname + ".recentVideos"] = "[]";
  159. self.last = {
  160. "movedVideo" : [],
  161. "removedVideo" : {},
  162. "modAction" : "",
  163. };
  164. //booleans
  165. self.debug = false; //if true, certain things will be logged to the console
  166. self.preloaded = false;
  167. self.loaded = false;
  168. self.newMsg = false;
  169. self.htmlIsSet = false;
  170. self.bgtimer = false;
  171. self.kickedUser = [false, ""];
  172. self.bannedUser = [false, ""];
  173. //variables
  174. self.version = "2.013";
  175. self.fastmsgs = 0;
  176. self.spinmsgs = 0;
  177. self.logs = 0;
  178. self.MAXFAST = 6;
  179. self.MAXSPIN = 6;
  180. self.MAXLOGS = 4;
  181. self.MAXRECENT = 24;
  182. self.marqueeSpeed = 50;
  183. self.loadattempts = 0;
  184. self.bgTimeout = 0;
  185. }();
  186.  
  187. window.console.oldLog = window.console.log;
  188. window.console.log = function(msg) {
  189. console.oldLog(msg);
  190. script.fns.handleMessage(msg);
  191. }
  192.  
  193. window.sdbg = new function(){
  194. var self = this;
  195. self.log = function(msg) {
  196. if (script.debug)
  197. console.oldLog("▌SCRIPT DEBUG▐ " + msg);
  198. return;
  199. };
  200. }
  201.  
  202. window.script.emoteSounds = {
  203. chen: new Audio('http://drowngaben.x10.mx/unused/bikehorn.ogg'),
  204. doot: new Audio('http://drowngaben.x10.mx/unused/dootdoot.mp3'),
  205. chad: new Audio('http://drowngaben.x10.mx/unused/gayniggas.mp3'),
  206. no: new Audio('http://drowngaben.x10.mx/unused/no.mp3'),
  207. chen2: new Audio('http://drowngaben.x10.mx/unused/chen2.ogg')
  208. };
  209.  
  210. window.script.overwriteFunctions = function() {
  211. //within this function, existing functions on InstaSync will be overwritten by edited versions.
  212. //so, obviously, anything overwritten doesn't belong to me
  213. sdbg.log("script.overwriteFunctions called");
  214. window.room.cleanChat = function (){
  215. //(C) Faqqq, (C) BibbyTube
  216. //https://github.com/Bibbytube/Instasynch/blob/master/Chat%20Additions/Autoscroll%20Fix/autoscrollFix.js
  217. var max = room.MAXMESSAGES;
  218. //increasing the maximum messages by the factor 2 so messages won't get cleared
  219. //and won't pile up if the user goes afk with autoscroll off
  220. if(!room.autoscroll)
  221. max = max*2;
  222. while(messages > max){
  223. $('#chat_messages > :first-child').remove(); //div messages
  224. messages--;
  225. }
  226. }
  227.  
  228. window.room.addMessage = function(user, message, extraStyles) { //extraStyles = additional classes FOR THE MESSAGE STYLE
  229. var usernameClass = "";
  230. var rollNumber;
  231. var rollString = "";
  232. var ballString = "";
  233. var rawMessage = message.trim();
  234. var useEmotes = script.fns.get("useEmotes");
  235. var vcState = script.fns.get("showVidChat");
  236. var vceIsEnabled = false;
  237. var vcClass = '';
  238. if (vcState !== 0)
  239. vceIsEnabled = script.fns.get("showVidEmotes");
  240. var myName = room.user.userinfo !== null ? room.user.userinfo.username.toLowerCase() : '';
  241. if ((room.filterGreyname === true && user.loggedin === false) || room.isMuted(user.ip))
  242. return;
  243. usernameClass += user.loggedin ? "registered " : "unregistered ";
  244. if (user.permissions == 1)
  245. usernameClass += "mod-message";
  246. else if (user.permissions == 2)
  247. usernameClass += "admin-message";
  248. if (user.username == '%addVideo' || user.username == '%modAction')
  249. usernameClass = 'hide';
  250. var messageBox = $('<div/>', {
  251. "class": "chat-message"
  252. });
  253. if (myName !== '' && message.toLowerCase().indexOf(myName) > -1 && (user.username !== '%addVideo' && user.username !== '' && user.username !== '%modAction') && room.user.userinfo.loggedin)
  254. $(messageBox).addClass("chat-mention");
  255. if (script.fns.byteCount(message) > 250 && user.username != '') {
  256. message = '<span style="color: #800">(removed)</span>';
  257. rawMessage = '';
  258. }
  259. if ((/(\:fast\:)/i).test(message) && "fast" in $codes) {
  260. script.fastmsgs += 1;
  261. vcState = 0;
  262. }
  263. if ((/(\:spin\:)/i).test(message) && "spin" in $codes) {
  264. script.spinmsgs += 1;
  265. script.fns.cleanSpin();
  266. vcState = 0;
  267. }
  268. if (user.username !== '%modAction')
  269. message = linkify(message);
  270. var splitmsg = message.split(" ");
  271. if (user.loggedin && user.username.toLowerCase() === "biggles" && user.permissions >= 1) {
  272. if (splitmsg.length == 2) {
  273. if (splitmsg[0] == '$delEmote') {
  274. if ($codes[splitmsg[1]] != undefined)
  275. delete $codes[splitmsg[1]];
  276. }
  277. } else if (splitmsg.length == 3) {
  278. if (splitmsg[0] == "$updated") {
  279. script.fns.updateNotice(splitmsg[1], splitmsg[2]);
  280. }
  281. } else if (splitmsg.length == 5) {
  282. if (splitmsg[0] == "$tempEmote") {
  283. script.fns.addTempEmote(splitmsg[1], splitmsg[2], splitmsg[3], splitmsg[4]);
  284. //$tempEmote name url width height
  285. }
  286. }
  287. }
  288. if (splitmsg[0] == '$bump') {
  289. splitmsg[0] = '<img src="http://i.imgur.com/d1odx.png" width="25" height="25">';
  290. if (room.user.isMod && user.username.toLowerCase() == myName) {
  291. if (splitmsg.length == 3)
  292. script.fns.bumpUser(splitmsg[1].toLowerCase(), splitmsg[2]);
  293. else if (splitmsg.length == 2) {
  294. if (!isNaN(parseInt(splitmsg[1])))
  295. script.fns.bumpUser(myName, splitmsg[1]);
  296. else
  297. script.fns.bumpUser(splitmsg[1].toLowerCase(), null);
  298. } else if (splitmsg.length == 1)
  299. script.fns.bumpUser(myName, null);
  300. }
  301. } else if (script.fns.get("showRoll") && user.loggedin && splitmsg[splitmsg.length - 1] == '&#8203;' && splitmsg[0] !== undefined) {
  302. a = splitmsg;
  303. if (splitmsg[0].toLowerCase() == '&#8203;$r&#8203;o&#8203;l&#8203;l') {
  304. rollString = script.fns.postRoll("roll", splitmsg, user.username);
  305. rollNumber = rollString[1];
  306. rollString = rollString[0];
  307. } else if (splitmsg[0].toLowerCase() == '&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l') {
  308. splitmsg = message.split("|");
  309. var answer = splitmsg[splitmsg.length - 2];
  310. ballString = script.fns.postRoll("8ball", answer, user.username);
  311. splitmsg[splitmsg.length - 2] = '';
  312. }
  313. }
  314. message = splitmsg.join(" ");
  315. var usernameSpan; //we attach the modal popup code to this
  316. if (message.substring(0,4) == "/me "){ //emote texte
  317. vcState = 0;
  318. message = message['substring'](3);
  319. message = script.fns.checkEmote(message, false);
  320. var usernameSpan = $("<span/>", {
  321. "class":"username emote "+usernameClass,
  322. "text":user.username+" "
  323. });
  324. messageBox.append(usernameSpan);
  325. messageBox.append($("<span/>",{
  326. "class":"emote",
  327. "html":message
  328. }));
  329. }
  330. else if(message[0] == '/' && $codes[message.substring(1)] != undefined && useEmotes){ //emote
  331. var emote = message['substring'](1);
  332. if (vceIsEnabled)
  333. rawMessage = $codes[emote];
  334. usernameSpan = $("<span/>", {
  335. "class":"username "+usernameClass,
  336. "text":user.username+": "
  337. });
  338. messageBox.append(usernameSpan);
  339. messageBox.append(($("<span/>",{
  340. "class":"message",
  341. "title":"/" + emote,
  342. "html":$codes[emote] //convert to text when switching anti xss to client side
  343. })));
  344. }
  345. else if(message[0] === '!' || message[0] === '~' || message[0] == '#' || message.substring(0,4) == '&gt;'){
  346. var type = '';
  347. if (message.substring(0,4) == '&gt;')
  348. type = '&gt;';
  349. else
  350. type = message[0];
  351. var classes = {'!': 'urgenttext', '~': 'limetext', '#': 'hashtext', '&gt;': 'greentext'};
  352. if (vcState == 1)
  353. vcClass = classes[type];
  354. message = script.fns.checkEmote(message, false);
  355. usernameSpan = $("<span/>", {
  356. "class":"username "+usernameClass,
  357. "text":user.username+": "
  358. //"id":usernameId,
  359. //"text":senderString
  360. });
  361. messageBox.append(usernameSpan);
  362. messageBox.append($("<span/>",{
  363. "class": "message " + classes[type],
  364. //"id":usernameId,
  365. "html":message //convert to text when switching anti xss to client side
  366. }));
  367. }
  368. else{ //regular message
  369. message = script.fns.checkEmote(message, false);
  370. usernameSpan = $("<span/>", {
  371. "class":"username "+usernameClass,
  372. "text":user.username+": "
  373. });
  374. messageBox.append(usernameSpan);
  375. var msg = $("<span/>",{
  376. "class":"message "+extraStyles,
  377. "html":message//switch this to text when switching to xss prevention client side
  378. });
  379. messageBox.append(msg);
  380. }
  381. messageBox.data("user", user);
  382. $("#chat_messages").append(messageBox);
  383. if (vcState !== 0 && user.loggedin && rawMessage.length > 0) {
  384. if (vcState === 1) {
  385. script.fns.addScrollingMessage(rawMessage, vcState, vcClass);
  386. }
  387. }
  388. if (script.fns.get("showRoll")) {
  389. if (rollString !== undefined && !isNaN(parseInt(rollNumber))) {
  390. $("#chat_messages").append(rollString);
  391. }
  392. if (ballString !== undefined && script.eight_choices.indexOf(answer) > -1) {
  393. $("#chat_messages").append(ballString);
  394. }
  395. }
  396. if (room.autoscroll === true) {
  397. var textarea = document.getElementById('chat_messages');
  398. textarea.scrollTop = textarea.scrollHeight;
  399. }
  400. if (!$('#cin').is(':focus') && script.newMsg == false) {
  401. room.roomName.toLowerCase() == "v4c" ? script.fns.setFavIcon('http://i.imgur.com/L4dvBOL.png') : script.fns.setFavIcon('http://i.imgur.com/XiBhO54.png');
  402. script.newMsg = true;
  403. }
  404. if (!$("#tabs_chat").hasClass("active")){
  405. room.unreadTabMessages++;
  406. $("#tabs_chat .unread-msg-count").text(room.unreadTabMessages);
  407. }
  408. window.messages++;
  409. room.cleanChat();
  410. script.fns.cleanFast();
  411. };
  412. window.room.playVideo = function(vidinfo, time, playing) {
  413. var self = window.room;
  414. var addedby = '';
  415. var title = '';
  416. var indexOfVid = self.playlist.indexOf(vidinfo);
  417. if (indexOfVid > -1)
  418. {
  419. var title = self.playlist.videos[indexOfVid].title;
  420. var addedby = self.playlist.videos[indexOfVid].addedby;
  421. $('#playlist .active').removeClass('active');
  422. $($('#playlist').children('li')[indexOfVid]).addClass('active');
  423. //Scroll to currently playing videos
  424. script.fns.scrollTopPl();
  425. $('#vidTitle').html(script.fns.checkEmote(title, false) + " <div class='via'>via " + addedby + "</div>");
  426. script.fns.setTabTitle(vidinfo, addedby, indexOfVid, title);
  427. if (self.playerDisabled == false){
  428. self.video.play(vidinfo, time, playing);
  429. try{ //incase logobrand isn't ready or something (this has never happened, but just incase because it's not fully tested)
  430. self.video.video.logobrand().setTitle(title);
  431. }
  432. catch (e){
  433. console.oldLog("Failed to set title, logobrand not ready.");
  434. }
  435. }
  436. if (script.last.modAction === "cleaned the playlist.")
  437. script.last.modAction = "";
  438. if (script.fns.get("autoClean") && room.user.isMod) {
  439. setTimeout(function() {
  440. if (indexOfVid == 1 && script.last.modAction !== "cleaned the playlist.")
  441. room.sendcmd('clean', null);
  442. }, 500);
  443. }
  444. script.bgtimer = false;
  445. $('.video-image-header').remove();
  446. clearTimeout(script.bgTimeout);
  447. script.bgTimeout = 0;
  448. if (room.roomName.toLowerCase() == "v4c") {
  449. if (room.playlist.videos[indexOfVid].info.id == 'IniyZZqlcwA') {
  450. script.bgtimer = true;
  451. script.fns.backgroundTimer(19.8, script.bgtimer, "http://i.imgur.com/mIjMpbR.gif");
  452. } else if (room.playlist.videos[indexOfVid].info.id == '1EKTw50Uf8M') {
  453. script.bgtimer = true;
  454. script.fns.backgroundTimer(19.4, script.bgtimer, "http://i.imgur.com/zz37ZFX.gif");
  455. }
  456. }
  457. script.fns.updateRecent(indexOfVid);
  458. var quality = script.fns.findNearestQuality(script.fns.get('defaultQuality'));
  459. if ($('.vjs-quality-button .vjs-menu ul li.vjs-selected').attr('data-val') !== quality)
  460. $('.vjs-quality-button .vjs-menu ul li[data-val="'+quality+'"]').click();
  461. }
  462. };
  463. window.utils.secondsToTime = function(num) {
  464. //modified original function; changes default time length from 00:00 to 0:00
  465. var hours = Math.floor(num / 3600);
  466. var minutes = Math.floor((num - (hours * 3600)) / 60);
  467. var seconds = num - (hours * 3600) - (minutes * 60);
  468.  
  469. if (minutes < 10 && hours > 0)
  470. minutes = "0" + minutes;
  471.  
  472. if (seconds < 10)
  473. seconds = "0" + seconds;
  474.  
  475. var time = "";
  476. if (hours !== 0)
  477. time += hours + ':';
  478.  
  479. time += minutes + ':' + seconds;
  480. return time;
  481. };
  482. room.playlist.url = function(vidinfo) {
  483. if (vidinfo.info.provider === 'youtube') {
  484. return 'http://www.youtube.com/watch?v=' + vidinfo.info.id;
  485. }
  486. else if (vidinfo.info.provider === 'vimeo') {
  487. return'http://vimeo.com/' + vidinfo.info.id;
  488. }
  489. else if (vidinfo.info.provider === 'twitch') {
  490. if (vidinfo.info.mediaType === "stream")
  491. return 'http://twitch.tv/' + vidinfo.info.channel;
  492. }
  493. else if (vidinfo.info.provider === 'dailymotion'){
  494. return "http://dailymotion.com/video/"+vidinfo.info.id;
  495. }
  496. else{
  497. return "http://instasync.com";
  498. }
  499. }
  500. room.playlist.createVideo = function(video) {
  501. var self = room.playlist;
  502. self.videos.push(video);
  503. var li = $('<li/>', {"data":{video:video}});
  504. li.append($('<div/>', {
  505. class:"title",
  506. title:video.title,
  507. text:video.title
  508. }));
  509. li.append($("<div/>", {
  510. class:"buttons"
  511. }).append($("<i/>",{
  512. class:"fa fa-times-circle mod remove-video",
  513. css: room.user.isMod ? {} : {display: "none"}
  514. })).append(
  515. $("<a/>",{target: "_blank", href: self.url(video)}).append($("<i/>",{class:"fa fa-external-link"}))
  516. ));
  517. li.append($("<div/>",{
  518. class:"pl-video-info"
  519. }).append($("<div/>",{
  520. class:"addedby",
  521. html:$("<a/>",{href:"",title:"Added by "+video.addedby,text:"via "+video.addedby})
  522. })).append($("<div/>",{
  523. class:"duration",
  524. text:utils.secondsToTime(video.duration)
  525. })));
  526. return li;
  527. };
  528. var createUser = function(user) {
  529. var self = room.userlist;
  530. var css = '';
  531. css += user.permissions > 0 ? "mod " : "";
  532. if (user.loggedin) {
  533. css += "registered ";
  534. if (script.fns.get("showLogs") && messages > 4) {
  535. $('<span class="logJoined" style="opacity: 1">+ ' + user.username + '<br />').appendTo('#logs');
  536. script.logs++;
  537. script.fns.cleanLog();
  538. }
  539. } else css += "unregistered";
  540. css += room.isMuted(user.ip) ? "muted" : "";
  541. user.css = css;
  542. self.users.push(user);
  543. var userElement = $('<li/>', {
  544. "class": css,
  545. "text": user.username,
  546. "data": {user: user},
  547. "title": user.username
  548. });
  549. return userElement;
  550. };
  551. var sortUserlist = function() {
  552. var self = room.userlist;
  553. var userlist = $('#user_list li')['clone'](true);
  554. userlist.sort(function (a, b) {
  555. var dataA = $(a).data('user');
  556. var dataB = $(b).data('user');
  557. var keyA = dataA.css + " "+dataA.username.toLowerCase();
  558. var keyB = dataB.css + " "+dataB.username.toLowerCase();
  559. if (keyA < keyB) {
  560. return -1;
  561. }
  562. if (keyA > keyB) {
  563. return 1;
  564. }
  565. return 0;
  566. });
  567. $('#user_list').empty();
  568. $('#user_list').html(userlist);
  569. self.users.sort(function (a, b) {
  570. var keyA = a.css + " "+a.username.toLowerCase();
  571. var keyB = b.css + " "+b.username.toLowerCase();
  572. if (keyA < keyB) {
  573. return -1;
  574. }
  575. if (keyA > keyB) {
  576. return 1;
  577. }
  578. return 0;
  579. });
  580. };
  581. window.room.playlist.addVideo = function(video) {
  582. var self = room.playlist;
  583. if (script.fns.get("showAdd") && messages > 4)
  584. script.fns.addLog(video.title, video.addedby);
  585. if ($.isArray(video)){
  586. //arrays were getting past this for some reason?, so changed instanceof to $.isArray
  587. var videos = [];
  588. for (var i = 0; i < video.length; i++) {
  589. self.totalTime += video[i].duration;
  590. videos.push(self.createVideo(video[i]));
  591. }
  592. $('#playlist').html(videos);
  593. }
  594. else{
  595. self.totalTime += video.duration;
  596. $('#playlist').append(self.createVideo(video));
  597. }
  598. $('#playlist_count').text(self.videos.length + " Videos");
  599. $('#playlist_duration').text(utils.secondsToTime(self.totalTime));
  600. };
  601. window.room.userlist.addUser = function(user) {
  602. var self = room.userlist;
  603. if ($.isArray(user)){
  604. var users = [];
  605. for (var i = 0; i < user.length; i++) {
  606. users.push(createUser(user[i]));
  607. }
  608. $('#user_list').html(users);
  609. }
  610. else{
  611. $('#user_list').append(createUser(user));
  612. }
  613. sortUserlist();
  614. $('.user-count').text(self.users.length);
  615. };
  616. window.room.userlist.removeUser = function(id) {
  617. var self = room.userlist;
  618. var user = room.userlist.users[script.fns.getUserIndex(id)];
  619. if (user.loggedin && script.fns.get("showLogs") && messages > 4) {
  620. $('<span class="logLeft" style="opacity: 1">- ' + user.username + '<br />').appendTo('#logs');
  621. script.logs++;
  622. script.fns.cleanLog();
  623. }
  624. for (var i = 0; i < self.users.length; i++)
  625. {
  626. if (id === self.users[i].id)
  627. {
  628. self.users.splice(i, 1);
  629. $($('#user_list').children('li')[i]).remove();
  630. break;
  631. }
  632. }
  633. $('.user-count').text(self.users.length);
  634. if (script.kickedUser[0]) {
  635. room.addMessage({username:'%modAction'},'<span class="modName">'+script.kickedUser[1]+"</span> kicked " + user.username + ".", 'chat-modAction');script.kickedUser[0]=false;
  636. } else if (script.bannedUser[0]) {
  637. room.addMessage({username:'%modAction'},'<span class="modName">'+script.bannedUser[1]+"</span> banned " + user.username + ".", 'chat-modAction');script.bannedUser[0]=false;
  638. }
  639. };
  640. var oldRemoveVideo = window.room.playlist.removeVideo;
  641. window.room.playlist.removeVideo = function(video) {
  642. oldRemoveVideo(video);
  643. script.last['removedVideo'] = video;
  644. };
  645. var oldMoveVideo = window.room.playlist.moveVideo;
  646. window.room.playlist.moveVideo = function(vidinfo, position) {
  647. oldMoveVideo(vidinfo, position);
  648. var pl = room.playlist.videos;
  649. script.last['movedVideo'] = [pl[position], position];
  650. };
  651. window.room.poll.create = function(poll) {
  652. var titleClass;
  653. var classes = {'#': 'hashtext', '!': 'urgenttext', '|': 'spoiler', '~': 'limetext'};
  654. $(".poll.active").removeClass("active");
  655. var pollEle = $("<div>",{class: "poll active"});
  656. if (room.user.isMod){ //mod controls
  657. pollEle.append($("<div>",{
  658. class:"mod poll-controls",
  659. 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
  660. }));
  661. }
  662. if (poll.title.substring(0, 4) === '&gt;')
  663. titleClass = 'greentext';
  664. else if (classes[poll.title[0]] !== undefined)
  665. titleClass = classes[poll.title[0]];
  666. var title = $("<div>",{
  667. class:"poll-title " + titleClass
  668. });
  669. title.html(script.fns.checkEmote(linkify(title.text(poll.title).html()), false)); //->text()->html() filters out < > etc.
  670. pollEle.append(title);
  671. var pollOptionsEle = $("<div>",{class:"poll-options"});
  672. for (var i = 0; i < poll.options.length; i++){
  673. var optionClass = '';
  674. if (poll.options[i].option.substring(0, 4) === '&gt;')
  675. optionClass = 'greentext';
  676. else if (classes[poll.options[i].option[0]] !== undefined)
  677. optionClass = classes[poll.options[i].option[0]];
  678. var voteEle = $("<span>",{class:"poll-votes",text:poll.options[i].votes});
  679. voteEle.data("option",i);
  680. var textEle = $("<div>",{class:"poll-text " + optionClass});
  681. textEle.html(script.fns.checkEmote(linkify(textEle.text(poll.options[i].option).html()), false));
  682. pollOptionsEle.append($("<div>",{class: "poll-option",}).append(voteEle).append(textEle));
  683. }
  684. pollEle.append(pollOptionsEle);
  685. pollEle.append($("<div/>",{
  686. class: "text-danger poll-ended",
  687. html:$("<i/>",{class:"fa fa-trash-o delete-poll"})
  688. }));
  689. pollEle.data('poll',poll);
  690. $("#poll_tab").prepend(pollEle);
  691. $("#poll_column").prepend(pollEle.clone(true));
  692. if (!$("#tabs_polls").parent().hasClass("active")){ //tab is not selected, so highlight it
  693. $("#tabs_polls").addClass("attention");
  694. }
  695. };
  696. room.poll.showCreateModal = function (title, options){
  697. var option;
  698. title = title || "";
  699. options = options || ["",""]; //default is two options
  700. $("#create-poll #title").val(title);
  701. $("#create-poll #options_list input").remove();
  702. for (var i = 0; i < options.length; i++){
  703. option = $('<input class="form-control create-poll-option" placeholder="Option">');
  704. option.val(options[i]);
  705. $('#create-poll #options_list').append(option);
  706. }
  707. $('#create-poll').show();
  708. }
  709. sdbg.log("script.overwriteFunctions finished");
  710. };
  711.  
  712. window.script.setListeners = function() {
  713. $('#cin').off("focus");
  714. $('#cin').on('focus', function() {
  715. if (script.newMsg) {
  716. script.newMsg = false;
  717. var roomname = room.roomName.toLowerCase();
  718. if (roomname == "v4c") script.fns.setFavIcon('http://i.imgur.com/DmMh2O9.png'); else script.fns.setFavIcon('/favicon.ico');
  719. }
  720. });
  721. $('#chat_tab_changelog').on('click', function() {
  722. if ($(this).hasClass('tab_updated-glow'))
  723. $(this).removeClass('tab_updated-glow');
  724. });
  725. $('#clearchat_btn').off("click");
  726. $('#clearchat_btn').on('click', function() {
  727. script.fns.clearChat();
  728. });
  729. $('#create_poll_btn_column').off("click");
  730. $('#create_poll_btn_column').on('click', function() {
  731. $("#create-poll").toggle();
  732. });
  733. $("#tabs_users").off("click");
  734. $("#tabs_users").on('click', function(e){
  735. e.stopPropagation();
  736. var userlist = $("#user_list");
  737. if (userlist.css("right") == "0px"){//already visible
  738. $(this).removeClass("visible");
  739. userlist.animate({right: "-"+userlist.width()+"px"});
  740. $('#chat_messages').css('padding-right', "4px")
  741. }
  742. else if (parseInt(userlist.css("right")) < 0) { // closed
  743. $(this).addClass("visible");
  744. userlist.animate({right: "0px"});
  745. $('#chat_messages').css('padding-right', 4+userlist.width()+"px");
  746. } else {
  747. return;
  748. }
  749. if (room.autoscroll === true) {
  750. var textarea = document.getElementById('chat_messages');
  751. textarea.scrollTop = textarea.scrollHeight;
  752. }
  753. });
  754. $('#create-poll #submit-poll').on('click', function() {
  755. var title = $('#create-poll #title').val();
  756. if (title.trim() == ""){
  757. $('#create-poll #title').addClass("has-error");
  758. return;
  759. }
  760. else{
  761. $("#create-poll #title").removeClass("has-error");
  762. }
  763. var optionsEle = $('#create-poll #options_list input');
  764. var options = [];
  765. for (var i = 0; i<optionsEle.length; i++){
  766. var val = $(optionsEle[i]).val();
  767. if (val.trim() != "")
  768. options.push(val)
  769. }
  770. room.sendcmd("poll-create", {title: title, options:options});
  771. });
  772. $('#create-poll #add-option').on('click', function() {
  773. if ($('#create-poll #options_list input').length < 10) {
  774. var option = $('<input class="form-control create-poll-option" placeholder="Option">');
  775. $('#create-poll #options_list').append(option);
  776. }
  777. });
  778. $('#create-poll #clear-fields').on('click', function() {
  779. $('#create-poll input').val('');
  780. });
  781. $('#create-poll #close-poll').on('click', function() {
  782. $('#create-poll').hide();
  783. });
  784. $('#resetsettings_btn').on('click', function() {
  785. for (var i in script.settings) {
  786. if (i.indexOf("recentVideos") < 0)
  787. localStorage.setItem(i, null)
  788. if (i.indexOf("cssSettings") < 0)
  789. localStorage.setItem(i, null)
  790. }
  791. script.fns.initializeSettings();
  792. script.fns.setChecks();
  793. console.oldLog("Script settings reset to defaults.");
  794. });
  795. $('#export_playlist').on('click', function() {
  796. script.fns.getPlaylist();
  797. });
  798. $('#resetcolor_btn').on('click', function() {
  799. script.fns.set("cssSettings", JSON.stringify(script.colorSettings));
  800. script.fns.initJSColor(true);
  801. console.oldLog("CSS colors reset to defaults.");
  802. });
  803. $('#recentTab').on('click', function() {
  804. if ($('#tabs_playlist_recent').hasClass('active') == false)
  805. script.fns.viewHistory($.parseJSON(script.fns.get(room.roomName.toLowerCase() + ".recentVideos")));
  806. });
  807. $("#add_video_url").on("keydown", function(e) {
  808. if (e.which == 13) {
  809. e.preventDefault();
  810. $("#add_video_btn").click();
  811. }
  812. });
  813. $('#cin').on('keyup', function(e) {
  814. script.fns.handleChatKeyup(e);
  815. });
  816.  
  817. $('#cin').on('keydown', function(e) {
  818. var chatArea = $('#cin');
  819. if (e.which == 13) {
  820. if (chatArea.hasClass('chatSpecial'))
  821. chatArea.removeClass('chatSpecial');
  822. if (script.fns.byteCount(chatArea.val()) > 250) {
  823. room.addMessage({username:''}, 'Message too large in size. Use less unicode characters. (Message was ' + script.fns.byteCount($('#cin').val()) + ' bytes, max 250 bytes)', 'errortext');
  824. return false;
  825. }
  826. if (chatArea.val() == "'autoclean" && room.user.isMod) {
  827. script.fns.toggleAutoClean(null);
  828. } else if (chatArea.val() == "'version") {
  829. room.addMessage({username:""}, "Script Version: " + script.version, "hashtext");
  830. }
  831. var msgTest = chatArea.val().split(' ');
  832. if (chatArea.val().slice(0, 9) == "'setskip " && !isNaN(parseInt(msgTest[1])) && msgTest[1] > -1 && room.user.isMod) {
  833. room.addMessage({username:''}, 'Skip rate set to ' + msgTest[1] + '%.', 'hashtext');
  834. } else if (chatArea.val() == "'clear") {
  835. script.fns.clearChat();
  836. } else if (msgTest[0].toLowerCase() == "'countvids") {
  837. var x = msgTest[1] === "undefined" ? '' : msgTest[1];
  838. script.fns.findUserVideos(x);
  839. } else if (msgTest[0] == "&#8203;$r&#8203;o&#8203;l&#8203;l" || msgTest[0] == "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l") {
  840. return false;
  841. } else if (msgTest[0].toLowerCase() === "$roll" && room.user.userinfo.loggedin) {
  842. msgTest[0] = "&#8203;$r&#8203;o&#8203;l&#8203;l";
  843. var numbers = 2;
  844. if (msgTest.length > 1) {
  845. var numTest = parseInt(msgTest[1]);
  846. if (!isNaN(numTest) && numTest > 0 && numTest < 11) {
  847. numbers = msgTest[1];
  848. }
  849. }
  850. numbers = parseInt(numbers);
  851. var numCount = "1".repeat(numbers);
  852. numCount = parseInt(numCount) * 9 + 1;
  853. var rollnum = "000000000" + Math.floor(Math.random() * numCount).toString();
  854. rollnum = rollnum.slice(-numbers);
  855. msgTest[msgTest.length] = rollnum;
  856. msgTest[msgTest.length] = "&#8203;";
  857. chatArea.val(msgTest.join(" "));
  858. }
  859. if (msgTest[0].toLowerCase() === "$8ball" && room.user.userinfo.loggedin) {
  860. eight_choices = [
  861. "It is certain",
  862. "It is decidedly so",
  863. "Without a doubt",
  864. "Yes - definitely",
  865. "You may rely on it",
  866. "As I see it, yes",
  867. "Most likely",
  868. "Outlook good",
  869. "Signs point to yes",
  870. "Yes",
  871. "Ask again later",
  872. "Better not tell you now",
  873. "Cannot predict now",
  874. "Don't count on it",
  875. "My reply is no",
  876. "My sources say no",
  877. "Outlook not so good",
  878. "Very doubtful",
  879. "Never",
  880. "Of course not"
  881. ];
  882. msgTest[0] = "&#8203;$8&#8203;b&#8203;a&#8203;l&#8203;l";
  883. answer = eight_choices[Math.floor(Math.random() * eight_choices.length)];
  884. msgTest[msgTest.length] = "|" + answer + "|";
  885. msgTest[msgTest.length] = "&#8203;";
  886. chatArea.val(msgTest.join(" "));
  887. }
  888. }
  889. });
  890. $("#vidchat-setting").on("change", ".radio input", function(){
  891. var state = $(this).attr('data-state');
  892. script.fns.set('showVidChat', state);
  893. });
  894. $("#toggle_vidchatemotes_box").on("change", function(){
  895. var checked = $(this).is(":checked");
  896. script.fns.set("showVidEmotes", checked);
  897. });
  898. $("#action_list").on("change", "input", function(){
  899. var checked = $(this).is(":checked");
  900. var val = $(this).attr('value');
  901. if (val in script.validModActions) {
  902. script.validModActions[$(this).attr('value')] = checked;
  903. script.fns.set("validActions", JSON.stringify(script.validModActions));
  904. }
  905. });
  906. $("#qualityList").on("change", ".radio input", function(){
  907. var val = $(this).attr('data-q');
  908. script.fns.setDefaultQuality(val);
  909. });
  910. $("#toggle_autoclean_box").on("change", function(){
  911. var checked = $(this).is(":checked");
  912. script.fns.toggleAutoClean(checked);
  913. });
  914. $("#toggle_logtochat_box").on("change", function(){
  915. var checked = $(this).is(":checked");
  916. script.fns.set("logToChat", checked);
  917. });
  918. $("#toggle_showadd_box").on("change", function(){
  919. var checked = $(this).is(":checked");
  920. script.fns.set("showAdd", checked);
  921. });
  922. $("#toggle_showroll_box").on("change", function(){
  923. var checked = $(this).is(":checked");
  924. script.fns.set("showRoll", checked);
  925. });
  926. $("#toggle_useemotes_box").on("change", function(){
  927. var checked = $(this).is(":checked");
  928. script.fns.set("useEmotes", checked);
  929. });
  930. $("#toggle_navbar_box").on("change", function(){
  931. var checked = $(this).is(":checked");
  932. script.fns.set("fixedNavbar", checked);
  933. checked ? $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'fixed') : $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  934. });
  935. $("#toggle_fast_box").on("change", function() {
  936. var checked = $(this).is(":checked");
  937. script.fns.set("showFast", checked);
  938. checked ? $codes['fast'] = '<marquee direction="right" scrollamount="' + script.fns.get("marqueeSpeed") + '">' : delete $codes.fast;
  939. });
  940. $('#toggle_spin_box').on("change", function() {
  941. var checked = $(this).is(":checked");
  942. script.fns.set("showSpin", checked);
  943. checked ? $codes['spin'] = '<span class="spinnew">' : delete $codes.spin;
  944. });
  945. $("#toggle_showlogs_box").on("change", function(){
  946. var checked = $(this).is(":checked");
  947. script.fns.set("showLogs", checked);
  948. if (checked) {
  949. $('.logWrapper').show();
  950. } else {
  951. $('.logWrapper').hide();
  952. $('#logs').empty();
  953. }
  954. });
  955. }
  956.  
  957. window.script.fns = {
  958. set: function(key, value) {
  959. localStorage.setItem(key, value);
  960. },
  961. get: function(key) {
  962. var a = localStorage.getItem(key);
  963. var b;
  964. if (a == "true" || a == "false")
  965. if (a == "true")
  966. b = true;
  967. else
  968. b = false;
  969. else if (!isNaN(parseInt(a)) && key !== "lastVersion")
  970. b = parseInt(a);
  971. else b = a;
  972. return b;
  973. },
  974. remove: function(key) {
  975. localStorage.removeItem(key);
  976. },
  977.  
  978. handleChatKeyup: function(event) {
  979. var chatArea = $('#cin');
  980. var cls = 'chatSpecial';
  981. if (chatArea.val()[0] === '<') {
  982. if (!chatArea.hasClass(cls))
  983. if (script.fns.get("showVidChat") === 1)
  984. chatArea.addClass(cls);
  985. } else {
  986. if (chatArea.hasClass(cls))
  987. chatArea.removeClass(cls);
  988. }
  989. },
  990. updateNotice: function(state, ver) {
  991. if (state == 'on' && ver != script.version) {
  992. $('.newUpdate').show();
  993. } else if (state == 'off') {
  994. $('.newUpdate').hide();
  995. }
  996. },
  997. setFast: function(data) {
  998. if (!isNaN(parseInt(data))) {
  999. if (data > 999) {
  1000. data = 999;
  1001. $('#marqueeinput').val(data);
  1002. }
  1003. script.fns.set("marqueeSpeed", data);
  1004. if (script.fns.get("showFast")) {
  1005. $codes['fast'] = '<marquee direction="right" scrollamount="' + data + '">';
  1006. }
  1007. }
  1008. },
  1009. updateRecent: function(a) {
  1010. sdbg.log("updateRecent called");
  1011. var recent = script.fns.get(room.roomName.toLowerCase() + ".recentVideos");
  1012. recent = $.parseJSON(recent);
  1013. if (recent == null)
  1014. recent = [];
  1015. if (recent.some(function(b) {return b.info.id == room.playlist.videos[a].info.id}) == false) {
  1016. recent.push(room.playlist.videos[a]);
  1017. if (recent.length > script.MAXRECENT)
  1018. recent = recent.slice(recent.length - script.MAXRECENT)
  1019. script.fns.viewHistory(recent);
  1020. }
  1021. recent = JSON.stringify(recent);
  1022. script.fns.set(room.roomName.toLowerCase() + ".recentVideos", recent);
  1023. },
  1024. postRoll: function(type, a, user) {
  1025. var msgClass = '';
  1026. if (type == "roll") {
  1027. msgClass = 'rollDigits ';
  1028. var rolledNumber = a[a.length - 2];
  1029. var numColor = '#005cff';
  1030. a[a.length - 2] = '';
  1031. if (rolledNumber.length > 10)
  1032. rolledNumber = rolledNumber.slice(0, 10);
  1033. if (rolledNumber == parseInt(rolledNumber)) {
  1034. var j = 1;
  1035. var k = rolledNumber.length;
  1036. for (var i = 1; i < k; i++) {
  1037. if (rolledNumber[i] === rolledNumber[i - 1])
  1038. j++;
  1039. else
  1040. break;
  1041. }
  1042. if (k === j) msgClass += 'rollConsecutive ';
  1043. return ['<span class="gm rollstr">&nbsp;' + user + ' rolled <span class="'+msgClass+'">' + rolledNumber + ' </span><br />', rolledNumber];
  1044. } else return "";
  1045. } else if (type == "8ball") {
  1046. msgClass = 'ballAnswer ';
  1047. return '<span class="gm ballstr">&nbsp;' + user + ': 8ball says, <span class="'+msgClass+'">"' + a + '" </span><br />';
  1048. } else return '';
  1049. },
  1050. clearChat: function() {
  1051. $('#chat_messages').empty();
  1052. messages = script.fastmsgs = script.spinmsgs = 0;
  1053. },
  1054. utcClock: function() {
  1055. var time = new Date();
  1056.  
  1057. var utcTime = {hrs: time.getUTCHours(), min: time.getUTCMinutes(), sec: time.getUTCSeconds()}
  1058. //var localTime = {hrs: time.getHours(), min: time.getMinutes(), sec: time.getSeconds()}
  1059.  
  1060. for (var i in utcTime) {
  1061. if (utcTime[i] < 10) utcTime[i] = "0" + utcTime[i];
  1062. //if (localTime[i] < 10) localTime[i] = "0" + localTime[i];
  1063. }
  1064. //remains as #gmtClock so people don't have to restyle it
  1065. $('#gmtClock').text(utcTime.hrs + ":" + utcTime.min + ":" + utcTime.sec + ' UTC');
  1066.  
  1067. setTimeout(function() {script.fns.utcClock()}, 1000);
  1068. },
  1069. getPlaylist: function() {
  1070. //heavily modified from Bibby's exportPlaylist() at https://github.com/Bibbytube/Instasynch under Playlist Additions/Export Playlist Command
  1071. var output = '';
  1072. var videoTitle = '';
  1073. var playlist = room.playlist.videos;
  1074. if (playlist.length > 0) {
  1075.  
  1076. for (i = 0; i < playlist.length; i++) {
  1077. playlist[i].title.length > 100 ? videoTitle = playlist[i].title.substring(0, 100) + '...' : videoTitle = playlist[i].title;
  1078. switch (playlist[i].info.provider) {
  1079. case 'youtube':
  1080. 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=';
  1081. break;
  1082. case 'vimeo':
  1083. 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/';
  1084. break;
  1085. case 'twitch':
  1086. 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/';
  1087. break;
  1088. case 'dailymotion':
  1089. 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/';
  1090. break;
  1091. default:
  1092. continue;
  1093. }
  1094. playlist[i].info.provider === 'twitch' ? output += playlist[i].info.channel + '</a>\n<br />' : output += playlist[i].info.id + '</a>\n<br />';
  1095. }
  1096. try {
  1097. var newWindow = window.open("", "_blank", "scrollbars=1,resizable=1");
  1098. 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>');
  1099. newWindow.document.body.style.background = 'black';
  1100. newWindow.document.body.style.fontFamily = 'tahoma';
  1101. } catch (e) {
  1102. console.error('Cannot open Playlist window. Are pop-ups disabled? ERROR: ' + e.message);
  1103. }
  1104. } else {
  1105. console.error("Cannot grab playlist, no videos.");
  1106. return;
  1107. }
  1108. },
  1109. // adjustCurtain() -- resize curtain upon change of screen layout, and toggle
  1110. adjustCurtain: function () {
  1111. var a = {h: $('#media').height(), w: $('#media').width()};
  1112. // a is an object of #media dimensions {h: height,w: width}
  1113. // floor of the curtain always has a constant height, so subtract
  1114. // the height of the floor from the height of the video to get the new curtainTop height
  1115. if ($('#curtainTop').width() !== a.w)
  1116. $('#curtainTop').width(a.w);
  1117. if ($('#curtainFloor').width() !== a.w)
  1118. $('#curtainFloor').width(a.w);
  1119. if ($('.curtain').height() !== a.h)
  1120. $('.curtain').height(a.h);
  1121. $('#curtainFloor').height() === 0 ? $('#curtainFloor').height(72) : $('#curtainFloor').height(0);
  1122. $('#curtainTop').height() === 0 ? $('#curtainTop').height($('#media').height() - 72) : $('#curtainTop').height(0);
  1123. },
  1124. hex2rgb: function(hexStr) { //can be found here:
  1125. // http://stackoverflow.com/questions/4262417/jquery-hex-to-rgb-calculation-different-between-browsers
  1126.  
  1127.  
  1128.  
  1129. // note: hexStr should be #rrggbb
  1130. var hex = parseInt(hexStr.substring(1), 16);
  1131. var r = (hex & 0xff0000) >> 16;
  1132. var g = (hex & 0x00ff00) >> 8;
  1133. var b = hex & 0x0000ff;
  1134. return [r, g, b];
  1135. },
  1136. updateColor: function(id, hex) {
  1137. var log = id + " passed to updateColor with hex color #" + hex + ".";
  1138. if (id in script.colorSettings && id !== "pickerControlBarOpacity") {
  1139. log += " accepted.";
  1140. el = 'head #h-' +id+ '.script-css-colors';
  1141. switch (id) {
  1142. case 'pickerButtons': $(el).html('.vjs-default-skin .vjs-play-control, .vjs-mute-control, .vjs-fullscreen-control {color: #'+hex+'}'); break;
  1143. case 'pickerHandles': $(el).html('.vjs-slider-handle {color: #'+hex+'}'); break;
  1144. case 'pickerHandlesGlow': $(el).html('.vjs-slider-handle:before {text-shadow: 0em 0em 1em #'+hex+'!important}'); break;
  1145. case 'pickerButtonsHoverGlow': $(el).html('.vjs-default-skin .vjs-play-control:hover:before, .vjs-mute-control:hover:before, .vjs-fullscreen-control:hover:before {text-shadow: 0em 0em 1em #'+hex+'!important}'); break;
  1146. case 'pickerProgress': $(el).html('.vjs-play-progress {background-color: #'+hex+'!important}'); break;
  1147. case 'pickerVolume': $(el).html('.vjs-volume-level {background-color: #'+hex+'!important}');break;
  1148. case 'pickerText': $(el).html('.vjs-current-time-display, .vjs-time-divider, .vjs-duration-display, .vjs-quality-button {color: #'+hex+'}'); break;
  1149. case 'pickerControlBar':
  1150. var rgb = script.fns.hex2rgb("#"+hex);
  1151. var opac;
  1152. opac = parseInt($.parseJSON(script.fns.get('cssSettings')).pickerControlBarOpacity) / 100;
  1153. if (isNaN(opac) || (opac<0 || opac>1)) {
  1154. opac = .7;
  1155. $('#pickerControlBarOpacity').val(70);
  1156. }
  1157. $(el).html('.vjs-control-bar {background-color: rgba('+rgb[0]+', '+rgb[1]+', '+rgb[2]+', '+opac+')!important}');
  1158. break;
  1159. }
  1160. log += " color changed.";
  1161. var css = $.parseJSON(script.fns.get("cssSettings"));
  1162. css[id] = hex;
  1163. css['pickerControlBarOpacity'] = $('#pickerControlBarOpacity').val();
  1164. log += " localStorage updated.";
  1165. script.fns.set("cssSettings", JSON.stringify(css));
  1166. }
  1167. sdbg.log(log + " done!");
  1168. },
  1169. findUserVideos: function(user) {
  1170. if (typeof(user) === 'string' && user !== '') {
  1171. var vids = 0;
  1172. var userLower = user.toLowerCase();
  1173. if (room.playlist.videos.length > 0) {
  1174. for (var i = 0; i < room.playlist.videos.length; i++) {
  1175. if (room.playlist.videos[i].addedby.toLowerCase() == userLower) {
  1176. vids++;
  1177. }
  1178. }
  1179. room.addMessage({username:''},'Found ' + vids + ' video(s) added by ' + user + '.','hashtext');
  1180. } else {
  1181. room.addMessage({username:''},'No videos in playlist.','urgenttext');
  1182. }
  1183. } else {
  1184. room.addMessage({username:''},"Usage: 'countvids [username]","hashtext");
  1185. }
  1186. },
  1187. getUserIndex: function(id) {
  1188. for (var i = 0; i < room.userlist.users.length; i++) {
  1189. if (id == room.userlist.users[i].id) {
  1190. return i;
  1191. }
  1192. }
  1193. return -1;
  1194. },
  1195. cleanLog: function() {
  1196. if (script.logs > script.MAXLOGS) {
  1197. $('#logs span').eq(1).css('opacity', '.4');
  1198. $('#logs span').eq(2).css('opacity', '.6');
  1199. $('#logs span').eq(3).css('opacity', '.8');
  1200. $('#logs span').eq(0).remove();
  1201. script.logs--;
  1202. }
  1203. },
  1204. setTabTitle: function(a,b,c,d) { //vidinfo, addedby, video index, title
  1205. var newTitle = d;
  1206. if (newTitle.length > 55) {
  1207. newTitle = newTitle.substring(0, 55);
  1208. newTitle += '...';
  1209. }
  1210. var currentVid = newTitle + ' via ' + b;
  1211. var videoLink = '';
  1212. document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
  1213. switch (a.provider) {
  1214. case "youtube":
  1215. videoLink = 'http://youtu.be/' + a.id;
  1216. break;
  1217. case "vimeo":
  1218. videoLink = 'http://vimeo.com/' + a.id;
  1219. break;
  1220. case "twitch":
  1221. videoLink = 'http://twitch.tv/' + a.channel;
  1222. break;
  1223. case "dailymotion":
  1224. videoLink = 'http://dailymotion.com/video/' + a.id;
  1225. break;
  1226. default:
  1227. videoLink = 'unlisted source';
  1228. break;
  1229. }
  1230. console.oldLog('Now playing: ' + currentVid + ' ( ' + videoLink + ' )');
  1231. },
  1232. setFavIcon: function(src) {
  1233. var a = '<link rel="shortcut icon" class="scr-fav" href="' + src + '">';
  1234. $('.scr-fav').length ? $('.scr-fav').attr('href', src) : $('head').append(a);
  1235. },
  1236. scrollTopPl: function() { //from built-in room.playVideo
  1237. $('#playlist').animate({
  1238. scrollTop: $("#playlist .active").offset().top - $("#playlist .active").offset().top + $("#playlist .active").scrollTop()
  1239. });
  1240. },
  1241. byteCount: function(s){return encodeURIComponent(s).replace(/%[A-F\d]{2}/g,'x').length},
  1242. //https://gist.github.com/mathiasbynens/1010324
  1243. playSound: function(sound) {
  1244. var vol = 0.8;
  1245. if (typeof(room.video) !== "undefined")
  1246. vol = room.video.video.volume();
  1247. sound.volume = vol;
  1248. sound.play();
  1249. },
  1250. testHexColor: function(str) {
  1251. if (str.length == 7) {
  1252. return (/^#[0-9a-f]{6}$/i).test(str);
  1253. } else if (str.length == 4) {
  1254. return (/^#[0-9a-f]{3}$/i).test(str);
  1255. } else {
  1256. return false;
  1257. }
  1258. },
  1259. buildEmotes: function() {
  1260. sdbg.log("script.fns.buildEmotes called");
  1261. window.script.$initialcodes = window.$codes;
  1262. window.script.$newcodes = {
  1263. //modified original emotes
  1264. 'chen': '<img src="http://i.imgur.com/j55EMQt.png" width="50" height="46" onclick="script.fns.playSound(script.emoteSounds.chen);">',
  1265. 'doot': '<img src="http://i.imgur.com/WfUlQ5Q.gif" width="50" height="45" onclick="script.fns.playSound(script.emoteSounds.doot);">',
  1266. 'bestgames': '<img src="http://i.imgur.com/ImyXj.png" width="48" height="54" onclick="script.fns.playSound(script.emoteSounds.chad);">',
  1267. 'no': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="script.fns.playSound(script.emoteSounds.no);">',
  1268. 'idontwantthat': '<img src="http://i.imgur.com/nKa8o.png" width="41" height="30" onclick="script.fns.playSound(script.emoteSounds.no);">',
  1269. 'heero' : '<img src="http://i.imgur.com/D7JCR6j.png" width="60" height="55">',
  1270. 'kek' : '<img src="http://i.imgur.com/xrw4paP.png" width="40" height="54">',
  1271. //additional emotes
  1272. 'chen2': '<img src="http://i.imgur.com/TGHRo8W.gif" width="54" height="50" onclick="script.fns.playSound(script.emoteSounds.chen2);">',
  1273. 'kitty2': '<img src="http://i.imgur.com/yxBHAvx.gif" width="38" height="60">',
  1274. 'enjoytheanime' : '<img src="http://i.imgur.com/aXPWln0.png" width="48" height="60">',
  1275. 'straya' : '<img src="http://i.imgur.com/PNB0kE9.gif" width="50" height="50">',
  1276. 'neverever' : '<img src="http://i.imgur.com/MJnWGHV.png" width="52" height="50">',
  1277. 'gud': '<img src="http://i.imgur.com/Ms3Zxne.png" width="62.5" height="50">',
  1278. 'feelssmug': '<img src="http://i.imgur.com/og9In6D.png" width="48" height="48">',
  1279. 'puke': '<img src="http://i.imgur.com/IADYHCP.png" width="58" height="58">',
  1280. 'tip': '<img src="http://i.imgur.com/QWhYbc8.gif" width="49" height="54">',
  1281. 'copythat': '<img src="http://i.imgur.com/VOibACz.png" width="31" height="51">',
  1282. 'ree': '<img src="http://i.imgur.com/U1Trjzq.gif" width="42" height="42">',
  1283. 'alien2': '<img src="http://i.imgur.com/jBji5uc.gif" width="43" height="63">',
  1284. };
  1285.  
  1286. window.script.$colorcodes = {
  1287. "knuckles": '</span><span style="color:tomato">',
  1288. "mario": '</span><span style="color:red">',
  1289. "starfox": '</span><span style="color:brown">',
  1290. "tomnook": '</span><span style="color:chocolate">',
  1291. "crashbandicoot": '</span><span style="color:orange">',
  1292. "orange": '</span><span style="color:orange">',
  1293. "pacman": '</span><span style="color:yellow">',
  1294. "gex": '</span><span style="color:yellowgreen">',
  1295. "link": '</span><span style="color:green">',
  1296. "halo2": '</span><span style="color:darkgreen">',
  1297. "chao": '</span><span style="color:aqua">',
  1298. "squirtle": '</span><span style="color:cyan">',
  1299. "liara": '</span><span style="color:steelblue">',
  1300. "bluebomber": '</span><span style="color:royalblue">',
  1301. "sonic": '</span><span style="color:blue">',
  1302. "krystal": '</span><span style="color:darkblue">',
  1303. "bigthecat": '</span><span style="color:indigo">',
  1304. "nights": '</span><span style="color:purple">',
  1305. "spyro": '</span><span style="color:blueviolet">',
  1306. "birdo": '</span><span style="color:deeppink">',
  1307. "kirby": '</span><span style="color:violet">',
  1308. "wakeupmrfreeman": '</span><span style="color:tan">',
  1309. "tomba": '</span><span style="color:pink">',
  1310. "metalgear": '</span><span style="color:silver">',
  1311. "kidicarus": '</span><span style="color: white">',
  1312. "gamenwatch": '</span><span style="color: black">',
  1313. "outline": '<span style="text-shadow: 1px 0 #00ccff, -1px 0px #00ccff, 0 1px #00ccff, 0 -1px #00ccff">',
  1314. "redoutline" : '<span style="text-shadow: 1px 0 #f00, -1px 0px #f00, 0 1px #f00, 0 -1px #f00">'
  1315. //"rainbowroad" : '</span><span class="rainbow">'
  1316. };
  1317. window.script.$fontcodes = {
  1318. "spoiler": '<font style="text-shadow: 0 0 black; background-color: #000; cursor: default" onmouseover="this.style.backgroundColor=\'transparent\'" onmouseout="this.style.backgroundColor=\'black\'">',
  1319. "i": '<font style="font-style:italic">',
  1320. "u": '<font style="text-decoration: underline">',
  1321. "b": '<strong>',
  1322. "s": '<strike>',
  1323. "endbold": '</strong>',
  1324. "endstrike": '</strike>',
  1325. "endspan": '</span></font></font></font>'
  1326. };
  1327. $.extend(script.$newcodes, script.$externalEmotes);
  1328. $.extend(script.$colorcodes, script.$fontcodes);
  1329. $.extend($codes, script.$newcodes);
  1330. $.extend($codes, script.$colorcodes);
  1331. sdbg.log("script.fns.buildEmotes finished");
  1332. },
  1333. useEmote: function(code) {
  1334. var msg = $('#cin').val();
  1335. //if (useColons)
  1336. msg = msg + ":" + code + ":";
  1337. //else
  1338. // msg = "/" + code;
  1339. $('#cin').val(msg);
  1340. },
  1341. buildEmoteMenu: function() {
  1342. var emoteMenu,code;
  1343. emoteMenu = code = '';
  1344.  
  1345. var endtags = {
  1346. s: ['<strike', '</strike>', 'Strikethrough'],
  1347. b: ['<strong', '</strong>', 'Bold'],
  1348. u: ['<font style="text-decoration: underline"', '</font>', 'Underline'],
  1349. i: ['<font style="font-style:italic"', '</font>', 'Italics'],
  1350. endstrike: ['<strike', '</strike>', 'End Strikethrough'],
  1351. endbold: ['<strong', '</strong>', 'End Bold'],
  1352. endspan: ['<strong style="text-decoration: underline; font-style: italic"', '</strong>', 'End font effects'],
  1353. 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']
  1354. }
  1355.  
  1356. $.each($codes, function(code, image) {
  1357. if (code != 'fast' && code != 'spin' && script.$colorcodes[code] == undefined) {
  1358. emoteMenu = emoteMenu + '<span title="' + code + '" onclick="script.fns.useEmote(\'' + code + '\')">' + image + '</span>';
  1359. }
  1360. });
  1361. emoteMenu += "<br />";
  1362. $.each(script.$colorcodes, function(code, bgcolor) {
  1363. if (code !== 'rainbowroad' && script.$fontcodes[code] == undefined) {
  1364. if (code == 'outline') {
  1365. bgcolor = 'color: black;box-shadow: 0 0 15px #00ccff inset';
  1366. } else if (code == 'redoutline') {
  1367. bgcolor = 'color: black;box-shadow: 0 0 15px #f00 inset';
  1368. } else {
  1369. bgcolor = bgcolor.slice(20, -2);
  1370. }
  1371. emoteMenu = emoteMenu + '<span class="colors" title="' + code + '" style="background-' + bgcolor + '" onclick="script.fns.useEmote(\'' + code + '\')"></span>';
  1372. }
  1373. });
  1374. emoteMenu += "<br />";
  1375. $.each(script.$fontcodes, function(code, node) {
  1376.  
  1377. var endc = '<font';
  1378. var endtag = '</font>';
  1379. var txt = '';
  1380.  
  1381. if (code in endtags) {
  1382. endc = endtags[code][0];
  1383. endtag = endtags[code][1];
  1384. txt = endtags[code][2];
  1385. }
  1386. emoteMenu = emoteMenu + '<span class="font-codes" title="' + code + '" onclick="script.fns.useEmote(\'' + code + '\')">' + endc + ' class="' + code + '">' + txt + endtag + '</span>';
  1387. });
  1388.  
  1389. $('#emotes').remove();
  1390. $('#emote_list').append('<div id="emotes">' + emoteMenu + '</div>');
  1391. //$('#emotes').css('display', 'none');
  1392. },
  1393.  
  1394. toggleAutoClean: function(setting) {
  1395. var ac,
  1396. message;
  1397. if (setting == true)
  1398. ac = true;
  1399. else if (setting == false)
  1400. ac = false;
  1401. else {
  1402. ac = script.fns.get("autoClean");
  1403. ac = !ac;
  1404. }
  1405. message = ac ? "Autoclean is now on. The next video must be position 1 to autoclean." : "Autoclean is now off.";
  1406. room.addMessage({username:''}, message, 'hashtext');
  1407. script.fns.set("autoClean", ac);
  1408. $('#toggle_autoclean_box').prop('checked', ac);
  1409. },
  1410. checkEmote: function(message, hexOnly) {
  1411. var doCheck = script.fns.get("useEmotes");
  1412. if (doCheck) {
  1413. var a,b,c,d,e,f,g;
  1414. a = b = c = d = e = 0;
  1415. while (a < message.length && a >= 0 && e < 4) {
  1416. var checked = false;
  1417. g = '';
  1418. f = '';
  1419. d++;
  1420. a = message.indexOf(':', a);
  1421. b = message.indexOf(':', a + 1);
  1422. f = message.slice(a, b + 1);
  1423. g = f.slice(1,-1).toLowerCase();
  1424. if ($codes.hasOwnProperty(g) || g[0] === '#') {
  1425.  
  1426. if (g[0] === '#') {
  1427. if (script.fns.testHexColor(g)) {
  1428. var colorNode = "</span><span style='color: " + g + "'>";
  1429. message = message.replace(f, colorNode);
  1430. c = colorNode.length;
  1431. checked = true;
  1432. e += 0.5;
  1433. }
  1434. }
  1435. if (!checked && !hexOnly) {
  1436. if ($codes.hasOwnProperty(g))
  1437. c = $codes[g].length;
  1438. else
  1439. return message;
  1440. message = message.replace(f, $codes[g]);
  1441. if (script.$colorcodes.hasOwnProperty(g) !== undefined || script.$fontcodes.hasOwnProperty(g) !== undefined || g == "fast" || g == "spin") e += 0.5;
  1442. else e++;
  1443. }
  1444. if (c < g.length) {
  1445. a = message.indexOf(g);
  1446. } else {
  1447. a += c;
  1448. }
  1449. } else if ($codes.hasOwnProperty(g)) {
  1450. a = b;
  1451. } else if (d >= 10) {
  1452. break;
  1453. }
  1454. }
  1455. }
  1456. return message;
  1457. },
  1458. cleanFast: function() {
  1459. var m = $('#chat_messages.chat-messages .message marquee');
  1460. if (!m.length)
  1461. script.fastmsgs = 0;
  1462. if (script.fastmsgs > script.MAXFAST) {
  1463. for (var i = 0; i < m.length, script.fastmsgs > script.MAXFAST; i++) {
  1464. m.eq(i)[0].outerHTML = m.eq(i)[0].innerHTML;
  1465. script.fastmsgs -= 1;
  1466. }
  1467. }
  1468. },
  1469. backgroundTimer: function(time, state, image) {
  1470. sdbg.log('backgroundTimer called ('+time+', '+state+', '+image+')');
  1471. if (state == true) {
  1472. if (room.video.video.currentTime() < time) {
  1473. script.bgTimeout = setTimeout(function() {
  1474. script.fns.backgroundTimer(time, script.bgtimer, image);
  1475. }, 1000);
  1476. } else if ((time < room.video.video.currentTime()) && (room.video.video.currentTime() < (time + 10))) { //allows people to refresh/join late if they do not want the background
  1477. script.bgtimer = false;
  1478. $('.video-image-header').remove();
  1479. $('head').append('<style class="video-image-header">.dim {background-image: url("'+image+'")!important}</style>');
  1480. } else {
  1481. script.bgtimer = false;
  1482. $('.video-image-header').remove();
  1483. return;
  1484. }
  1485. }
  1486. },
  1487. handleMessage: function(msg) { //Looked at Zod-'s ModSpy plugin for some ideas
  1488. //https://greasyfork.org/en/scripts/5962/code
  1489. var valid = script.validModActions;
  1490. var log = msg.split(" ");
  1491. var user = '<span class="modName">' + log[0] + '</span>';
  1492. var output = msg;
  1493. log[0] = '';
  1494. if (log.length == 5 && log[1]+" "+log[2]+" "+log[4] == "has purged videos.") {
  1495. otheruser = log[3];
  1496. log = "has purged videos.";
  1497. } else {
  1498. log = log.join(" ").trim();
  1499. }
  1500. if (valid[log] === true) {
  1501. script.last.modAction = log;
  1502. if (script.fns.get("logToChat")) {
  1503. if (log == "moved a video.") {
  1504. try {
  1505. var movedVideo = script.last.movedVideo;
  1506. var title = movedVideo[0].title;
  1507. if (title.length > 80)
  1508. title = title.substring(0,80) + "...";
  1509. output = user + " moved " + title + " via " + movedVideo[0].addedby + " to " + movedVideo[1];
  1510. } catch (e) {
  1511. console.error("nothing in script.last.movedVideo");
  1512. }
  1513. } else if (log == "has purged videos.") {
  1514. try {
  1515. output = user+" has purged "+otheruser+" videos.";
  1516. } catch (e) {
  1517. console.error(e.message);
  1518. }
  1519. } else if (log == "removed a video.") {
  1520. try {
  1521. var removedVideo = script.last.removedVideo;
  1522. var info = {info: removedVideo};
  1523. output = user + " removed <a href='" + room.playlist.url(info) + "' target='_blank'>a video</a>.";
  1524. } catch (e) {
  1525. console.error("nothing in script.last.removedVideo");
  1526. }
  1527. } else if (log == "has kicked a user.") {
  1528. script.kickedUser = [true, user];
  1529. return;
  1530. } else if (log == "has banned a user.") {
  1531. script.bannedUser = [true, user];
  1532. return;
  1533. } else if (log == "cleaned the playlist.") {
  1534. output = user + " cleaned the playlist.";
  1535. } else {
  1536. output = user + " " + log;
  1537. }
  1538. room.addMessage({username:'%modAction'},output,"chat-modAction");
  1539. }
  1540. }
  1541. },
  1542. cleanSpin: function() {
  1543. var m = $('#chat_messages.chat-messages .message .spinnew');
  1544. if (!m.length)
  1545. script.spinmsgs = 0;
  1546. if (script.spinmsgs > script.MAXSPIN) {
  1547. for (var i = 0; i < m.length, script.spinmsgs > script.MAXSPIN; i++) {
  1548. m.eq(i)[0].outerHTML = m.eq(i)[0].innerHTML;
  1549. script.spinmsgs -= 1;
  1550. }
  1551. }
  1552. },
  1553. viewHistory: function(vids) {
  1554. var icon = '',
  1555. host = '',
  1556. thumb = '',
  1557. title = '',
  1558. id = '',
  1559. provider = '',
  1560. recentHTML = '',
  1561. info,
  1562. duration,
  1563. addedby = '';
  1564. var key = {
  1565. 'youtube': {icon: 'http://i.imgur.com/KpOgg0D.png', host: 'http://youtube.com/watch?v='},
  1566. 'vimeo': {icon: 'http://i.imgur.com/TOogvwC.png', host: 'http://vimeo.com/'},
  1567. 'dailymotion': {icon: 'http://i.imgur.com/n7HR2hF.png', host: 'http://dailymotion.com/video/'},
  1568. 'twitch': {icon: 'http://i.imgur.com/0jO0wYz.png', host: 'http://twitch.tv/'},
  1569. }
  1570. $('#recent_list').empty();
  1571. try {
  1572. for (var i = vids.length - 1; i > -1; i--) {
  1573. info = vids[i].info;
  1574. provider = info.provider;
  1575. id = provider === 'twitch' ? info.channel : info.id;
  1576. thumb = info.thumbnail;
  1577. if (provider in key) {
  1578. icon = key[provider].icon;
  1579. host = key[provider].host;
  1580. }
  1581. title = vids[i].title;
  1582. if (title.length > 100)
  1583. title = title.slice(0,100) + '...';
  1584. addedby = vids[i].addedby;
  1585. duration = utils.secondsToTime(vids[i].duration);
  1586. 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>';
  1587. }
  1588. } catch (e) {
  1589. recentHTML = "<span>No videos.</span>";
  1590. }
  1591. $('#recent_list').append(recentHTML);
  1592. },
  1593. bumpUser: function(user, bumpTo) {
  1594. if (room.user.isMod) {
  1595. var a = false,
  1596. c = [],
  1597. b = '',
  1598. d = '',
  1599. e = bumpTo,
  1600. pl = room.playlist.videos,
  1601. users = room.userlist.users;
  1602. e = (e > 0) ? e - 1 : $('#playlist.playlist li.active').index() + 1;
  1603. e = parseInt(e);
  1604. if (isNaN(e) || e >= pl.length) {
  1605. d = 'Invalid playlist position.';
  1606. } else {
  1607. if (user !== '\\r') {
  1608. for (var i = 0; i < users.length; i++) {
  1609. if (users[i].username.toLowerCase().indexOf(user) == 0 && users[i].loggedin) {
  1610. c.push(users[i].username);
  1611. }
  1612. }
  1613. if (c.length > 1) {
  1614. d = 'Multiple users found. Be more specific.';
  1615. } else if (c.length == 0) {
  1616. d = 'No users found.';
  1617. } else if (c.length == 1) {
  1618. b = c[0];
  1619. for (var l = pl.length - 1; l > -1; l--) {
  1620. if (pl[l].addedby.toLowerCase() == b.toLowerCase()) {
  1621. a = true;
  1622. room.sendcmd('move', {
  1623. info: pl[l].info,
  1624. position: e
  1625. });
  1626. break;
  1627. }
  1628. }
  1629. d = a ? 'Bumped ' + b + '.' : 'No videos found.';
  1630. }
  1631. } else {
  1632. f = Math.ceil(Math.random() * playlist.length) - 1;
  1633. if (f == $('#playlist.playlist li.active').index()) {
  1634. f++;
  1635. }
  1636. if (f > pl.length - 1) {
  1637. d = 'Playlist too small.';
  1638. } else {
  1639. room.sendcmd('move', {
  1640. info: pl[f].info,
  1641. position: e
  1642. });
  1643. d = 'Random video (' + f + ') bumped.';
  1644. }
  1645. }
  1646. }
  1647. } else {
  1648. d = 'You cannot use this command.';
  1649. }
  1650. room.addMessage({username:""}, '<span style="color: red; font-style: none; font-weight:bold">$bump: </span>' + d + '</span></div>', 'system');
  1651. },
  1652. initializeSettings: function() {
  1653. var get = script.fns.get;
  1654. var set = script.fns.set;
  1655. for (var i in script.settings) {
  1656. sdbg.log("checking settings: " + i);
  1657. var val = get(i);
  1658. // i = key, val = key's value
  1659. switch (i) {
  1660. case "defaultQuality":
  1661. if (!script.qualities.hasOwnProperty(val) || val == null || val == 'null') {
  1662. sdbg.log("└ initializing " + i);
  1663. set(i, 'large');
  1664. }
  1665. break;
  1666. case room.roomName.toLowerCase() + ".recentVideos":
  1667. if (typeof($.parseJSON(val)) !== "object" || val == null || val == 'null') {
  1668. sdbg.log("└ initializing " + i);
  1669. set(room.roomName.toLowerCase() + ".recentVideos", "[]");
  1670. }
  1671. break;
  1672. case "showVidChat":
  1673. if (typeof val !== "number" || val == null || val == 'null' || val < 0 || val > 1) {
  1674. sdbg.log("└ initializing " + i);
  1675. set(i, 1);
  1676. }
  1677. break;
  1678. case "validActions":
  1679. if (typeof($.parseJSON(val)) !== "object" || val == null || val == 'null') {
  1680. sdbg.log("└ initializing " + i);
  1681. set(i, JSON.stringify(script.validModActions));
  1682. }
  1683. break;
  1684. case "cssSettings":
  1685. if (typeof($.parseJSON(val)) !== "object" || val == null || val == 'null') {
  1686. sdbg.log("└ initializing " + i);
  1687. set("cssSettings", JSON.stringify(script.colorSettings));
  1688. }
  1689. break;
  1690. case "lastVersion":
  1691. if (val !== script.version || val == "null" || val == null) {
  1692. sdbg.log("└ initializing " + i);
  1693. set(i, script.version);
  1694. room.addMessage({username:''}, "<span style='color: #09C073; font-weight: bold'>Script updated to v" + script.version + "!</span>", "system");
  1695. if (!$('#chat_tab_changelog').hasClass('tab_updated-glow'))
  1696. $('#chat_tab_changelog').addClass('tab_updated-glow');
  1697. }
  1698. break;
  1699. case "currentCSS":
  1700. if (script.cssLinks[val] === undefined) {
  1701. sdbg.log("└ initializing " + i);
  1702. set(i, script.settings[i]);
  1703. }
  1704. break;
  1705. case "showSpin":
  1706. set("showSpin", "false");
  1707. break;
  1708. default:
  1709. if (typeof(val) !== typeof($.parseJSON(script.settings[i])) || val == "null") {
  1710. sdbg.log("└ initializing " + i);
  1711. set(i, script.settings[i]);
  1712. }
  1713. break;
  1714. }
  1715. }
  1716. script.validModActions = $.parseJSON(get("validActions"));
  1717. for (var i in script.validModActions) {
  1718. $('#action_list').append('<label><input type="checkbox" value="'+i+'">'+i+'</label>');
  1719. $('#action_list input[value="'+i+'"]').prop('checked', script.validModActions[i]);
  1720. }
  1721. if (isNaN(parseInt(get("marqueeSpeed"))))
  1722. set("marqueeSpeed", script.settings["marqueeSpeed"]);
  1723. script.marqueeSpeed = parseInt(get("marqueeSpeed"));
  1724. if (get("showFast"))
  1725. $codes['fast'] = '<marquee direction="right" scrollamount="' + get("marqueeSpeed") + '">';
  1726. if (get("showSpin"))
  1727. $codes['spin'] = '<span class="spinnew">';
  1728. },
  1729. setCustomLayout: function(layoutName) {
  1730. var css = script.cssLinks;
  1731. if (css[layoutName] === undefined) {
  1732. console.error("script.fns.setCustomLayout: " + layoutName + " not found in script.cssLinks, check the name of the CSS if you are trying to add your own. Reverting to base CSS.");
  1733. $('.customLayout').remove();
  1734. script.fns.set("currentCSS", "none");
  1735. $('#css-none').prop('checked', true);
  1736. return;
  1737. }
  1738. if (css !== "none") {
  1739. if ($('.customLayout').href !== css[layoutName][2]) {
  1740. $('.customLayout').remove();
  1741. $('head').append('<link href="' + css[layoutName][2] + '" type="text/css" rel="stylesheet" class="customLayout">');
  1742. }
  1743. } else {
  1744. $('.customLayout').remove();
  1745. }
  1746. if (script.fns.get("currentCSS") !== layoutName) {
  1747. script.fns.set("currentCSS", layoutName);
  1748. $('#css-' + layoutName).prop('checked', true);
  1749. }
  1750. },
  1751. addLog: function(title, addedby) {
  1752. var cl = $('#chat_messages .chat-message');
  1753. if (typeof(title) !== "undefined")
  1754. if (title.length > 80)
  1755. title = title.slice(0, 80) + '...';
  1756. try {
  1757. if (cl.length) {
  1758. if ((!(/\: (Welcome to)/).test(cl[cl.length-1].textContent) && !(/\: (Connected)/).test(cl[cl.length-1].textContent)) && messages > 0) {
  1759. room.addMessage({username:'%addVideo'}, addedby + ' added ' + title, 'gm vid');
  1760. }
  1761. }
  1762. } catch (e) {
  1763. console.error(e.message);
  1764. }
  1765. },
  1766. addTempEmote: function(name, url, w, h) {
  1767. var newEmote = {};
  1768. if (w == null || w == 'null')
  1769. w = '';
  1770. if (h == null || h == 'null')
  1771. h = '';
  1772. url = url.replace(/['"]/g, '');
  1773. w = w.replace(/['"]/g, '');
  1774. h = h.replace(/['"]/g, '');
  1775. var node = '<img src="' + url + '" width="' + w + '" height="' + h + '">';
  1776. newEmote[name] = node;
  1777. $.extend($codes, newEmote);
  1778. },
  1779. initJSColor: function(a) {
  1780. $('.script-css-colors').remove();
  1781. $('head').append( //i like to make ids/classes complex to decrease chances of conflicts
  1782. '<style id="h-pickerButtons" class="script-css-colors"></style>'+
  1783. '<style id="h-pickerHandles" class="script-css-colors"></style>'+
  1784. '<style id="h-pickerHandlesGlow" class="script-css-colors"></style>'+
  1785. '<style id="h-pickerButtonsHoverGlow" class="script-css-colors"></style>'+
  1786. '<style id="h-pickerProgress" class="script-css-colors"></style>'+
  1787. '<style id="h-pickerVolume" class="script-css-colors"></style>'+
  1788. '<style id="h-pickerText" class="script-css-colors"></style>'+
  1789. '<style id="h-pickerControlBar" class="script-css-colors"></style>'
  1790. );
  1791. var css = $.parseJSON(script.fns.get("cssSettings"));
  1792. for (var i in css) {
  1793. if (i in script.colorSettings) {
  1794. document.getElementById(i).value = css[i];
  1795. script.fns.updateColor(i, css[i]);
  1796. }
  1797. }
  1798. if (a) {
  1799. var pickerOptions = {pickerPosition:'right', pickerMode:'HVS'};
  1800. window.buttonPicker = new jscolor.color(document.getElementById('pickerButtons'), pickerOptions);
  1801. window.buttonGlowPicker = new jscolor.color(document.getElementById('pickerButtonsHoverGlow'), pickerOptions);
  1802. window.handlesPicker = new jscolor.color(document.getElementById('pickerHandles'), pickerOptions);
  1803. window.handleGlowPicker = new jscolor.color(document.getElementById('pickerHandlesGlow'), pickerOptions);
  1804. window.progressPicker = new jscolor.color(document.getElementById('pickerProgress'), pickerOptions);
  1805. window.volumePicker = new jscolor.color(document.getElementById('pickerVolume'), pickerOptions);
  1806. window.textPicker = new jscolor.color(document.getElementById('pickerText'), pickerOptions);
  1807. window.controlbarPicker = new jscolor.color(document.getElementById('pickerControlBar'), pickerOptions);
  1808. }
  1809. },
  1810. setChecks: function() {
  1811. $('#marqueeinput').val(script.fns.get("marqueeSpeed"));
  1812. $('#vidchat-setting input[data-state="'+script.fns.get('showVidChat')+'"]').prop('checked', true);
  1813. $('#toggle_vidchatemotes_box').prop('checked', script.fns.get("showVidEmotes"));
  1814. $('#toggle_showlogs_box').prop('checked', script.fns.get("showLogs"));
  1815. $('#toggle_fast_box').prop('checked', script.fns.get("showFast"));
  1816. $('#toggle_spin_box').prop('checked', script.fns.get("showSpin"));
  1817. $('#toggle_showroll_box').prop('checked', script.fns.get("showRoll"));
  1818. $('#toggle_showadd_box').prop('checked', script.fns.get("showAdd"));
  1819. $('#toggle_autoclean_box').prop('checked', script.fns.get("autoClean"));
  1820. $('#toggle_useemotes_box').prop('checked', script.fns.get("useEmotes"));
  1821. $('#toggle_navbar_box').prop('checked', script.fns.get("fixedNavbar"));
  1822. $('#toggle_logtochat_box').prop('checked', script.fns.get("logToChat"));
  1823. $('#css-' + script.fns.get("currentCSS")).prop('checked', true);
  1824. script.fns.get("showLogs") ? $('.logWrapper').show() : $('.logWrapper').hide();
  1825. $('#qualityList input[data-q="'+script.fns.get('defaultQuality')+'"]').prop('checked', true);
  1826. script.fns.get("fixedNavbar") ? $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'fixed') : $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  1827. script.fns.setCustomLayout(script.fns.get("currentCSS"));
  1828. },
  1829. addScrollingMessage: function(message, state, extraClass) {
  1830. if (state === 1 && $('#media').height() > 0) {
  1831. if (message !== null && typeof message === "string" && message.length > 0) {
  1832. if (message.length > 240)
  1833. message = message.substring(0,240);
  1834. message = script.fns.checkEmote(message, !script.fns.get('showVidEmotes'));
  1835. setTimeout(function() {
  1836. $('.videochatContainer').append('<div class="videoText new '+extraClass+'" style="visibility:hidden">'+message+'</div>');
  1837. var el = $('.videoText.new');
  1838. var fontSize = Math.random() * (48.0 - 24.0) + 24.0;
  1839. var heightLevels = Math.floor($('#media').height() / fontSize);
  1840. el.css('font-size', fontSize+'px');
  1841. var level = fontSize * Math.floor(Math.random() * (heightLevels));
  1842. var w = el.width();
  1843. el.css('right', (0 - w)+'px');
  1844. el.css('visibility', 'visible');
  1845. el.css('top', level+'px');
  1846. var time = '4.5s';
  1847.  
  1848. move('.videoText.new')
  1849. .ease('linear')
  1850. .add('right', ($('#media').width() + w))
  1851. .duration(time)
  1852. .then(function() {
  1853. el.remove();
  1854. })
  1855. .end();
  1856. el.removeClass('new');
  1857. },200);
  1858. }
  1859. } else {
  1860. return;
  1861. }
  1862. },
  1863. findNearestQuality: function(quality) {
  1864.  
  1865. var x = 'auto',
  1866. qualListEl = $('.vjs-quality-button .vjs-menu ul li'),
  1867. q = [];
  1868.  
  1869. function error(e) {
  1870. //e == {message: "error message", return: "return value"};
  1871. console.error(e.message);
  1872. x = e.return;
  1873. }
  1874. if (qualListEl.length > 0) {
  1875. for (var i = qualListEl.length - 1; i > -1; i--) {
  1876. q.push(qualListEl.eq(i).attr('data-val'));
  1877. }
  1878. if (script.qualities.hasOwnProperty(quality)) {
  1879. if (q.indexOf(quality) > -1) {
  1880. x = quality;
  1881. } else {
  1882. quality = q[q.length - 1];
  1883. if (script.qualities.hasOwnProperty(quality))
  1884. x = quality;
  1885. else
  1886. error({message:'Given quality ' + quality + ' is not in the list of qualities. Returning \'auto\'.', return: 'auto'});
  1887. }
  1888. } else {
  1889. error({message:'Given quality ' + quality + ' is not in the list of qualities. Returning \'auto\'.', return: 'auto'});
  1890. }
  1891. } else {
  1892. error({message:'Nothing found in the video player\'s quality menu. Returning \'auto\'.', return: 'auto'});
  1893. }
  1894. return x;
  1895. },
  1896. setDefaultQuality: function(quality) {
  1897. var q = quality.toLowerCase();
  1898. if (script.qualities.hasOwnProperty(q)) {
  1899. script.fns.set('defaultQuality', q);
  1900. $('.vjs-quality-button .vjs-menu ul li[data-val="'+script.fns.findNearestQuality(q)+'"]').click();
  1901. $('#qualityList input[data-q="'+q+'"]').prop('checked', true);
  1902. } else {
  1903. console.error('Default quality not set: '+q+' is not a valid value.');
  1904. }
  1905. },
  1906. load: function() {
  1907. if (!window.script.loaded) {
  1908. if (!window.script.preloaded) {
  1909. for (var i = 0; i < script.pretasks.length; i++) {
  1910. sdbg.log("Pre-connect Task "+i+" executing...");
  1911. script.pretasks[i]();
  1912. sdbg.log("╚ Pre-connect Task "+i+" executed!");
  1913. }
  1914. window.script.preloaded = true;
  1915. }
  1916. window.script.loaded = true;
  1917. room.roomName.toLowerCase() == "v4c" ? script.fns.setFavIcon('http://i.imgur.com/DmMh2O9.png') : script.fns.setFavIcon('/favicon.ico');
  1918. for (var i = 0; i < script.tasks.length; i++) {
  1919. sdbg.log("Task "+i+" executing...");
  1920. script.tasks[i]();
  1921. sdbg.log("╚ Task "+i+" executed!");
  1922. }
  1923. console.oldLog("Script loaded.");
  1924. var hello = '<span style="font-weight:bold; color:#045AA4">Loaded ' + script.version + '.';
  1925. if (script.debug)
  1926. hello += ' <span style="font-weight:bold; color:#7304A4">Debug to console ON.</span>';
  1927. hello += '</span>';
  1928. room.addMessage({username:""}, hello, 'system');
  1929. setTimeout(function() {
  1930. window.script.delayedTasks.push(script.fns.buildEmoteMenu);
  1931. for (var i = 0; i < script.delayedTasks.length; i++) {
  1932. sdbg.log("Delayed task "+i+" executing...");
  1933. script.delayedTasks[i]();
  1934. sdbg.log("╚ Delayed task "+i+" executed!");
  1935. }
  1936. }, 700);
  1937. sdbg.log("script.fns.load finished");
  1938. }
  1939. }
  1940.  
  1941. };
  1942.  
  1943. window.script.setCSS = function() {
  1944. $('.scriptBaseCSS').remove();
  1945. $('head').append('<link class="scriptBaseCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDZ2IwRFRzaTV2dEU" rel="stylesheet" type="text/css">');
  1946. sdbg.log("Base CSS added to page header");
  1947. };
  1948.  
  1949. window.script.setHTML = function() {
  1950. if (!script.htmlIsSet) {
  1951. script.htmlIsSet = true;
  1952. 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>');
  1953. if (script.fns.get("fixedNavbar") == false)
  1954. $('.navbar-fixed-top, .navbar-fixed-bottom').css('position', 'static');
  1955. var addvideobtn = $('#add_video_btn').detach();
  1956. $('.add-video').replaceWith($('#add_video_url').detach());
  1957. $(addvideobtn).insertAfter($('#add_video_url'));
  1958. $('#media').parent().css('overflow', 'hidden');
  1959. $('.row.room-component-row').prepend('<div id="media-title"><div id="vidTitle" class="title"><div class="via"></div></div></div>');
  1960. $('.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>');
  1961. $('.nav.navbar-nav.navbar-right').prepend('<div id="gmtClock"></div>');
  1962. $('.video-controls .tab-content').append('<div class="tab-pane" id="tabs_playlist_emotes"><div class="pl-tab_header">Emote List<button class="btn btn-xs btn-default" style="float: right" onclick="script.fns.buildEmoteMenu();">Reload List</button></div><div id="emote_list"></div></div>');
  1963. $('.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>');
  1964. $('.video-controls .tab-content').append('<div class="tab-pane" id="tabs_playlist_cssmenu"><div id="layout_list"><div class="pl-tab_header">Custom Layouts</div></div></div>');
  1965. $('<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');
  1966. $('<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');
  1967. $('<li><a id="cssMenuTab" title="Layout Options" 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');
  1968. $('#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>');
  1969. $('<div class="videochatContainer"></div><div class="curtain"><div id="curtainTop"></div><div id="curtainFloor"></div></div>').insertBefore('#media');
  1970. $('.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>');
  1971. $('.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>');
  1972. $('.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>');
  1973. $('#tabs_playlist_settings .mod-control').append('<br /><div class="checkbox"><label class="active_tooltip"><input id="toggle_autoclean_box" type="checkbox" value="Autoclean">Autoclean</label></div>');
  1974. $('#tabs_chat_settings_content').append('<span class="areaLabel">Scrolling Messages on Video</span><div id="vidchat-setting"><div class="radio"><label class="active_tooltip"><input type="radio" name="vcoption" data-state="0">Disabled</label></div><div class="radio"><label class="active_tooltip"><input type="radio" name="vcoption" data-state="1">Enabled</label></div><div class="checkbox"><label class="active_tooltip"><input id="toggle_vidchatemotes_box" type="checkbox">Display Emotes</label></div></div>');
  1975. $('#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>');
  1976. $('#tabs_chat_settings_content').append('<div class="checkbox"><label class="active_tooltip"><input id="toggle_useemotes_box" type="checkbox" value="UseEmotes">Show Emotes in Chat</label></div>');
  1977. $('#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>');
  1978. $('#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>');
  1979. $('#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>');
  1980. $('#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>');
  1981. $('#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>');
  1982. $('#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><span style="display: block;padding-left: 20px;color:orange">Display these actions:</span><div id="action_list"></div></div>');
  1983. $('#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>');
  1984. $('<button id="resetsettings_btn" class="btn btn-xs btn-red" style="margin-left:5px">Reset Script Preferences</button>').insertAfter($('#clearchat_btn'));
  1985. $('<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');
  1986. $('<button id="export_playlist" class="btn btn-xs btn-default" style="margin-left: 4px">Export Playlist (pop-up)</button>').insertAfter($('#disable_player'));
  1987. /*$('#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>');
  1988. $('#recentsinput').val(script.fns.get("maxRecents"));*/
  1989. $('<div id="qualitySettings"><span class="areaLabel">Default Video Quality (experimental; not for YT player)</span><div id="qualityList"></div></div>').insertBefore('#tabs_playlist_settings .mod-control');
  1990.  
  1991. for (var i in script.qualities) {
  1992. var str = '';
  1993. if (i == 'hd2160')
  1994. str = '2160p (4k)';
  1995. else if (i == 'auto')
  1996. str = 'Auto';
  1997. else
  1998. str = script.qualities[i] + 'p';
  1999. var html = '<div class="radio"><label><input type="radio" name="defaultQuality" data-q="'+i+'">'+str+'</label></div>';
  2000. $('#qualityList').append(html);
  2001. }
  2002. for (var i in script.cssLinks) {
  2003. 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>';
  2004. $('#layout_list').append(html);
  2005. }
  2006. $('#tabs_playlist_cssmenu #layout_list').append('<div class="pl-tab_header">Colors<button id="resetcolor_btn" class="btn btn-xs btn-red" style="float: right">Reset Color Settings</button></div></div>');
  2007. $('#tabs_playlist_cssmenu #layout_list').append(
  2008. '<div class="css-picker">Player Button Color #<input id="pickerButtons" size="6" value="CCCCCC" onchange="script.fns.updateColor(\'pickerButtons\', $(this).val())"></div>'+
  2009. '<div class="css-picker"> └ Hover Glow Color #<input id="pickerButtonsHoverGlow" size="6" value="FFFFFF" onchange="script.fns.updateColor(\'pickerButtonsHoverGlow\', $(this).val())"></div>'+
  2010. '<div class="css-picker">Slider Handle Color #<input id="pickerHandles" size="6" value="CCCCCC" onchange="script.fns.updateColor(\'pickerHandles\', $(this).val())"></div>'+
  2011. '<div class="css-picker"> └ Glow Color #<input id="pickerHandlesGlow" size="6" value="FFFFFF" onchange="script.fns.updateColor(\'pickerHandlesGlow\', $(this).val())"></div>'+
  2012. '<div class="css-picker">Progress Bar Color #<input id="pickerProgress" size="6" value="66A8CC" onchange="script.fns.updateColor(\'pickerProgress\', $(this).val())"></div>'+
  2013. '<div class="css-picker">Volume Bar Color #<input id="pickerVolume" size="6" value="66A8CC" onchange="script.fns.updateColor(\'pickerVolume\', $(this).val())"></div>'+
  2014. '<div class="css-picker">Player Text Color #<input id="pickerText" size="6" value="CCCCCC" onchange="script.fns.updateColor(\'pickerText\', $(this).val())"></div>'+
  2015. '<div class="css-picker">Player Control Bar Color #<input id="pickerControlBar" size="6" value="07141E" onchange="script.fns.updateColor(\'pickerControlBar\', $(this).val())"></div>'+
  2016. '<div class="css-picker"> └ Opacity <input id="pickerControlBarOpacity" size="3" value="70" type="number" style="color: black" min="0" max="100" maxlength="3" onchange="script.fns.updateColor(\'pickerControlBar\', $(\'#pickerControlBar\').val())">% (buggy, may have to change on refresh/reset)</div>'
  2017. );
  2018. script.fns.initJSColor(true);
  2019. $('#changelog_list').append(script.changelog);
  2020. }
  2021. };
  2022.  
  2023. window.script.pretasks = [script.overwriteFunctions, script.setCSS]; //run before main tasks
  2024. window.script.tasks = [script.setHTML, script.setListeners, script.fns.utcClock]; //main tasks
  2025. window.script.delayedTasks = [script.fns.initializeSettings, script.fns.setChecks, script.fns.buildEmotes]; //delayed by 700ms after main tasks
  2026.  
  2027. $(function() {
  2028. if (!window.script.loaded) script.fns.load();
  2029. });