// ==UserScript==
// @name v4c/InstaSynch Additional Features
// @namespace v4c
// @description gives many additional features on instasynch. created by biggles, unless otherwise noted in script source. the purpose of this version is to put the script into the plugin itself, rather than an external file
// @include *://*.instasynch.com/rooms/*
// @include *://instasynch.com/rooms/*
// @match *://*.instasynch.com/rooms/*
// @match *://instasynch.com/rooms/*
// @require https://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js
// @require http://openuserjs.org/src/libs/TimidScript/TSL_-_jsColorGM.js
// @version 1.8731
// @grant none
// @author biggles
// ==/UserScript==
//BETA 1.873
//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).
/*
<InstaSynch - Watch Videos with friends.>
Copyright (C) 2013-2014 InstaSynch
<Instasynch modified code>
Copyright (C) 2013-2014 biggles (unless otherwise noted)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
http://opensource.org/licenses/GPL-3.0
*/
/* afterConnect (here, it is postConnect) function by Faqqq on http://userscripts.org:8080/scripts/show/181142 */
$(function() {
var postConnect = [];
loadedFunctions = loadedGlobalVariables = loadedCSS = loadedConnected = loadedCookies = loadedClock = loadedChatListeners = loadedEmoteMenu = loadedHTML = loadedBinds = false;
function postConnectDo() {
if ($('.users #userlist li').length < 1) {
setTimeout(function() {
postConnectDo();
}, 100);
return;
}
for (var i = 0; i < postConnect.length; i++) {
postConnect[i]();
}
}
$('head').append('<link rel="stylesheet" type="text/css" href="https://googledrive.com/host/0B2hdmKDeA0HDak92NTA2amhMZ2s?v=001"/>');
function loadGlobalVariables() {
window.scriptVer = "1.873b";
window.maxemotes = window.MAXLOGS = window.MAXFAST = 4;
currentVid = '';
isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.chenSound = new Audio('http://drowngaben.x10.mx/unused/bikehorn.ogg');
window.dootSound = new Audio('http://drowngaben.x10.mx/unused/dootdoot.mp3');
window.chadSound = new Audio('http://drowngaben.x10.mx/unused/gayniggas.mp3');
logTraffic = logVids = impone = showRoll = sameUserMessages = true;
logs = fastmsgs = 0;
recentVidInfo = [];
marqueeSpeed = 50;
autoClean = v4cm4c = largePlayer = largerPlayer = false;
loadedGlobalVariables = true;
stageBase = 675;
ignoreannivfunction = true;
userStyleList = ['registered ', 'registered um0 ', 'registered um1 ', 'registered ummb ', 'registered umbiggles '];
admins = ['manboss']; //too lazy to rename list -- not all are admins
eight_choices = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes - definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Signs point to yes",
"Yes",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
"Never",
"Of course not"
];
}
function loadCSS() {
loadedCSS = true;
switch ($.cookie('largePlayerSetting')) {
case '0':
largePlayer = false;
largerPlayer = false;
$('.jspContainer').attr('style', 'width: 536px; height: 327px;');
break;
case '1':
largePlayer = true;
largerPlayer = false;
$('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDVHVVWFBoMzZqdUU?d=20140526&v=000" type="text/css" />');
stageBase = 890;
$('.jspContainer').attr('style', 'width: 735px; height: 398px;');
$('#videos').attr('style', 'width: 739px');
break;
case '2':
largePlayer = false;
largerPlayer = true;
$('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDSkxuR1J0MUppRnc?d=20140526&v=000" type="text/css" />');
stageBase = 1393;
$('.jspContainer').attr('style', 'width: 1346px; height: 519px;');
$('#videos').attr('style', 'width: 1350px');
break;
}
}
function connected() {
loadedConnected = true;
addMessage({username:'[v' + scriptVer + ']Script'}, '<span style="font-weight:bold; color:#23B323">Loaded.</span>', 'system');
window.scrollTo(0, 165);
$('.stage').height(stageBase);
setTimeout(function() {
for (var q = 0; q < users.length; q++) {
var i = $('#userlist li').eq(q);
if ($('#userlist li')[q].textContent.toLowerCase() == ROOMNAME.toLowerCase()) {
i.addClass('admin');
}
if ($('#userlist li')[q].textContent.toLowerCase() == 'manboss' && v4cm4c) {
i.addClass('manboss');
}
if ($('#userlist li')[q].textContent.toLowerCase() == 'captainfalcon' && v4cm4c) {
i.addClass('user_cap');
}
if ($('#userlist li')[q].textContent.toLowerCase() == 'grinsly' && v4cm4c) {
i.addClass('grins');
}
if ($('#userlist li')[q].textContent.toLowerCase() == 'gingersnap' && v4cm4c) {
i.addClass('ginger');
}
}
}, 1000);
}
loadFunctions = function() {
loadedFunctions = true;
//functions here: secondsToTime(num) [core]; playSound(sound); getUserIndex(id); switchResolution(level); addLog(title,addedby); updateNotice(state,ver); addTempEmote(name,url,w,h);
//findUserVideos(user); checkMod(user); checkEmote(message); expandEmotes(); setFavIcon(src); cssCommand(mode,item,c); gmtClock(); clearChat(); cleanLog(); toggleAutoClean();
//viewHistory(vids); addUser(user,sort) [core]; removeUser(id) [core]; bumpUser(user,bumpto); addVideo(vidinfo,updateScrollbar) [core]; chatScroll() [core]; useEmote(code); videoHTMLChange(a,b,c);
//updateRecent(a); setTabTitle(a,b,c); playVideo(vidinfo, time, playing) [core]; cleanFast(); addMessage(user, message, extraStyles) [core]; buildEmoteMenu(); createPoll(poll) [core]; getPlaylist();
//byteCount(str);
window.playVideo = function(vidinfo, time, playing) {
var addedby,title;
addedby = title = '';
var indexOfVid = getVideoIndex(vidinfo);
if (indexOfVid > -1) {
if (mediashadow) {
if (vidinfo.provider === 'youtube') {
$('#media').css('box-shadow', '0 0 10px #CC181E');
} else if (vidinfo.provider === 'vimeo') {
$('#media').css('box-shadow', '0 0 10px #00ADEF');
} else if (vidinfo.provider === 'twitch') {
$('#media').css('box-shadow', '0 0 10px #b9a3e3');
} else if (vidinfo.provider === 'dailymotion') {
$('#media').css('box-shadow', '0 0 10px #ff0');
}
}
title = playlist[indexOfVid].title;
title = checkEmote(title);
addedby = playlist[indexOfVid].addedby;
videoHTMLChange(addedby, title, indexOfVid);
updateRecent(indexOfVid);
setTabTitle(vidinfo, addedby, indexOfVid);
video.play(vidinfo, time, playing);
$("#slider").slider("option", "max", playlist[indexOfVid].duration);
$("#sliderDuration").html("/" + secondsToTime(playlist[indexOfVid].duration));
$('#skip-count').attr('style', 'color: #fff!important');
if (autoClean && isMod) {
setTimeout(function() {
var vP = $('.video.active').index();
if (vP == 1) {
global.sendcmd('clean', null);
}
}, 1000);
}
var vidPlayingId = playlist[indexOfVid].info.id;
var bgtimer = '';
if (vidPlayingId == 'IniyZZqlcwA') {
clearTimeout(bgtimer);
window.bgtimer = setTimeout(function() {
$('#stage').css('background-image', 'url("http://whereduaneat.org/duane.gif")');
}, 21000);
} else {
clearTimeout(bgtimer);
$('#stage').css('background-image', 'none');
}
}
};
window.setFast = function(data) {
if (!isNaN(parseInt(data))) {
if (data > 99) {
data = 99;
$('#marqueeinput').val(data);
}
marqueeSpeed = data;
if (typeof($codes.fast) === 'string') {
$codes.fast = '<marquee direction="right" scrollamount="' + marqueeSpeed + '">';
}
}
};
window.updateColor = function(id, hex) {
switch (id) {
case 'pickerButtons': $('.vjs-default-skin .vjs-play-control, .vjs-mute-control, .vjs-fullscreen-control').css('color', '#'+hex); break;
case 'pickerHandles': $('.vjs-slider-handle').css('color', '#'+hex); break;
case 'pickerProgress': $('.vjs-play-progress, .vjs-volume-level').css('background-color', '#'+hex); break;
case 'pickerText': $('.vjs-current-time-display, .vjs-time-divider, .vjs-duration-display, .vjs-quality-button').css('color', '#'+hex); break;
}
};
window.showChangelog = function() {
$('#chat-messages').append('<div class="message changelog"><strong style="color: #f0f">============= Changelog =============</strong></div>');
$('#chat-messages').append('<div class="message changelog"><strong style="color: #0000aa">[1.87]</strong> New "hide video" button in the playlist controls bar.</div>');
$('#chat-messages').append('<div class="message changelog"><strong style="color: #0f0">[1.873b]</strong> Small fixes; should be updatable through the browser plugin now</div>');
$('#chat-messages').append('<div class="message changelog"><strong style="color: #f0f">====================================</strong></div>');
messages += 3;
chatScroll();
};
window.byteCount = function(str) {
return encodeURI(str).split(/%..|./).length - 1;
}; /*Lauri Oherd on stackoverflow*/
jQuery.lazyCookie = function() {
if (jQuery.cookie(arguments[0]) === null) return;
jQuery.cookie.apply(this, arguments);
}; /*by Jacob Relkin on stackoverflow*/
window.secondsToTime = function(num) {
var hours = Math.floor(num / 3600);
var minutes = Math.floor((num - (hours * 3600)) / 60);
var seconds = num - (hours * 3600) - (minutes * 60);
if (minutes < 10 && hours > 0)
minutes = "0" + minutes;
if (seconds < 10)
seconds = "0" + seconds;
var time = "";
if (hours !== 0)
time += hours + ':';
time += minutes + ':' + seconds;
return time;
};
window.playSound = function(sound) {
var vol = video.video.volume();
sound.volume = vol;
sound.play();
};
window.getUserIndex = function(id) {
for (var i = 0; i < users.length; i++) {
if (id == users[i].id) {
return i;
}
}
return -1;
};
window.switchResolution = function(level) {
var switchRes = false;
switch (level) {
case 0:
$.cookie('largePlayerSetting', '0');
largePlayer = false;
largerPlayer = false;
var currentCSS = $('.scriptCSS');
$('.jspContainer').attr('style', 'width: 536px; height: 327px;');
$('#videos').attr('style', 'width: 539px');
stageBase = 675;
$('#players a.normal').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.normal').attr('href', null);
$('#players a.large, #players a.larger').attr('style', 'color: #ccc!important; text-decoration: underline!important');
$('#players a.large, #players a.larger').attr('href', '#');
$('.stage').height(stageBase);
if ($('#curtain').height() > 320) $('#curtain').height('320px');
currentCSS.remove();
break;
case 1:
$.cookie('largePlayerSetting', '1');
largePlayer = true;
largerPlayer = false;
var currentCSS = $('.scriptCSS');
$('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDVHVVWFBoMzZqdUU?d=20140526&v=000" type="text/css" />');
stageBase = 890;
$('#players a.large').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.large').attr('href', null);
$('#players a.larger, #players a.normal').attr('style', 'color: #ccc!important; text-decoration: underline!important');
$('#players a.larger, #players a.normal').attr('href', '#');
$('.stage').height(stageBase);
$('.jspContainer').attr('style', 'width: 735px; height: 398px;');
$('#videos').attr('style', 'width: 739px');
if ($('#curtain').height() > 436) {
$('#curtain').height('436px');
} else if ($('#curtain').height() > 0 && $('#curtain').height() < 436) {
$('#curtain').height('436px');
}
currentCSS.remove();
break;
case 2:
$.cookie('largePlayerSetting', '2');
largePlayer = false;
largerPlayer = true;
var currentCSS = $('.scriptCSS');
$('head').append('<link rel="stylesheet" class="scriptCSS" href="https://googledrive.com/host/0B2hdmKDeA0HDSkxuR1J0MUppRnc?d=20140526&v=000" type="text/css" />');
stageBase = 1393;
$('#players a.larger').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.larger').attr('href', null);
$('#players a.large, #players a.normal').attr('style', 'color: #ccc!important; text-decoration: underline!important');
$('#players a.large, #players a.normal').attr('href', '#');
$('.stage').height(stageBase);
$('.jspContainer').attr('style', 'width: 1346px; height: 519px;');
$('#videos').attr('style', 'width: 1350px');
if ($('#curtain').height() > 796) {
$('#curtain').height('796px');
} else if ($('#curtain').height() > 0 && $('#curtain').height() < 796) {
$('#curtain').height('796px');
}
currentCSS.remove();
break;
}
};
window.addLog = function(title, addedby) {
var cl = $('#chat-messages .message');
if (cl[cl.length - 1].textContent !== ': Reconnected to chat server.' && messages > 2) {
if (title.length > 80)
title = title.slice(0, 80) + '...';
addMessage({username:'%addVideo'}, addedby + ' added ' + title, 'gm vid');
}
};
window.updateNotice = function(state, ver) {
if (state == 'on' && ver != scriptVer) {
$('#newUpdate').show();
} else if (state == 'off') {
$('#newUpdate').hide();
}
};
window.addTempEmote = function(name, url, w, h) {
var newEmote = {};
var node = '<img src="' + url + '" width="' + w + '" height="' + h + '">';
newEmote[name] = node;
$.extend($codes, newEmote);
};
window.findUserVideos = function(user) {
var vids = 0;
var userLower = user.toLowerCase();
if (playlist.length !== 0) {
for (var i = 0; i < playlist.length; i++) {
if (playlist[i].addedby.toLowerCase() == userLower) {
vids++;
}
}
addMessage({username:''},'Found ' + vids + ' video(s) added by ' + user + '.','hashtext');
} else {
addMessage({username:''},'No videos in playlist.','urgenttext');
}
};
window.checkMod = function(user) {
user = user.toLowerCase();
for (var i = 0; i < users.length; i++) {
if (users[i].username.toLowerCase() == user) {
var p = users[i].permissions;
var Mod;
if (p == "1" && admins.indexOf(user) < 0) {
Mod = 1; //normal mod
} else if (p == 2) {
Mod = 2; //admin of room
} else if (admins.indexOf(user) > -1) {
Mod = 3; //user in custom admin list
} else {
Mod = 0; //normal user
}
return Mod;
}
}
};
window.checkEmote = function(message) {
var a,b,c,d,e;
a = b = c = d = e = 0;
while (a < message.length && a >= 0 && e < 4) {
d++;
a = message.indexOf(':', a);
b = message.indexOf(':', a + 1);
var f = message.slice(a, b + 1);
if ($codes[f.slice(1, -1).toLowerCase()] !== undefined) {
c = $codes[f.slice(1, -1).toLowerCase()].length;
var emote = f.slice(1, -1).toLowerCase();
message = message.replace(f, $codes[emote]);
if ($colorcodes[emote] !== undefined || $fontcodes[emote] !== undefined) e += 0.5;
else e++;
if (c < f.slice(1, -1).length) {
a = message.indexOf(f.slice(1, -1));
} else {
a = ($codes[f.slice(1, -1).toLowerCase()].length + a);
}
} else if ($codes[f.slice(1, -1).toLowerCase()] === undefined) {
a = b;
} else if (d >= 10) {
break;
}
}
return message;
};
window.expandEmotes = function() {
var a = $('#facecodesmenu');
var b = $('#radiomenu');
a.toggle();
b.toggle();
$('#facecodesmenu #emotes').toggle();
};
window.setFavIcon = function(src) {
var a = '<link rel="shortcut icon" class="scr-fav" href="' + src + '">';
$('.scr-fav').remove();
$('head').append(a);
};
window.cssCommand = function(mode, item, c) {
if (mode == 'glow') {
if (c == 'off') {
$(item).css('box-shadow', 'none');
} else {
$(item).css('box-shadow', '0 0 15px ' + c);
}
} else if (mode == 'bg') {
if (c == 'off') {
$(item).css('background-image', 'none');
} else {
$(item).css('background-image', 'url(' + c + ')');
}
}
};
window.clearChat = function() {
$('#chat-messages').empty();
messages = fastmsgs = 0;
};
window.cleanLog = function() {
if (logs > MAXLOGS) {
$('#logs span').slice(1, 2).css('opacity', '.4');
$('#logs span').slice(2, 3).css('opacity', '.6');
$('#logs span').slice(3, 4).css('opacity', '.8');
$('#logs span')[0].remove();
$('#logs br')[0].remove();
logs--;
}
};
String.prototype.repeat = function(num) {
return new Array(num + 1).join(this);
};
window.toggleAutoClean = function() {
autoClean = !autoClean;
if (autoClean) {
addMessage({username:''}, 'Autoclean is now on. The next video must be position 1 to autoclean.', 'hashtext');
} else {
addMessage({username:''}, 'Autoclean is now off.', 'hashtext');
}
};
window.viewHistory = function(vids) {
var icon = '';
var host = '';
var thumb = '';
var title = '';
$('#viewHistory').empty();
$('#viewHistory').append('<div class="close-history x" onclick="$(\'#gethistory\').click();"></div>');
for (var i = vids.length - 1; i > -1; i--) {
thumb = vids[i].info.thumbnail;
if (vids[i].info.provider == 'youtube') {
icon = "http://i.imgur.com/KpOgg0D.png";
host = "http://youtube.com/watch?v=";
} else if (vids[i].info.provider == 'vimeo') {
icon = "http://i.imgur.com/TOogvwC.png";
host = "http://vimeo.com/";
} else if (vids[i].info.provider == 'dailymotion') {
icon = "http://i.imgur.com/n7HR2hF.png";
host = "http://dailymotion.com/video/";
} else if (vids[i].info.provider === 'twitch') {
host = "http://twitch.tv/";
icon = "http://i.imgur.com/0jO0wYz.png";
vids[i].info.id = vids[i].info.channel;
}
title = vids[i].title;
if (title.length > 100) {
title = title.slice(0,100) + '...';
}
$('#viewHistory').append('<li class="search-result" title="' + title + '"><a href="' + host + vids[i].info.id + '" target="_blank"><span class="video-thumb"><img class="video-thumbnail" src="' + thumb + '"><img class="video-icon" src="' + icon + '"><span class="video-time">' + secondsToTime(vids[i].duration) + '</span></span><span class="video-title">' + title + '</span><span class="video-uploader">added by <b><span id="vidUploader">' + vids[i].addedby + '</span></b></a></li>');
}
};
window.addUser = function(user, sort) {
var css = '';
if (user['loggedin']) {
css += 'registered ';
if (logTraffic) {
$('<span/>', {
"css": {
color: '#00a000'
},
"html": '+ ' + user.username
}).appendTo('#logs');
$('#logs').append($('<br/>'));
logs++;
cleanLog();
}
}
if (user.permissions > 0) {
css += 'm ';
}
if (user.permissions == "1" || user.permissions == 2) {
var name = user.username.toLowerCase();
if (name == ROOMNAME.toLowerCase()) {
css += 'admin ';
}
if (name == 'manboss' && v4cm4c) {
css += 'manboss';
}
if (name == 'captainfalcon' && v4cm4c) {
css += 'user_cap ';
}
if (name == 'grinsly' && v4cm4c) {
css += 'grins ';
}
if (name == 'gingersnap' && v4cm4c) {
css += 'ginger ';
}
}
css += isMuted(user.ip) ? "muted" : "";
user.css = css;
users.push(user);
var userElement = $('<li/>', {
"class": css,
"text":user.username,
"data": {username: String(user.username), id: user.id, css: css, loggedin: user.loggedin, ip: user.ip},
"click": function () {
$('#cin')['val']($('#cin')['val']() + $(this).data('username'));
$('#cin')['focus']();
}
});
userElement.hover(function ()
{
var thisElement = $(this);
$(this).data('hover', setTimeout(function ()
{
$('#bio-username').text(thisElement.data('username').toUpperCase());
$("#user_bio_hover").css('top', $(thisElement).offset().top - $("#chat").offset().top + 10);
$('#bio-image').attr('src', '');
$('#bio-text').text('');
//reset
$('#ban').data('id', "");
$('#kick').data('id', "");
$('#mute-button').data('ip', "");
//
$('#user_bio_hover').show();
if (thisElement.data('loggedin') == true)
{
getUserInfo(thisElement.data('username'), function (avatar, bio) {
$('#bio-image').attr('src', avatar);
$('#bio-text').text(bio);
});
} else {
$('#bio-text').html("<span style='color: grey; font-style:italic'>User is not registered.</span>");
}
$('#ban').data('id', user['id']);
$('#kick').data('id', user['id']);
$('#mute-button').data('ip', user.ip);
//show or hide mute/unmute buttons
if (isMuted(user.ip))
{
$("#mute-button").removeClass("");
$("#mute-button").addClass("");
}
else
{
$("#mute-button").removeClass("");
$("#mute-button").addClass("");
}
}, 600));
}, function () {
clearTimeout($(this).data('hover'));
setTimeout(function () {
if (!mouseOverBio) {
$('#user_bio_hover').hide();
}
}, 50);
});
$('#userlist').append(userElement);
$('#viewercount').text(users.length);
if (sort === true) {
sortUserlist();
}
if (users.length >= 100) {
if (users.length < 200) {
if (!$('#viewercount').hasClass('highviewcount'))
$('#viewercount').addClass('highviewcount');
if ($('#viewercount').hasClass('higherviewcount'))
$('#viewercount').removeClass('higherviewcount');
} else if (users.length >= 200) {
if ($('#viewercount').hasClass('highviewcount'))
$('#viewercount').removeClass('highviewcount');
$('#viewercount').addClass('higherviewcount');
}
} else {
if ($('#viewercount').hasClass('highviewcount'))
$('#viewercount').removeClass('highviewcount');
if ($('#viewercount').hasClass('higherviewcount'))
$('#viewercount').removeClass('higherviewcount');
}
};
window.removeUser = function(id) {
var user = users[getUserIndex(id)];
if (user.loggedin && logTraffic) {
$('<span/>', {
"css": {
color: '#a00000'
},
"html": '- ' + user.username,
}).appendTo('#logs');
$('#logs').append($('<br/>'));
logs++;
cleanLog();
}
for (var i = 0; i < users.length; i++)
{
if (id === users[i].id)
{
users['splice'](i, 1);
$($('#userlist').children('li')[i]).remove();
break;
}
}
$('#viewercount').html(users.length);
if (users.length >= 100) {
if (users.length < 200) {
if (!$('#viewercount').hasClass('highviewcount'))
$('#viewercount').addClass('highviewcount');
if ($('#viewercount').hasClass('higherviewcount'))
$('#viewercount').removeClass('higherviewcount');
} else if (users.length >= 200) {
if ($('#viewercount').hasClass('highviewcount'))
$('#viewercount').removeClass('highviewcount');
$('#viewercount').addClass('higherviewcount');
}
} else {
if ($('#viewercount').hasClass('highviewcount'))
$('#viewercount').removeClass('highviewcount');
if ($('#viewercount').hasClass('higherviewcount'))
$('#viewercount').removeClass('higherviewcount');
}
};
window.bumpUser = function(user, bumpTo) {
if (isMod) {
var a = false;
var c = [];
var b = '';
var d = '';
var e = bumpTo;
if (e === null) {
e = $('.video.active').index() + 1;
}
e = parseInt(e);
if (isNaN(e) || e >= playlist.length) {
d = 'Invalid playlist position.';
} else {
if (user !== '\\r') {
for (var i = 0; i < users.length; i++) {
if (users[i].username.toLowerCase().indexOf(user) == 0 && users[i].loggedin) {
c.push(users[i].username);
}
}
if (c.length > 1) {
d = 'Multiple users found. Be more specific.';
} else if (c.length == 0) {
d = 'No users found.';
} else if (c.length == 1) {
b = c[0];
for (var l = playlist.length - 1; l > -1; l--) {
if (playlist[l].addedby.toLowerCase() == b.toLowerCase()) {
a = true;
global.sendcmd('move', {
info: playlist[l].info,
position: e
});
break;
}
}
if (a) {
d = 'Bumped ' + b + '.';
} else {
d = 'No videos found.';
}
}
} else {
f = Math.ceil(Math.random() * playlist.length) - 1;
if (f == $('.video.active').index()) {
f++;
}
if (f > playlist.length - 1) {
d = 'Playlist too small.';
} else {
global.sendcmd('move', {
info: playlist[f].info,
position: e
});
d = 'Random video (' + f + ') bumped.';
}
}
}
} else {
d = 'You cannot use this command.';
}
$('<div class="message"><span class="cm gm"><span style="color: red; font-style: none; font-weight:bold">$bump: </span>' + d + '</span></div>').appendTo('#chat-messages');
messages++;
chatScroll();
};
window.addVideo = function(vidinfo, updateScrollbar) {
playlist.push({info: vidinfo.info, title: vidinfo.title, addedby: vidinfo.addedby, duration: vidinfo.duration});
var dur = '';
var thisTitle = vidinfo.title;
if (logVids && messages > 3)
addLog(vidinfo.title, vidinfo.addedby);
if (vidinfo.info.provider == 'twitch')
dur = 'Twitch Stream';
else
dur = secondsToTime(vidinfo.duration);
if (thisTitle.length > 200)
thisTitle = thisTitle.slice(0,200) + '...';
var li = $('<li/>', {"class":"video","data":{info: vidinfo.info}});
var vidInfo = $('<div/>', {"class":"video-info"})
.append($('<div/>',{"class":"title","text":thisTitle, "title":thisTitle}))
.append($('<div/>',{"class":"via", "text":"via " + vidinfo.addedby}))
.append($('<div/>',{"class":"duration","text":dur}));
var buttons = $('<div/>',{"class":"buttons"})
.append($('<div/>',{
"class":"info",
"title":"More information about this video.",
"click":function()
{
$(".detailed-info").fadeIn(); //to show loading spinner
getVideoInfo(vidinfo.info, function(err, data){
if (err){
//output error
}
else{
showVideoInfo(vidinfo.info, data);
}
});
}
}))
.append($('<a/>',{
"class":"link",
"title":"Open this video in a new tab.",
"href":url(vidinfo),
"target":"_blank",
"style":"display: inline-block"
}));
if (isMod) //if mod,
{
buttons.append($('<div/>',
{
"class":"remove",
"title":"Remove video",
"click":function()
{
global.sendcmd('remove', {info: vidinfo.info});
}
}));
}
$(vidInfo).click(function()
{
if ($("#video-list").hasClass("noclick")) //Don't make the video play if sorting video
{
$("#video-list").removeClass('noclick');
}
else
{
if (isLeader)
{
global.sendcmd('play', {info: vidinfo.info});
}
else
{
$('#cin').val($('#cin').val() + getVideoIndex(vidinfo.info) + ' ');
$('#cin').focus();
}
}
});
li.append(vidInfo).append(buttons);
$('#video-list').append(li);
totalTime += vidinfo.duration;
$('#total-videos').html(playlist.length);
$('#total-duration').html(secondsToTime(totalTime));
if (updateScrollbar)
$("#videos").data("jsp").reinitialise(); //uses alot of resources
};
window.chatScroll = function() {
if (autoscroll) {
var textarea = document.getElementById('chat-messages');
textarea.scrollTop = textarea.scrollHeight;
}
};
window.useEmote = function(code) {
var msg = $('#cin').val();
if ($('input[name=a]:checked', '#radios').val() == 0) {
msg = msg + ":" + code + ":";
$('#cin').val(msg);
} else if ($('input[name=a]:checked', '#radios').val() == 1) {
msg = "/" + code;
$('#cin').val(msg);
}
};
window.videoHTMLChange = function(a,b,c) {
$('.video.active .video-info').css('color', '#888');
$('.video.active .video-info .duration').css('color', '#888');
$('.video.active').removeClass('active');
$($('#video-list').children('li')[c]).addClass('active');
$('.video.active .video-info').css('color', '#000');
$('.video.active .video-info .duration').css('color', '#000');
$('#vidTitle').html(b + ' <div class=\'via\'> via ' + a + '</div>');
$('#vidTitle .via').css('color', '#ccc');
};
window.updateRecent = function(a) {
if (recentVidInfo.indexOf(playlist[a]) < 0) recentVidInfo.push(playlist[a]);
if (recentVidInfo.length > 12) {
recentVidInfo = recentVidInfo.slice(recentVidInfo.length - 12);
}
};
window.setTabTitle = function(a,b,c) {
var newTitle = playlist[c].title;
if (newTitle.length > 55) {
newTitle = newTitle.substring(0, 55);
newTitle += '...';
}
currentVid = newTitle + ' via ' + b;
document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
if (a.provider == 'youtube') videoLink = 'http://youtu.be/' + a.id;
else if (a.provider == 'vimeo') videoLink = 'http://vimeo.com/' + a.id;
else if (a.provider == 'twitch') videoLink = 'http://twitch.tv/' + a.channel;
else if (a.provider == 'dailymotion') videoLink = 'http://dailymotion.com/video/' + a.id;
if (isChrome) console.log('%c Now playing: ' + currentVid + ' ( ' + videoLink + ' ) ', 'background-color: black; color: #00ecff'); else console.log('Now playing: ' + currentVid + ' ( ' + videoLink + ' )');
};
window.cleanFast = function() {
var max = MAXFAST;
if ($('#chat-messages.messages .message marquee')[0] == undefined) {
fastmsgs = 0;
}
while (fastmsgs > max) {
$('#chat-messages.messages .message marquee')[0].remove();
fastmsgs--;
}
};
window.addMessage = function(user, message, extraStyles) { //extraStyles = additional classes FOR THE MESSAGE STYLE
var lastUserEl,lastUser;
if ($('#chat-messages .message .username').length > 0) {
lastUserEl = $('#chat-messages .message .username').slice(-1)[0];
lastUser = lastUserEl.textContent.slice(0, lastUserEl.textContent.length - 2).toLowerCase();
}
var senderString = user.username + ': ';
var usernameId = '';
if (user.username !== undefined) {
var name = user.username.toLowerCase();
}
var usernameClass = "";
if (filterGreyname === true)
{
if (user.loggedin === false)
{
return;
}
}
if (isMuted(user.ip))
{
return;
}
if (user.loggedin) {
usernameClass += 'registered ';
}
else{
usernameClass += 'unregistered ';
}
if (name == '%addvideo') {
usernameClass = 'hide';
}
var messageBox = $('<div/>', {
"class": "message"
});
if (name !== '' && sameUserMessages && $('.message').length > 0 && message.substring(0,4) !== "/me " && name !== '%addvideo' && user.loggedin) {
if (lastUserEl.id == name || lastUser == name) {
usernameId = name;
senderString = '';
$(messageBox).addClass("same");
}
}
var rollString, ballString;
var rawMessage = message;
var testRaw = rawMessage.split(" ");
if (message.indexOf(':fast:') > -1 && $.cookie('fastSetting') == '1') {
fastmsgs++;
cleanFast();
}
if (userStyleList.indexOf(usernameClass) > -1) { //'um' stands for name in message, used for mod names in chat
if (checkMod(name) == 1) {
if (name == 'biggles') usernameClass += 'umbiggles ';
else usernameClass += 'um0 '
} else if (checkMod(name) == 2) {
usernameClass += 'um1 '
} else if (checkMod(name) == 3 && v4cm4c) {
if (name.toLowerCase() == 'manboss') usernameClass += 'ummb '
}
}
message = linkify(message);
var ballTest = message.split("|");
var bumpTest = message.split(" ");
test = message.split(" ");
if (test[0] == '$bump') {
test[0] = '<img src="http://i.imgur.com/d1odx.png" width="25" height="25">';
}
if (testRaw[0] == '$css' && name == 'biggles' && usernameClass == 'registered umbiggles ') {
cssCommand(testRaw[1], testRaw[2], testRaw[3]);
}
if (testRaw[0] == '$delEmote' && name == 'biggles' && usernameClass == 'registered umbiggles ') {
if ($codes[testRaw[1]] != undefined) {
delete $codes[testRaw[1]];
}
}
if (testRaw[0] == '$tempEmote' && name == 'biggles' && usernameClass == 'registered umbiggles ') {
if ($codes[testRaw[1]] != undefined) {
delete $codes[testRaw[1]];
}
var jstest = rawMessage.split('|');
addTempEmote(testRaw[1], testRaw[2], testRaw[3], testRaw[4], jstest[1]);
}
if (testRaw[0] == '$updated' && name == 'biggles' && usernameClass == 'registered umbiggles ') {
updateNotice(testRaw[1], testRaw[2]);
}
if (byteCount(rawMessage) > 250 && name != '') {
message = '<span style="color: #800">(removed)</span>';
test = '';
rawMessage = '';
}
if (test[0] !== undefined && test[0].toLowerCase() == '​$r​o​l​l' && test.length > 1 && userStyleList.indexOf(usernameClass) > -1 && test[test.length - 1] == '​' && showRoll) {
var rolledNumber = test[test.length - 2];
if (rolledNumber.length > 10) {
rolledNumber = rolledNumber.slice(0, 10);
}
test[test.length - 2] = '';
if (rolledNumber == parseInt(rolledNumber)) {
var dubslist = ['00','11','22','33','44','55','66','77','88','99'];
if ($.inArray(rolledNumber, dubslist) > -1) var numColor = '#f90'; else var numColor = '#005cff';
rollString = '<span class="gm rollstr"> ' + user.username + ' rolled <span style="color:' + numColor + '; font-weight: bold; font-style: normal">' + rolledNumber + ' </span><br />';
}
} else if (test[0] !== undefined && test[0].toLowerCase() == '​$8​b​a​l​l' && test.length > 1 && userStyleList.indexOf(usernameClass) > -1 && test[test.length - 1] == '​' && showRoll) {
var answer = ballTest[ballTest.length - 2];
ballTest[ballTest.length - 2] = '';
test = ballTest;
ballString = '<span class="gm ballstr"> ' + user.username + ': 8ball says, <span style="color:#f00; font-weight: bold; font-style: normal">"' + answer + '" </span><br />';
}
message = test.join(' ');
if (userInfo.username.toLowerCase() !== '' && message.toLowerCase().indexOf(userInfo.username.toLowerCase()) > -1 && name !== '%addvideo') {
$(messageBox).addClass("mentionMsg");
}
if (message.substring(0,4) == "/me "){ //emote text
message = message['substring'](4);
message = checkEmote(message);
messageBox.append($("<span/>",{
"class":"metext",
"html":user.username + " " + message
}));
}
else if(message.substring(0, 4) == '>'){ //greentext
message = checkEmote(message);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
messageBox.append($("<span/>",{
"class":"text greentext",
"id":usernameId,
"html":message //convert to text when switching anti xss to client side
}));
}
else if(message[0] == '!'){ //urgenttext
message = checkEmote(message);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
messageBox.append($("<span/>",{
"class":"text urgenttext",
"id":usernameId,
"html":message //convert to text when switching anti xss to client side
}));
}
else if(message[0] == '~'){ //limetext
message = checkEmote(message);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
messageBox.append($("<span/>",{
"class":"text limeg",
"id":usernameId,
"html":message //convert to text when switching anti xss to client side
}));
}
else if (message[0] == "#"){ //hashtext
message = checkEmote(message);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
messageBox.append(($("<span/>",{
"class":"text hashtext",
"html":message //convert to text when switching anti xss to client side
})));
}
else if(message[0] == '/' && $codes[message.substring(1)] != undefined){ //emote
var emote = message['substring'](1);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
messageBox.append($("<span/>",{
"class":"",
"title": '/' + emote,
"html":$codes[emote]
}));
}
else{ //regular message
message = checkEmote(message);
messageBox.append($("<span/>", {
"class":"username "+usernameClass,
"id":usernameId,
"text":senderString
}));
var msg = $("<span/>",{
"class":"text "+extraStyles,
"html":message//switch this to text when switching to xss prevention client side
});
messageBox.append(msg);
}
$("#chat-messages").append(messageBox);
if (bumpTest[0] == '$bump' && isMod && name == userInfo.username.toLowerCase()) {
if (bumpTest.length == 3) {
bumpUser(bumpTest[1].toLowerCase(), bumpTest[2]);
} else if (bumpTest.length == 2) {
if (!isNaN(parseInt(bumpTest[1]))) {
bumpUser(userInfo.username.toLowerCase(), bumpTest[1]);
} else {
bumpUser(bumpTest[1].toLowerCase(), null);
}
} else if (bumpTest.length == 1) {
bumpUser(userInfo.username.toLowerCase(), null);
}
}
if (rollString !== undefined && parseInt(rollString) !== NaN && showRoll) {
$("#chat-messages").append(rollString);
}
if (ballString !== undefined && eight_choices.indexOf(answer) > -1 && showRoll) {
$("#chat-messages").append(ballString);
}
if (autoscroll === true) {
var textarea = document.getElementById('chat-messages');
textarea.scrollTop = textarea.scrollHeight;
}
if (!$('#cin').is(':focus') && newMsg == false) {
if (v4cm4c) setFavIcon('http://i.imgur.com/L4dvBOL.png'); else setFavIcon('http://i.imgur.com/XiBhO54.png');
newMsg = true;
document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
global.page.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
}
messages++;
cleanChat();
};
window.createPoll = function(poll) { //poll.title, poll.options = array of {option, votes}
$(".st-poll").css('display', '');
var c = poll.title.split(' ');
var a = '';
var b = '';
for (var i in c) {
c[i] = linkify(c[i], false, true);
}
poll.title = c.join(' ');
poll.title = checkEmote(poll.title);
if (poll.title.substring(0, 4) === '>')
a = 'greentext';
else if (poll.title[0] === '#')
a = 'hashtext';
else if (poll.title[0] === '!')
a = 'urgenttext';
else if (poll.title[0] === '|')
a = "spoiler";
else if (poll.title[0] === '~')
a = "limeg";
$('.poll-title').attr('class', 'poll-title');
$('.poll-title').attr('class', $('.poll-title').attr('class') + ' ' + a);
$(".poll-title").html(poll.title);
var choices = $(".poll-results.choices");
$(choices).empty();
for (var i = 0; i < poll.options.length; i++) {
var d = poll.options[i].option.split(' ');
for (var j in d) {
d[j] = linkify(d[j], false, true);
}
poll.options[i].option = d.join(' ');
poll.options[i].option = checkEmote(poll.options[i].option);
b = '';
if (poll.options[i].option.substring(0, 4) === '>')
b = 'greentext';
else if (poll.options[i].option[0] === '#')
b = 'hashtext';
else if (poll.options[i].option[0] === '!')
b = 'urgenttext';
else if (poll.options[i].option[0] === '|')
b = "spoiler";
else if (poll.options[i].option[0] === '~')
b = "limeg";
var choice =
$("<div/>", {
"class": "poll-item choice"
}).append($("<span/>", {
"class": "poll-vote-btn basic-btn vote_choice",
"html": poll.options[i].votes,
"data": {
option: i
},
"click": function() {
global.sendcmd("poll-vote", {
vote: $(this).data("option")
});
}
})).append($("<span/>", {
"class": "poll-vote-text " + b,
"html": (poll.options[i].option)
}));
$(choices).append(choice);
}
};
window.toggleScriptSetting = function(a,b,c) {
var toOn = false;
var toOff = false;
switch (a) {
case 'op-showadd':
logVids = !logVids;
if (logVids) {
toOn = true;
$.cookie('logvidSetting', '1');
} else {
toOff = true;
$.cookie('logvidSetting', '0');
}
break;
case 'op-showshadow':
mediashadow = !mediashadow;
if (mediashadow) {
toOn = true;
mediashadow = true;
$('#reload').click();
$.cookie('mshadSetting', '1');
} else {
toOff = true;
mediashadow = false;
$('#media').css('box-shadow', 'none');
$.cookie('mshadSetting', '0');
}
break;
case 'op-fastemote':
if (typeof($codes.fast) === 'string') {
toOff = true;
$.cookie('fastSetting', '0');
delete $codes.fast;
$('marquee').remove();
fastmsgs = 0;
} else {
toOn = true;
$.cookie('fastSetting', '1');
$.extend($codes, ({
'fast': '<marquee direction="right" scrollamount="' + marqueeSpeed + '">'
}));
}
break;
case 'op-showjoinleave':
logTraffic = !logTraffic;
if (logTraffic) {
toOn = true;
$.cookie('logsSetting', '1');
$('.logoutput').show();
} else {
toOff = true;
$.cookie('logsSetting', '0');
$('.logoutput').hide();
$('#logs').html('');
logs = 0;
}
break;
case 'op-showroll':
showRoll = !showRoll;
if (showRoll) {
toOn = true;
$.cookie('showRollSetting', '1');
} else {
toOff = true;
$.cookie('showRollSetting', '0');
}
break;
case 'op-filtergray':
filterGreyname = !filterGreyname;
if (filterGreyname) toOn = true;
else toOff = true;
break;
case 'op-sameuser':
sameUserMessages = !sameUserMessages;
if (sameUserMessages) {
toOn = true;
$.cookie('indentSameUser', '1');
} else {
toOff = true;
$.cookie('indentSameUser', '0');
}
break;
case 'op-autoclean':
if (isMod) {
toggleAutoClean();
if (autoClean) toOn = true;
else toOff = true;
}
break;
}
if (b == 'OptionsON' && toOff) {
$(c).removeClass('OptionsON');
$(c).addClass('OptionsOFF');
} else if (b == 'OptionsOFF' && toOn) {
$(c).removeClass('OptionsOFF');
$(c).addClass('OptionsON');
}
};
window.getPlaylist = function() { //heavily modified from Bibby's exportPlaylist() at https://github.com/Bibbytube/Instasynch under Playlist Additions/Export Playlist Command
var output = '';
var videoTitle = '';
for (i = 0; i < playlist.length; i++) {
if (playlist[i].title.length > 100) {
videoTitle = playlist[i].title.substring(0, 100);
videoTitle += '...';
} else {
videoTitle = playlist[i].title;
}
switch (playlist[i].info.provider) {
case 'youtube':
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=';
break;
case 'vimeo':
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/';
break;
case 'twitch':
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/';
break;
case 'dailymotion':
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/';
break;
default:
continue;
}
if (playlist[i].info.provider === 'twitch')
output += playlist[i].info.channel + '</a>\n<br />';
else
output += playlist[i].info.id + '</a>\n<br />';
}
var newWindow = window.open("", "_blank", "scrollbars=1,resizable=1");
newWindow.document.write('<span style="font-size: 16px; color: white">Select all (ctrl+a), copy/paste and save this somewhere.<br />Room: ' + ROOMNAME + '<br />Videos: ' + playlist.length + '</span><br /><br /><div id="playlistInfo" style="font-size: 12px; color: #84FFAB">' + output + '</div>');
newWindow.document.body.style.background = 'black';
newWindow.document.body.style.fontFamily = 'arial';
};
};
function buildEmoteMenu() {
loadedEmoteMenu = true;
var $newcodes = {
//modified original emotes
'chen': '<img src="http://i.imgur.com/j55EMQt.png" width="50" height="46" onclick="playSound(chenSound);">',
'doot': '<img src="http://i.imgur.com/WfUlQ5Q.gif" width="50" height="45" onclick="playSound(dootSound);">',
'bestgames': '<img src="http://i.imgur.com/ImyXj.png" width="48" height="54" onclick="playSound(chadSound);">',
'heero' : '<img src="http://i.imgur.com/D7JCR6j.png" width="60" height="55">',
'kek' : '<img src="http://i.imgur.com/xrw4paP.png" width="40" height="54">',
//additional emotes
'enjoytheanime' : '<img src="http://i.imgur.com/aXPWln0.png" width="48" height="60">',
'straya' : '<img src="http://i.imgur.com/PNB0kE9.gif" width="50" height="50">',
'neverever' : '<img src="http://i.imgur.com/MJnWGHV.png" width="52" height="50">',
'gud': '<img src="http://i.imgur.com/Ms3Zxne.png" width="75" height="60">'
};
$.extend($codes, $newcodes);
$colorcodes = {
"knuckles": '</span><span style="color:tomato">',
"mario": '</span><span style="color:red">',
"starfox": '</span><span style="color:brown">',
"tomnook": '</span><span style="color:chocolate">',
"crashbandicoot": '</span><span style="color:orange">',
"orange": '</span><span style="color:orange">',
"pacman": '</span><span style="color:yellow">',
"gex": '</span><span style="color:yellowgreen">',
"link": '</span><span style="color:green">',
"halo2": '</span><span style="color:darkgreen">',
"chao": '</span><span style="color:aqua">',
"squirtle": '</span><span style="color:cyan">',
"liara": '</span><span style="color:steelblue">',
"bluebomber": '</span><span style="color:royalblue">',
"sonic": '</span><span style="color:blue">',
"krystal": '</span><span style="color:darkblue">',
"bigthecat": '</span><span style="color:indigo">',
"nights": '</span><span style="color:purple">',
"spyro": '</span><span style="color:blueviolet">',
"birdo": '</span><span style="color:deeppink">',
"kirby": '</span><span style="color:violet">',
"wakeupmrfreeman": '</span><span style="color:tan">',
"tomba": '</span><span style="color:pink">',
"metalgear": '</span><span style="color:silver">',
"kidicarus": '</span><span style="color: white">',
"gamenwatch": '</span><span style="color: black">',
"outline": '<span style="text-shadow: 1px 0 #00ccff, -1px 0px #00ccff, 0 1px #00ccff, 0 -1px #00ccff">',
"redoutline" : '<span style="text-shadow: 1px 0 #f00, -1px 0px #f00, 0 1px #f00, 0 -1px #f00">',
"rainbowroad" : '</span><span class="rainbow">'
};
$fontcodes = {
"spoiler": '<font style="text-shadow: 0 0 black; background-color: #000; cursor: default" onmouseover="this.style.backgroundColor=\'transparent\'" onmouseout="this.style.backgroundColor=\'black\'">',
"i": '<font style="font-style:italic">',
"u": '<font style="text-decoration: underline">',
"b": '<strong>',
"s": '<strike>'
};
$endcodes = {
"endbold": '</strong>',
"endstrike": '</strike>',
"endspan": '</span></font></font></font>'
};
$(".stage").prepend('<div id="radiomenu"><form method="post" id="radios"><div class="leftradio"><input type="radio" id=":" style="display: inline-block" name="a" value="0" checked="checked"><label for=":">:</label></div>Emote Style <div class="rightradio"><input type="radio" value="1" id="/" name="a"><label for="/">/</label></div> </form></div><div id="curtain"></div>');
var emoteMenu,code;
emoteMenu = code = '';
$.each($codes, function(code, image) {
if (code != 'fast') {
emoteMenu = emoteMenu + '<a title="' + code + '" onclick="useEmote(\'' + code + '\')">' + image + '</a>';
}
});
$.each($colorcodes, function(code, bgcolor) {
if (code !== 'rainbowroad') {
if (code == 'outline') {
bgcolor = 'color: black;box-shadow: 0 0 15px #00ccff inset';
} else if (code == 'redoutline') {
bgcolor = 'color: black;box-shadow: 0 0 15px #f00 inset';
} else {
bgcolor = bgcolor.slice(20, -2);
}
emoteMenu = emoteMenu + '<div class="colors" title="' + code + '" style="background-' + bgcolor + '" onclick="useEmote(\'' + code + '\')"></div>';
}
});
$.each($fontcodes, function(code, fontc) {
if (code == 'b') {
endtag = '</strong>';
} else if (code == 's') {
endtag = '</strike>';
} else {
endtag = '</font>';
}
emoteMenu = emoteMenu + '<div class="colors" title="' + code + '" onclick="useEmote(\'' + code + '\')">' + fontc.slice(0, -1) + ' class="' + code + '">' + endtag + '</div>';
});
$.each($endcodes, function(code, endc) {
if (code == 'endbold') {
endtag = '</strong>';
} else if (code == 'endstrike') {
endtag = '</strike>';
} else {
endtag = '</font>';
}
if (code == 'endstrike') {
endc = '<strike>';
} else if (code == 'endbold') {
endc = '<strong>';
} else {
endc = '<font>';
}
emoteMenu = emoteMenu + '<div class="colors" title="' + code + '" onclick="useEmote(\'' + code + '\')">' + endc.slice(0, -1) + ' class="' + code + '">' + endtag + '</div>';
});
$('<div id="facecodesmenu"></div>').insertBefore('.users');
$('#facecodesmenu').append('<div id="emotes" style="display: inline-block">' + emoteMenu + '</div>');
$('#facecodesmenu #emotes').css('display', 'none');
$('.spoiler').html('Spoiler');
$('.i').html('Italics');
$('.s').html('Strikethrough');
$('.u').html('Underline');
$('strong.b').html('Bold');
$('.endbold').html('End Bold');
$('.endstrike').html('End Strikethrough');
$('.endspan').html('<span style="font-size:12px; font-style:italic">End i, u, spoiler, color</span>');
$.extend($codes, $colorcodes);
$.extend($codes, $fontcodes);
$.extend($codes, $endcodes);
};
function setCookies() {
loadedCookies = true;
$.lazyCookie('mshadSetting', '1', {
expires: 1234,
path: '/'
});
$.lazyCookie('logsSetting', '1', {
expires: 1234,
path: '/'
});
$.lazyCookie('logvidSetting', '1', {
expires: 1234,
path: '/'
});
$.lazyCookie('largePlayerSetting', '0', {
expires: 1234,
path: '/'
});
$.lazyCookie('fastSetting', '1', {
expires: 1234,
path: '/'
});
$.lazyCookie('showRollSetting', '1', {
expires: 1234,
path: '/'
});
$.lazyCookie('indentSameUser', '1', {
expires: 1234,
path: '/'
});
if ($.cookie('fastSetting') == '1')
$.extend($codes, ({
'fast': '<marquee direction="right" scrollamount="' + marqueeSpeed + '">'
}));
if ($.cookie('mshadSetting') === '1')
mediashadow = true;
else
mediashadow = false;
if ($.cookie('showRollSetting') === '1')
showRoll = true;
else
showRoll = false;
if ($.cookie('logvidSetting') === '1')
logVids = true;
else
logVids = false;
if ($.cookie('indentSameUser') === '1')
sameUserMessages = true;
else
sameUserMessages = false;
}
window.gmtClock = function() {
if (!loadedClock)
loadedClock = true;
var time = new Date();
var gmtTime = {hrs: time.getUTCHours(), min: time.getUTCMinutes(), sec: time.getUTCSeconds()}
for (var i in gmtTime) {
if (gmtTime.i < 10) gmtTime.i = "0" + gmtTime.i;
}
$('#gmtTime').text(gmtTime.hrs + ":" + gmtTime.min + ":" + gmtTime.sec + ' GMT');
setTimeout(function() {gmtClock()}, 1000);
};
function addChatListeners() {
loadedChatListeners = true;
$('#cin').keydown(function(e) {
if (e.which == 13) {
if ($('#cin').val() == "'autoclean" && isMod) {
toggleAutoClean();
}
if (byteCount($('#cin').val()) > 250) {
addMessage({username:''}, 'Message too large in size. Use less unicode characters. (' + byteCount($('#cin').val()) + ', max 250)', 'errortext');
return false;
}
var msgTest = $('#cin').val().split(' ');
if ($('#cin').val().slice(0, 9) == "'setskip " && !isNaN(parseInt(msgTest[1])) && msgTest[1] > -1 && isMod) {
addMessage({username:''}, 'Skip rate set to ' + msgTest[1] + '%.', 'hashtext');
}
if ($('#cin').val() == "'clear") {
clearChat();
}
if (msgTest[0].toLowerCase() == "'countvids" && msgTest[1] !== undefined) {
findUserVideos(msgTest[1]);
}
if (msgTest[0] == "​$r​o​l​l" || msgTest[0] == "​$8​b​a​l​l") {
return false;
}
if (msgTest[0].toLowerCase() === "$roll" && $.cookie("username") !== undefined) {
msgTest[0] = "​$r​o​l​l";
var numbers = 2;
if (msgTest.length > 1) {
var numTest = parseInt(msgTest[1]);
if (!isNaN(numTest) && numTest > 0 && numTest < 11) {
numbers = msgTest[1];
}
}
numbers = parseInt(numbers);
var numCount = "1".repeat(numbers);
numCount = parseInt(numCount) * 9 + 1;
var rollnum = "000000000" + Math.floor(Math.random() * numCount).toString();
rollnum = rollnum.slice(-numbers);
msgTest[msgTest.length] = rollnum;
msgTest[msgTest.length] = "​";
$('#cin').val(msgTest.join(" "));
}
if (msgTest[0].toLowerCase() === "$8ball" && $.cookie("username") !== undefined) {
eight_choices = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes - definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Signs point to yes",
"Yes",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
"Never",
"Of course not"
];
msgTest[0] = "​$8​b​a​l​l";
answer = eight_choices[Math.floor(Math.random() * eight_choices.length)];
msgTest[msgTest.length] = "|" + answer + "|";
msgTest[msgTest.length] = "​";
$('#cin').val(msgTest.join(" "));
}
}
});
}
function setHTML() {
loadedHTML = true;
var a = '';
var currentURL = $(location).attr('href').toLowerCase();
var topimg = $('#top.room-top img[src="/images/logoNoBG.png"]');
v4c = false;
v4cm4c = false;
if (currentURL.indexOf('v4c') > -1) {
//<img src="http://i.imgur.com/GHzt0IV.png">
$('.top-descr').html($('.top-descr').html().toLowerCase().replace('v4c\'s room', 'Vidya4chan'));
a = '<a href="http://v4c.fathax.com/v4c/" target="_blank"><span class="st-room-link st-room-link-boards"><font><font>Image Board </font></font></span></a><a href="http://instasynch.com/rooms/movie4chan" target="_blank"><span class="st-room-link st-room-link-movies"><font><font>Movie4chan</font></font></span></a><a id="tcButton" title="Password is \'v4c\'." href="http://tinychat.com/vidya4chans" target="_blank"><span class="st-room-link st-room-link-tc"><font><font>Tinychat </font></font></span></a>';
$('.roomFooter').html('<div class="description-title">About Vidya4chan</div><div class="description"><span style="color: #DA3231; font-weight: bold">No bump begging. No skip begging.</span> No skip trains. No static videos. No furry/MLP videos. Try to keep music videos to a minimum. Polls must pass 3:1. In the interests of keeping things running smoothly please don\'t add static videos or music unless it actually has a video to go with it.<br><span style="color:#789922">>unlike all the other rooms with power tripping mods.</span><br><br><strong style="text-align: center;display: block">Come and watch movies with v4c here!: <a href="http://instasynch.com/rooms/movie4chan" style="color: #36c">http://instasynch.com/rooms/movie4chan</a><br><span style="color:#DA3231;">WE CHAN NOW: </span><a href="http://v4c.fathax.com/v4c/" style="color: #36c">http://v4c.fathax.com/v4c/</a></strong></div></div>');
v4c = true;
v4cm4c = true;
} else if (currentURL.indexOf('movie4chan') > -1) {
$('.top-descr').html($('.top-descr').html().toLowerCase().replace('movie4chan\'s room', 'Movie4chan'));
a = '<a href="http://v4c.fathax.com/v4c/" target="_blank"><span class="st-room-link st-room-link-boards"><font><font>Image Board </font></font></span></a><a href="http://instasynch.com/rooms/v4c" target="_blank"><span class="st-room-link st-room-link-vidya"><font><font>Vidya4chan</font></font></span></a><a id="tcButton" title="Password is \'v4c\'." href="http://tinychat.com/vidya4chans" target="_blank"><span class="st-room-link st-room-link-tc"><font><font>Tinychat </font></font></span></a>';
$('.roomFooter').html('<div class="description-title">About Movie4chan</div><div class="description">Watch movies/documentaries with v4c users! Check out the chan for movie night threads: <a href="http://www.v4c.fathax.com/v4c/">http://www.v4c.fathax.com/v4c/</a><br><br><strong style="text-align: center;display: block">Return to Vidya4chan: <a href="http://instasynch.com/rooms/vidya4chan" style="color: #36c">http://instasynch.com/rooms/vidya4chan</a><br><span style="color:#DA3231;">WE CHAN NOW: </span><a href="http://v4c.fathax.com/v4c/" style="color: #36c">http://v4c.fathax.com/v4c/</a></strong></div></div>');
v4cm4c = true;
}
if (v4cm4c) {
setFavIcon('http://i.imgur.com/DmMh2O9.png');
topimg.css('margin-top', '5px');
topimg.width('84');
topimg.height('47');
topimg.attr('src', 'http://i.imgur.com/DlZXK.png');
$('.top-descr').prepend('<div class="st-descr-avatar" style="float: left;margin-right: 10px;"><img height="50" width="40" src="http://i.imgur.com/2ktlex7.png"></div>');
} else {
$('.poll-container').css('background', '');
}
while (/(\d+)(\d{3})/.test($('.descr-stat-value')[1].innerHTML)) { //stackoverflow
$('.descr-stat-value')[1].innerHTML = $('.descr-stat-value')[1].innerHTML.replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
}
var friendsList = $('.friendsList').detach();
var loginarea = $('#loginfrm').detach();
$('.container').prepend(friendsList);
$('.container').prepend('<div id="scriptOptions"><div id="optionLines"><span id="OptionsButton" class="sc-txt">Script Options</span><span id="OptionsVersion" class="sc-txt">1.84</span></div></div>');
$('.container').prepend(loginarea);
$('<div id="togglechat"><img src="http://i.imgur.com/EZ7DAGs.png"></div><div id="togglevideo"></div><div id="gmtTime"></div>').insertAfter('.playlist-controls .controls .settings');
($('#lead').detach()).insertBefore('.st-poll');
($('#unlead').detach()).insertBefore('.st-poll');
($('#create-pollBtn').detach()).insertBefore('.st-poll');
$('#lead').text('Lead');
$('#create-pollBtn.mod').text('Poll');
$('#title.formbox').width('374px');
$('.formbox.create-poll-option').width('374px');
$('#resynch').text('Resynch Video');
$('#reload').text('Reload Media');
$('#playlist-settings-menu').append('<div class="menu-split"></div><li id="getplist">Get Playlist Info</li><li id="gethistory">View Video History</li><li id="hardrefresh" onclick="document.location.reload(true)">Hard Refresh</li>');
$('.counter').children().eq(0).addClass('invisible-item-script');
$('#chat .left').prepend('<div id="chatcontrols"><img id="chatcog" class="settings toggle" src="/images/gear.png" height="16" width="16"><img id="emmenu" class="settings toggle" height="24" src="http://i.imgur.com/vETtK.png" width="16" onclick="expandEmotes();"></div>');
$('<br /><div class="st-room-links"><a id="st-live-room"><span class="st-room-link st-room-link-live st-room-link-active"><font><font>Live </font></font></span></a>' + a + '</div>').insertBefore($('.descr-stats'));
$('.stage').prepend('<div class="logoutput" style="width: 120px;position: absolute;height: 48px;color: green;margin-top: -49px;font-size: 12px;overflow: hidden;"><div id="logs"></div></div>');
$('#create-poll').append('<button id="clear-options">Clear Options</button>');
$('.poll-container').append('<ul id="viewHistory" style="display: none"><div class="close-history x" onclick="$(\'#gethistory\').click();"></div></ul>');
$('.left').prepend('<div id="newUpdate">New script version: update through your browser\'s plugin!</div>');
$('<div class="players"><div id="players">layout: <a class="normal" href="#">normal</a> <a class="large" href="#">large</a> <a class="larger" href="#">larger</a>').insertAfter('.stage');
$('#unlead').attr('class', 'mod');
$('#logs').html('');
$('#add-friend').parent().parent().css('display', 'none');
$('<li><div><div class="category sAddFriend" onclick="$(\'#add-friend\').click()">Add a Friend</div></div></li>').appendTo('.friendsList-list');
$('.clicker#myName').append('<img src="http://i.imgur.com/kB8y50I.png" class="arrowDown">');
$('body').prepend('<div id="OptionsMenu"><div class="close-OptionMenu x"></div><div id="OptionsTop"><div id="OptionsTopImage"></div><strong>v4c\'s InstaSynch Addon Script</strong><span class="OptionsVersion"></span></div><div id="OptionsBottom"><ul id="OptionsList"><div class="op-seperator">Toggles</div><li id="op-showadd"><div class="OptionsSetting"></div>Show Video Add Messages<div class="OptionsButton">Toggle</div></li><li id="op-showshadow"><div class="OptionsSetting"></div>Display Video Source Shadow<div class="OptionsButton">Toggle</div></li><li id="op-fastemote"><div class="OptionsSetting"></div>:fast: Emote<div class="OptionsButton">Toggle</div></li><li id="op-showjoinleave"><div class="OptionsSetting"></div>Display User Join/Leave Log<div class="OptionsButton">Toggle</div></li><li id="op-showroll"><div class="OptionsSetting"></div>Display $roll and $8ball Messages<div class="OptionsButton">Toggle</div></li><li id="op-filtergray"><div class="OptionsSetting"></div>Filter Unregistered Messages<div class="OptionsButton">Toggle</div></li><li id="op-autoclean"><div class="OptionsSetting"></div>Playlist Autoclean<div class="OptionsButton">Toggle</div></li><li id="op-sameuser"><div class="OptionsSetting"></div>Indent Same-User Messages<div class="OptionsButton">Toggle</div></li><li id="op-defqual"><div class="OptionsSetting"></div>Default Video Quality (no function yet)</li><div class="op-seperator">Functions</div><li id="op-button" onclick="clearChat()">Clear All Chat Messages</li><br /><li id="op-button" onclick="showChangelog()">Show Changelog in Chat</li><div class="op-seperator">Variables</div><li class="op-var">:fast: Scroll Speed <input id="marqueeinput" value="50" size="2" type="text" max="99" maxlength="3" onkeyup="setFast($(this).val())"></li><div class="op-seperator">Styles</div><li id="op-style">Player Button Color <input id="pickerButtons" size="6" value="CCCCCC" onchange="updateColor(\'pickerButtons\', $(this).val())"></li><li id="op-style">Slider Handle Color <input id="pickerHandles" size="6" value="CCCCCC" onchange="updateColor(\'pickerHandles\', $(this).val())"></li><li id="op-style">Progress Bar Color <input id="pickerProgress" size="6" value="66A8CC" onchange="updateColor(\'pickerProgress\', $(this).val())"></li><li id="op-style">Player Text Color <input id="pickerText" size="6" value="CCCCCC" onchange="updateColor(\'pickerText\', $(this).val())"></li></ul></div><div id="OptionsBottomKey"><div id="OptionsKeyLeft"><div class="OptionsON"></div> = on; <div class="OptionsOFF"></div> = off; <div class="OptionsDisabled"></div> = disabled</div><div id="OptionsKeyRight">script created by biggles</div></div></div>');
if ($.cookie('logsSetting') === '0') {
$('.logoutput').hide();
logTraffic = false;
$('#logs').html('');
}
for (var i = 0; i < playlist.length; i++) {
$('.duration')[i].innerHTML = secondsToTime(playlist[i].duration);
if (playlist[i].info.provider == 'twitch') {
$('.duration')[i].innerHTML = 'Twitch Stream'
}
}
if (userInfo.loggedin) {
for (var q = 0; q < users.length; q++) {
if ($('.users li')[q].textContent.toLowerCase() == userInfo.username.toLowerCase()) {
var userMe = $('.users li').eq(q);
userMe.attr('id', 'me');
break;
}
}
}
getUserInfo(userInfo.username, function(avatar) {
var profimg = $('.clicker#myName img')[0];
profimg.src = avatar;
$(profimg).attr('width', '24');
$(profimg).attr('height', '24');
});
$('.OptionsVersion').text(scriptVer);
$('#OptionsVersion.sc-txt').text(scriptVer);
for (var i = 0; i < $('.OptionsSetting').length; i++) {
var op = $('.OptionsSetting')[i];
switch (op.parentNode.id) {
case 'op-showadd':
if (logVids)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-showshadow':
if (mediashadow)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-fastemote':
if (typeof($codes.fast !== 'undefined'))
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-showjoinleave':
if (logTraffic)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-showroll':
if (showRoll)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-filtergray':
if (filterGreyname)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-autoclean':
if (autoClean && isMod)
$(op).addClass('OptionsON');
else if (!autoClean && isMod)
$(op).addClass('OptionsOFF');
else if (!isMod)
$(op).addClass('OptionsDisabled');
break;
case 'op-sameuser':
if (sameUserMessages)
$(op).addClass('OptionsON');
else
$(op).addClass('OptionsOFF');
break;
case 'op-defqual':
$(op).addClass('OptionsDisabled');
break;
}
}
updateRecent($('.video.active').index());
window.buttonPicker = new jscolor.color(document.getElementById('pickerButtons'), {});
window.progressPicker = new jscolor.color(document.getElementById('pickerProgress'), {});
window.textPicker = new jscolor.color(document.getElementById('pickerText'), {});
window.handlesPicker = new jscolor.color(document.getElementById('pickerHandles'), {});
$('#togglechat').tipTip({
content: "Toggle Chat",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "left"
});
$('#chatcog').tipTip({
content: "Settings Menu",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "left"
});
$('#emmenu').tipTip({
content: "Emote Menu",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "left"
});
$('.rightradio').tipTip({
content: "Use \'/emote\' Viewable by all, but follows the standard rule of 1 per message. Note: Clears your text box",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "top"
});
$('.leftradio').tipTip({
content: "Use \':emote:\' Viewable by those who use the script only, but can be used " + maxemotes + " times per line with text.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "top"
});
$('#menu-save').tipTip({
content: "<span style='color: #006bfe'>Saves the current playlist.</span>",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#resynch').tipTip({
content: "Changes the time of the video to match the server's position.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#reload').tipTip({
content: "Kills and reloads the video without refreshing.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#getplist').tipTip({
content: "Opens a new window containing the current playlist information (video links, contributors, etc). <span style='color:red'>Pop-up.</span>",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#gethistory').tipTip({
content: "Toggle. Lets you view the last 12 videos you've watched. <span style='color:lime'>Appears under the poll area.</span>",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#togglesearchbox').tipTip({
content: "Opens up a movable box. Searches youtube for the search query in the Add Video text box.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#hardrefresh').tipTip({
content: "Refreshes the page ignoring all locally cached files, forcing a reload of all site files. Does not clear cache.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "right"
});
$('#setQuality').tipTip({
content: "List of available default quality settings for YouTube videos. When changed, the video will begin to switch to that quality, and the setting will be stored in a cookie.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "left"
});
$('#togglevideo').tipTip({
content: "Drops a \"curtain\" over the currently playing video. Toggle.",
fadeIn: 0,
fadeOut: 0,
defaultPosition: "left"
});
};
function setBinds() {
loadedBinds = true;
$('#skip').click(function() {
$('#skip-count').attr('style', 'color: #3F0!important');
});
$('#scriptOptions').click(function() {
$('#OptionsMenu').toggle();
});
$('#tcButton').click(function() {
alert('The password to the room is \'v4c\'.');
});
$('#players a.normal').on('click', function() {
if (largePlayer || largerPlayer)
switchResolution(0);
else return false;
});
$('#players a.large').on('click', function() {
if (!largePlayer || largerPlayer)
switchResolution(1);
else return false;
});
$('#players a.larger').on('click', function() {
if (largePlayer || !largerPlayer)
switchResolution(2);
else return false;
});
if (largePlayer && !largerPlayer) {
$('#players a.large').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.large').attr('href', null);
} else if (largerPlayer && !largePlayer) {
$('#players a.larger').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.larger').attr('href', null);
} else if (!largePlayer && !largerPlayer) {
$('#players a.normal').attr('style', 'color: white!important; text-decoration: none!important');
$('#players a.normal').attr('href', null);
}
$('#chat-messages').unbind('scroll');
//(C) BibbyTube, (C) Faqqq
//https://github.com/Bibbytube/Instasynch/blob/master/Chat%20Additions/Autoscroll%20Fix/autoscrollFix.js
//from instasynch's io.js with modified height multiplier
$('#chat-messages').on('scroll', function() {
var scrollHeight = $(this)[0].scrollHeight,
scrollTop = $(this).scrollTop(),
height = $(this).height();
//scrollHeight - scrollTop will be 290 when the scrollbar is at the bottom
//height of the chat window is 280, not sure where the 10 is from
if ((scrollHeight - scrollTop) < height * 2.5) {
autoscroll = true;
} else {
autoscroll = false;
}
});
$('#lead').click(function() {
if (isMod) {
$('#unlead').css('visibility', 'visible');
$('#playlistcontrols').height('49px');
$('.stage').stop().animate({
height: stageBase + $('#playlistcontrols').height() + 'px'
}, 200)
}
});
$('#unlead').click(function() {
if (isMod) {
$('#playlistcontrols').height('25px');
$('.stage').stop().animate({
height: stageBase + 'px'
}, 200)
}
});
$('.close-OptionMenu.x').click(function() {
$('#OptionsMenu').hide();
});
$("#add-option").click(function() {
if ($('.create-poll-option').length >= 10) {
$('#add-option').attr('disabled', 'true');
$('#add-option').text('Max options! (10)');
}
});
$('#getplist').click(function() {
getPlaylist();
});
$('#gethistory').click(function() {
if (recentVidInfo.length > 0) {
$('#viewHistory').toggle();
if ($('#viewHistory').css('display') !== 'none') {
viewHistory(recentVidInfo);
} else if ($('#viewHistory').css('display') === 'none') {
$('#viewHistory').empty();
}
}
});
$('#cin').focus(function() {
if (v4cm4c) setFavIcon('http://i.imgur.com/DmMh2O9.png'); else setFavIcon('/favicon.ico');
document.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
global.page.title = decodeURIComponent('%E2%96%B6') + ' ' + currentVid;
newMsg = false;
});
$('#submit-poll').click(function() {
$('#create-poll').hide();
});
$('#togglechat').click(function() {
var fcm = $('#facecodesmenu');
if (fcm.css('display') != 'none' ) {
expandEmotes();
}
$('.logoutput').toggle();
$('#chat').toggle();
});
$('#togglevideo').click(function() {
var ctn = $('#curtain');
if (ctn.css('height') == '0px' || ctn.css('height') == 0) {
$('#curtain').height($('#media').css('height'));
} else {
$('#curtain').height('0px');
}
});
$('#chatcog').click(function() {
addMessage({username: ''}, 'There is no longer a chat menu. The settings have been moved to the Script Options menu. Click the button at the top of the page to open it.', 'system');
});
$('#add-option').click(function() {
$('.formbox.create-poll-option').width('374px');
});
$('#clear-options').click(function() {
$('#create-poll input').val('');
});
$("#URLinput").keyup(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
$("#addUrl").click();
}
});
$("html").keyup(function(event) {
if (event.keyCode == 118 && v4cm4c) { //F7
event.preventDefault();
$('.poll-container').css('background', 'url("http://drowngaben.x10.mx/v4c/rotate/")');
}
if (event.keyCode == 120) { //F9
event.preventDefault();
$("#emmenu").click();
}
});
$('.click-nav .js').unbind('click');
$('.click-nav .js').click(function() {
var userMenu = $('#loggedInAs .click-nav .js li ul');
if (userMenu.height() !== 0)
userMenu.attr('style', 'height: 0px');
else userMenu.attr('style', 'height: 128px');
});
$('.OptionsButton').click(function() {
var buttonid = this.parentNode.id;
var optionstate = $(this).parent()[0].firstChild.className.split(' ')[1];
var imgdiv = $(this).parent()[0].firstChild;
toggleScriptSetting(buttonid, optionstate, imgdiv);
});
};
postConnect.push(loadGlobalVariables);
postConnect.push(loadFunctions);
postConnect.push(setCookies);
postConnect.push(buildEmoteMenu);
postConnect.push(setHTML);
postConnect.push(addChatListeners);
postConnect.push(loadCSS);
postConnect.push(setBinds);
postConnect.push(gmtClock);
postConnect.push(connected);
postConnectDo();
console.log('Reached end of script.');
window.errors = function() {
var errorMessage = '<div class="message urgenttext" style="background-color: black; font-weight: bold">Failed to load: ';
var errorList = '';
if (typeof(scriptVer) === 'undefined')
scriptVer = 'undefined';
if (!loadedFunctions) {
errorList += 'functions, ';
console.error(scriptVer + ': Failed to load functions');
}
if (!loadedGlobalVariables) {
errorList += 'globalVariables, ';
console.error(scriptVer + ': Failed to load global variables');
}
if (!loadedCSS) {
errorList += 'CSS, ';
console.error(scriptVer + ': Failed to load CSS');
}
if (!loadedConnected) {
errorList += 'connected, ';
console.error(scriptVer + ': Failed to load function "connected"');
}
if (!loadedCookies) {
errorList += 'cookies, ';
console.error(scriptVer + ': Failed to load cookies');
}
if (!loadedClock) {
errorList += 'gmtClock, ';
console.error(scriptVer + ': Failed to load GMT clock');
}
if (!loadedChatListeners) {
errorList += 'chatEvents, ';
console.error(scriptVer + ': Failed to load chat event listeners');
}
if (!loadedEmoteMenu) {
errorList += 'emotes, ';
console.error(scriptVer + ': Failed to load emote system');
}
if (!loadedHTML) {
errorList += 'HTML, ';
console.error(scriptVer + ': Failed to load HTML');
}
if (!loadedBinds) {
errorList += 'binds, ';
console.error(scriptVer + ': Failed to load HTML binds');
}
if (errorList == '') {
errorList = '<span style="color: lime">none</span>';
console.log('Seems like everything has loaded.')
}
errorMessage += errorList;
errorMessage += '</div>';
$('#chat-messages').append(errorMessage);
};
});
//if something is wrong, try typing errors() in the console