Skip to content

Instantly share code, notes, and snippets.

@hasbromlp
Last active August 29, 2015 14:15
Show Gist options
  • Save hasbromlp/0967a72e109c6f67104a to your computer and use it in GitHub Desktop.
Save hasbromlp/0967a72e109c6f67104a to your computer and use it in GitHub Desktop.
test.js
/*
// CyTube Channel: MLP Anniversary Internal Script
//
// Written and maintained by Xaekai
*/
// -- Channel Namespace --
if (!this[CHANNEL.name])
this[CHANNEL.name] = {};
// -- Channel Branding --
if (!this[CHANNEL.name].branding) {
this[CHANNEL.name].branding = $('.navbar-brand').html('FireTube Inc');
}
// -- Channel Favicon --
if (!this[CHANNEL.name].favicon) {
this[CHANNEL.name].favicon = $('<link/>').prop('id', 'favicon').attr('rel', 'shortcut icon').attr('type', 'image/png').attr('sizes', '64x64').attr('href', 'http://i.imgur.com/tcK4Mbz.png').appendTo('head');
}
function generateLink(url, text) {
return '<a target="_blank" href="__url">__text</a>'.replace(/__url/, url).replace(/__text/, text);
}
$('.alert').remove()
makeAlert('Server Info', (''
+ 'You need to signup i broke the site. We also hve a radio witch can be found at the link down below that says "Radio"\n'
+ generateLink('http://radio.rickyfk.info', 'Radio') + '\n'
+ '').replace(/\n/g, '<br>')).appendTo('#announcements');
// -- Automessage on clear --
if (!this[CHANNEL.name].loaded_clearchat) {
this[CHANNEL.name].loaded_clearchat = true;
socket.on('clearchat', function () {
var data = {
time: Date.now(),
username: 'MLP Anniversary Chat',
msg: '<img class="pic_filter_s" src="http://i.imgur.com/quajcnG.png">',
meta: { shadow: false }
};
addChatMessage(data);
});
// wrap this one shot up here, lel lazy
socket.on('changeMedia', function () {
if (CHANNEL.opts.allow_voteskip)
$('#voteskip').attr('disabled', false);
});
}
// -- Scroll to bottom when going AFK
// -- or when images or links are posted
if (!this[CHANNEL.name].loaded_scroll) {
this[CHANNEL.name].loaded_scroll = true;
socket.on('setAFK', scrollChat);
socket.on('chatMsg', function (data) {
if (data.msg.indexOf('<a') != -1 || data.msg.indexOf('<img') != -1) {
setTimeout(scrollChat, 500);
}
});
}
/*
// Autoscroll Control Toggle
*/
if (!chatScrollControl)
var chatScrollControl = {};
if (!chatScrollControl.initialized) {
chatScrollControl.initialized = true;
chatScrollControl.toggle = true;
/*
// -- Normally there would be state persistence code included here.
// -- But in this case it makes no sense, Autoscroll should always default to on.
*/
// -- Create Toggle Button
chatScrollControl.button = $('<span/>').text('Autoscroll').prop('id', 'scrollChatToggle').addClass('pointer label label-info pull-right').appendTo($('#chatheader'));
// -- Button click
chatScrollControl.button.click(function () {
if (chatScrollControl.toggle) {
chatScrollControl.toggle = false;
chatScrollControl.button.addClass('label-default').removeClass('label-info');
} else {
chatScrollControl.toggle = true;
chatScrollControl.button.removeClass('label-default').addClass('label-info');
}
});
// replace the default scrollChat function
function scrollChat() {
if (!chatScrollControl.toggle) {
return;
}
$('#messagebuffer').scrollTop($('#messagebuffer').prop('scrollHeight'));
}
}
window[CHANNEL.name].VirtualWhisperOffset = 0;
window[CHANNEL.name].VirtualWhisperSync = function () {
socket.once('chatMsg', function (data) {
window[CHANNEL.name].VirtualWhisperOffset = Date.now() - data.time;
});
};
setTimeout(window[CHANNEL.name].VirtualWhisperSync, 2000);
setTimeout(window[CHANNEL.name].VirtualWhisperSync, 30000);
// -- Emulated Server Whisper --
window[CHANNEL.name].VirtualWhisper = function (msg) {
var data = {
time: Date.now() - window[CHANNEL.name].VirtualWhisperOffset,
username: '[server]',
msg: msg,
msgclass: 'server-whisper',
meta: {
shadow: false,
addClass: 'server-whisper',
addClassToNameAndTimestamp: true
}
};
addChatMessage(data);
};
this[CHANNEL.name].whisperUserLeave = function (data) {
window[CHANNEL.name].VirtualWhisper(data.name + ' disconnected');
};
this[CHANNEL.name].whisperUserJoin = function (data) {
window[CHANNEL.name].VirtualWhisper(data.name + ' joined');
};
if (!this[CHANNEL.name].loaded_whispers) {
this[CHANNEL.name].loaded_whispers = true;
socket.on('userLeave', function (data) {
window[CHANNEL.name].whisperUserLeave(data);
});
if (CLIENT.rank < 2) {
socket.on('addUser', function (data) {
window[CHANNEL.name].whisperUserJoin(data);
});
}
}
$('#imdb_wrap').remove();
$('#kickass_wrap').remove();
//$('#leftpane').append('<div id="imdb_wrap" class="form-group"><label for="imdb_search">Movie search</label><span id="imdb_search"></span></div>');
function injectIMDB() {
$('#imdb_query').remove();
//$('#imdb_search').html('<input id="imdb_query" type="text" placeholder="IMDB Search" maxlength="240" style="" class="form-control">');
$('#imdb_query').keydown(function (ev) {
if (ev.keyCode == 13) {
var query = $('#imdb_query').val().trim();
//var url = 'http://www.imdb.com/find?q=' + encodeURIComponent(query);
if (!query) {
return;
}
window.open(url, '_blank');
$('#imdb_query').val('');
}
});
}
setTimeout(injectIMDB, 2500);
//$('#leftpane').append('<div id="kickass_wrap" class="form-group"><label for="kickass_search">Torrent search</label><span id="kickass_search"></span></div>');
function injectKickass() {
$('#kickass_query').remove();
// $('#kickass_search').html('<input id="kickass_query" type="text" placeholder="Kickass Torrents Search" maxlength="240" style="" class="form-control">');
$('#kickass_query').keydown(function (ev) {
if (ev.keyCode == 13) {
//var query = $('#kickass_query').val().trim();
var url = 'https://kickass.to/usearch/__query/'.replace(/__query/, encodeURIComponent(query));
if (!query) {
return;
}
window.open(url, '_blank');
$('#kickass_query').val('');
}
});
}
setTimeout(injectKickass, 2700);
$('#4CC_wrap').remove();
/*
$('#leftpane').append('<div id="4CC_wrap" class="form-group"><iframe style="width: 100%; height: 600px;" src="http://www.twitch.tv/the4chancup/chat"></iframe></div>');
$('#motd').html('<div id="CAH_wrap" class="form-group"><iframe style="width: 100%; height: 800px;" src="http://cards.horses.sexy/#game=1"></iframe></div>');
*/
$('#scratchpad_wrap').remove();
$('#leftpane').append('<div id="scratchpad_wrap" class="form-group"><label for="scratchpad_container">Scratch pad</label><span id="scratchpad_container"></span></div>');
function injectScratchPad() {
$('#scratchpad_contents').remove();
$('#scratchpad_container').html('<textarea id="scratchpad_contents" placeholder="Page notes" rows="10" class="form-control"></textarea>');
if (typeof Storage !== 'undefined') {
if (localStorage[CHANNEL.name + '_scratchPad'] === undefined) {
localStorage[CHANNEL.name + '_scratchPad'] = '';
} else {
$('#scratchpad_contents').val(localStorage[CHANNEL.name + '_scratchPad']);
}
} else {
$('#scratchpad_contents').val("This browser doesn't support storage. The contents of this box won't be saved between refreshes.");
}
$('#scratchpad_contents').keyup(function () {
var box = $(this);
var key = box.attr('id').replace('cs-', '');
var value = box.val();
var lastkey = Date.now();
box.data('lastkey', lastkey);
// Wait for the user to stop typing
setTimeout(function () {
if (box.data('lastkey') !== lastkey || box.val() !== value) {
return;
}
// And then save the value
localStorage[CHANNEL.name + '_scratchPad'] = value;
console.log(value);
}, 1000);
});
}
;
setTimeout(injectScratchPad, 3000);
this[CHANNEL.name].external_scripts = {
'squee': 'https://dl.dropboxusercontent.com/s/3aebmn9xojb24o5/external_squee.js',
'hotkey': 'https://dl.dropboxusercontent.com/s/nslanwosnc1ocfj/external_hotkeys.js',
'emote': 'https://dl.dropboxusercontent.com/s/ozhmvowm4iatrnq/external_emotelist.js',
'guest': 'https://dl.dropboxusercontent.com/s/tde1eb30vdwdixs/external_assignguest.js'
};
if (!this[CHANNEL.name].loaded_squee) {
$.getScript(this[CHANNEL.name].external_scripts['squee'], function () {
window[CHANNEL.name].loaded_squee = true;
console.log('XaeMae ScriptLoad: squee ');
});
}
// -- Import Audio Notification
if (!this[CHANNEL.name].loaded_hotkeys) {
$.getScript(this[CHANNEL.name].external_scripts['hotkey'], function () {
window[CHANNEL.name].loaded_hotkeys = true;
console.log('XaeMae ScriptLoad: hotkeys ');
});
}
// -- Import Standard Hotkeys
//if ( !this[CHANNEL.name].loaded_emotelist ) { $.getScript( this[CHANNEL.name].external_scripts["emote"] , function(){window[CHANNEL.name].loaded_emotelist = true; console.log("XaeMae ScriptLoad: emotelist ")}); } // -- Import Embedded Emote List
//if ( !this[CHANNEL.name].loaded_guest ) { $.getScript( this[CHANNEL.name].external_scripts["guest"] , function(){window[CHANNEL.name].loaded_guest = true; console.log("XaeMae ScriptLoad: guest ")}); } // -- Import Automatic Guest Name Assignment
if (CLIENT.rank > 1) {
$.getScript('https://dl.dropboxusercontent.com/s/g1bwugpkt9g6071/external_text_emotes.js');
$.getScript('https://dl.dropboxusercontent.com/s/yavobtn2euschua/external_color_selector.js');
}
if (CLIENT.rank > -1) {
// -- Import Ponies
// -- This requires my server to be up, no point in putting this on dropbox.
// -- Best if placed before anything else that adds buttons below chat
if (!this[CHANNEL.name].loaded_cypony) {
this[CHANNEL.name].loaded_cypony = true;
$.getScript('http://67.171.154.99/xaekai/xaemae/node-avatar/nodeavatar_client.js');
}
}
$.getScript('https://dl.dropboxusercontent.com/s/onfehmhhz5l3qi1/external_sound_emotes.js');
$.getScript('https://dl.dropboxusercontent.com/s/aoan9gwlcfu75bx/external_extended_tab_complete.js');
$.getScript('https://dl.dropboxusercontent.com/s/uldol8q40o4d9op/external_blackmagic.js');
$.getScript('https://dl.dropboxusercontent.com/s/dl7m8qtvdhxi9jg/external_chat_avatars.js', function () {
chatAvatar.profilefallback = false;
});
$.getScript('https://dl.dropboxusercontent.com/s/rh5w64xzu85zmci/external_playlist_thumbnails.js');
$.getScript('https://dl.dropboxusercontent.com/s/it0hibj7f1ds47q/external_banners.js');
$.getScript('https://dl.dropboxusercontent.com/s/lsqn57ikvevbwa6/external_chat_color.js');
$.getScript('https://dl.dropboxusercontent.com/s/iex5dd8vyyn4axb/external_webm_embedding.js');
//$.getScript("https://dl.dropboxusercontent.com/s/gy0fnr19w7ltd75/external_espeak.js", function(){ espeak_toggle_button.click() })
true;
(function () {
$.getScript('https://dl.dropboxusercontent.com/s/yewfqd2s0s1tfjw/jquery.simplePagination.min.js', function () {
$.getScript('https://dl.dropboxusercontent.com/s/ozhmvowm4iatrnq/external_emotelist.js');
});
}());
function parseMediaLink(url){if(typeof url!="string"){return{id:null,type:null}}url=url.trim();url=url.replace("feature=player_embedded&","");if(url.indexOf("jw:")==0){return{id:url.substring(3),type:"jw"}}if(url.indexOf("rtmp://")==0){return{id:url,type:"rt"}}var m;if(m=url.match(/youtube\.com\/watch\?([^#]+)/)){return{id:extractQueryParam(m[1],"v"),type:"yt"}}if(m=url.match(/youtu\.be\/([^\?&#]+)/)){return{id:m[1],type:"yt"}}if(m=url.match(/youtube\.com\/playlist\?([^#]+)/)){return{id:extractQueryParam(m[1],"list"),type:"yp"}}if(m=url.match(/twitch\.tv\/([^\?&#]+)/)){return{id:m[1],type:"tw"}}if(m=url.match(/livestream\.com\/([^\?&#]+)/)){return{id:m[1],type:"li"}}if(m=url.match(/ustream\.tv\/([^\?&#]+)/)){return{id:m[1],type:"us"}}if(m=url.match(/vimeo\.com\/([^\?&#]+)/)){return{id:m[1],type:"vi"}}if(m=url.match(/dailymotion\.com\/video\/([^\?&#]+)/)){return{id:m[1],type:"dm"}}if(m=url.match(/imgur\.com\/a\/([^\?&#]+)/)){return{id:m[1],type:"im"}}if(m=url.match(/soundcloud\.com\/([^\?&#]+)/)){return{id:url,type:"sc"}}if(m=url.match(/(?:docs|drive)\.google\.com\/file\/d\/([^\/]*)/)){return{id:m[1],type:"gd"}}if(m=url.match(/plus\.google\.com\/(?:u\/\d+\/)?photos\/(\d+)\/albums\/(\d+)\/(\d+)/)){return{id:m[1]+"_"+m[2]+"_"+m[3],type:"gp"}}if(m=url.match(/(?:gp:)?(\d{21}_\d{19}_\d{19})/)){return{id:m[1],type:"gp"}}if(m=url.match(/hitbox\.tv\/([^\?&#]+)/)){return{id:m[1],type:"hb"}}var tmp=url.split("?")[0];if(tmp.match(/^https?:\/\//)){if(tmp.match(/\.(mp4|flv|webm|og[gv]|mp3|mov)$/)){return{id:url,type:"fi"}}else{Callbacks.queueFail({link:url,msg:"The file you are attempting to queue does not match the supported "+"file extensions mp4, flv, webm, ogg, ogv, mp3, mov."});throw new Error("ERROR_QUEUE_UNSUPPORTED_EXTENSION")}}return{id:null,type:null}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment