2022-01-22 17:42:39 +00:00
|
|
|
/*eslint no-unused-vars: "off"*/
|
2014-02-25 00:25:49 +00:00
|
|
|
var CL_VERSION = 3.0;
|
2017-12-27 04:40:12 +00:00
|
|
|
var GS_VERSION = 1.7; // Google Drive Userscript
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
var CLIENT = {
|
|
|
|
rank: -1,
|
|
|
|
leader: false,
|
|
|
|
name: "",
|
|
|
|
logged_in: false,
|
|
|
|
profile: {
|
|
|
|
image: "",
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
};
|
2013-07-13 20:15:57 +00:00
|
|
|
var SUPERADMIN = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
var CHANNEL = {
|
|
|
|
opts: {},
|
|
|
|
openqueue: false,
|
|
|
|
perms: {},
|
|
|
|
css: "",
|
|
|
|
js: "",
|
|
|
|
motd: "",
|
2017-06-16 07:16:59 +00:00
|
|
|
name: CHANNELNAME,
|
2014-02-10 05:53:46 +00:00
|
|
|
usercount: 0,
|
|
|
|
emotes: []
|
2013-06-19 23:39:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var PLAYER = false;
|
2015-07-05 21:00:59 +00:00
|
|
|
var LIVESTREAM_CHROMELESS = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var FLUIDLAYOUT = false;
|
2013-08-05 04:51:28 +00:00
|
|
|
var VWIDTH;
|
|
|
|
var VHEIGHT;
|
|
|
|
if($("#videowidth").length > 0) {
|
|
|
|
VWIDTH = $("#videowidth").css("width").replace("px", "");
|
|
|
|
VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
|
|
|
|
}
|
2013-06-25 02:45:44 +00:00
|
|
|
var REBUILDING = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var socket = {
|
|
|
|
emit: function() {
|
|
|
|
console.log("socket not initialized");
|
|
|
|
console.log(arguments);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var CHATHIST = [];
|
|
|
|
var CHATHISTIDX = 0;
|
2013-11-19 21:14:40 +00:00
|
|
|
var CHATTHROTTLE = false;
|
2015-06-04 04:57:51 +00:00
|
|
|
var CHATMAXSIZE = 100;
|
2013-06-19 23:39:40 +00:00
|
|
|
var SCROLLCHAT = true;
|
2015-12-06 01:57:33 +00:00
|
|
|
var IGNORE_SCROLL_EVENT = false;
|
2014-02-15 07:40:14 +00:00
|
|
|
var LASTCHAT = {
|
|
|
|
name: ""
|
|
|
|
};
|
2013-06-19 23:39:40 +00:00
|
|
|
var FOCUSED = true;
|
|
|
|
var PAGETITLE = "CyTube";
|
|
|
|
var TITLE_BLINK;
|
2014-02-24 05:27:07 +00:00
|
|
|
var CHATSOUND = new Audio("/boop.wav");
|
2013-06-19 23:39:40 +00:00
|
|
|
var KICKED = false;
|
|
|
|
var NAME = readCookie("cytube_uname");
|
|
|
|
var SESSION = readCookie("cytube_session");
|
|
|
|
var LEADTMR = false;
|
2013-06-27 22:15:29 +00:00
|
|
|
var PL_FROM = "";
|
|
|
|
var PL_AFTER = "";
|
2013-09-11 03:43:43 +00:00
|
|
|
var PL_CURRENT = -1;
|
2013-07-27 14:30:12 +00:00
|
|
|
var PL_WAIT_SCROLL = false;
|
2013-06-19 23:39:40 +00:00
|
|
|
var FILTER_FROM = 0;
|
|
|
|
var FILTER_TO = 0;
|
2013-07-03 02:40:40 +00:00
|
|
|
var NO_STORAGE = typeof localStorage == "undefined" || localStorage === null;
|
2016-06-08 06:00:50 +00:00
|
|
|
var SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
2016-06-09 05:58:34 +00:00
|
|
|
var HAS_CONNECTED_BEFORE = false;
|
2016-07-12 05:19:39 +00:00
|
|
|
var IMAGE_MATCH = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gi;
|
2017-01-07 04:10:33 +00:00
|
|
|
var CyTube = {};
|
2017-07-22 17:35:45 +00:00
|
|
|
CyTube.ui = {
|
|
|
|
suppressedAnnouncementId: getOpt("suppressed_announcement_id")
|
|
|
|
};
|
2017-03-02 05:16:55 +00:00
|
|
|
CyTube.featureFlag = {
|
2017-08-05 19:22:58 +00:00
|
|
|
efficientEmotes: true
|
2017-03-02 05:16:55 +00:00
|
|
|
};
|
2018-10-22 05:12:49 +00:00
|
|
|
CyTube.channelCustomizations = {
|
|
|
|
cssHash: null,
|
|
|
|
jsHash: null
|
|
|
|
};
|
2018-05-25 06:49:28 +00:00
|
|
|
CyTube._internal_do_not_use_or_you_will_be_banned = {};
|
2013-07-03 02:40:40 +00:00
|
|
|
|
|
|
|
function getOpt(k) {
|
2014-07-02 03:11:54 +00:00
|
|
|
var v = NO_STORAGE ? readCookie(k) : localStorage.getItem(k);
|
|
|
|
try {
|
|
|
|
v = JSON.parse(v);
|
|
|
|
} catch (e) { }
|
|
|
|
return v;
|
2013-07-03 02:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setOpt(k, v) {
|
2014-07-02 03:11:54 +00:00
|
|
|
v = JSON.stringify(v);
|
2013-07-03 02:40:40 +00:00
|
|
|
NO_STORAGE ? createCookie(k, v, 1000) : localStorage.setItem(k, v);
|
|
|
|
}
|
2013-06-19 23:39:40 +00:00
|
|
|
|
|
|
|
function getOrDefault(k, def) {
|
2013-07-03 02:40:40 +00:00
|
|
|
var v = getOpt(k);
|
2014-01-19 02:18:00 +00:00
|
|
|
if(v === null || v === "null")
|
2013-06-19 23:39:40 +00:00
|
|
|
return def;
|
|
|
|
if(v === "true")
|
|
|
|
return true;
|
|
|
|
if(v === "false")
|
|
|
|
return false;
|
2014-07-02 03:11:54 +00:00
|
|
|
if(v.match && v.match(/^[0-9]+$/))
|
2013-06-19 23:39:40 +00:00
|
|
|
return parseInt(v);
|
2014-07-02 03:11:54 +00:00
|
|
|
if(v.match && v.match(/^[0-9\.]+$/))
|
2013-06-19 23:39:40 +00:00
|
|
|
return parseFloat(v);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2019-02-24 05:23:21 +00:00
|
|
|
var IGNORED = getOrDefault("ignorelist", []);
|
|
|
|
|
2013-06-19 23:39:40 +00:00
|
|
|
var USEROPTS = {
|
2016-07-08 11:31:32 +00:00
|
|
|
theme : getOrDefault("theme", DEFAULT_THEME), // Set in head template
|
2014-02-25 00:25:49 +00:00
|
|
|
layout : getOrDefault("layout", "fluid"),
|
2013-06-20 20:50:12 +00:00
|
|
|
synch : getOrDefault("synch", true),
|
|
|
|
hidevid : getOrDefault("hidevid", false),
|
|
|
|
show_timestamps : getOrDefault("show_timestamps", true),
|
|
|
|
modhat : getOrDefault("modhat", false),
|
2014-05-26 20:22:20 +00:00
|
|
|
blink_title : getOrDefault("blink_title", "onlyping"),
|
2013-06-20 20:50:12 +00:00
|
|
|
sync_accuracy : getOrDefault("sync_accuracy", 2),
|
2013-08-06 15:42:20 +00:00
|
|
|
wmode_transparent : getOrDefault("wmode_transparent", true),
|
2013-06-20 20:50:12 +00:00
|
|
|
chatbtn : getOrDefault("chatbtn", false),
|
|
|
|
altsocket : getOrDefault("altsocket", false),
|
|
|
|
qbtn_hide : getOrDefault("qbtn_hide", false),
|
2013-06-20 22:15:35 +00:00
|
|
|
qbtn_idontlikechange : getOrDefault("qbtn_idontlikechange", false),
|
2013-06-26 02:03:14 +00:00
|
|
|
first_visit : getOrDefault("first_visit", true),
|
|
|
|
ignore_channelcss : getOrDefault("ignore_channelcss", false),
|
2013-08-11 21:39:10 +00:00
|
|
|
ignore_channeljs : getOrDefault("ignore_channeljs", false),
|
2014-02-18 00:56:36 +00:00
|
|
|
sort_rank : getOrDefault("sort_rank", true),
|
2013-08-15 04:26:50 +00:00
|
|
|
sort_afk : getOrDefault("sort_afk", false),
|
2015-05-02 22:55:00 +00:00
|
|
|
default_quality : getOrDefault("default_quality", "auto"),
|
2014-05-26 20:22:20 +00:00
|
|
|
boop : getOrDefault("boop", "never"),
|
2015-05-13 17:17:32 +00:00
|
|
|
show_shadowchat : getOrDefault("show_shadowchat", false),
|
2018-02-02 01:39:45 +00:00
|
|
|
emotelist_sort : getOrDefault("emotelist_sort", true),
|
2016-07-12 05:19:39 +00:00
|
|
|
no_emotes : getOrDefault("no_emotes", false),
|
2017-01-11 06:26:46 +00:00
|
|
|
strip_image : getOrDefault("strip_image", false),
|
2018-10-07 20:55:34 +00:00
|
|
|
chat_tab_method : getOrDefault("chat_tab_method", "Cycle options"),
|
2020-07-15 12:55:09 +00:00
|
|
|
notifications : getOrDefault("notifications", "never"),
|
|
|
|
show_ip_in_tooltip : getOrDefault("show_ip_in_tooltip", true)
|
2013-06-19 23:39:40 +00:00
|
|
|
};
|
|
|
|
|
2014-05-26 20:22:20 +00:00
|
|
|
/* Backwards compatibility check */
|
|
|
|
if (USEROPTS.blink_title === true) {
|
|
|
|
USEROPTS.blink_title = "always";
|
|
|
|
} else if (USEROPTS.blink_title === false) {
|
|
|
|
USEROPTS.blink_title = "onlyping";
|
|
|
|
}
|
|
|
|
/* Last ditch */
|
|
|
|
if (["never", "onlyping", "always"].indexOf(USEROPTS.blink_title) === -1) {
|
|
|
|
USEROPTS.blink_title = "onlyping";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (USEROPTS.boop === true) {
|
|
|
|
USEROPTS.boop = "onlyping";
|
|
|
|
} else if (USEROPTS.boop === false) {
|
|
|
|
USEROPTS.boop = "never";
|
|
|
|
}
|
|
|
|
if (["never", "onlyping", "always"].indexOf(USEROPTS.boop) === -1) {
|
|
|
|
USEROPTS.boop = "onlyping";
|
|
|
|
}
|
|
|
|
|
2015-05-02 22:55:00 +00:00
|
|
|
// As of 3.8, preferred quality names are different
|
|
|
|
(function () {
|
|
|
|
var fix = {
|
|
|
|
small: "240",
|
|
|
|
medium: "360",
|
|
|
|
large: "480",
|
|
|
|
hd720: "720",
|
|
|
|
hd1080: "1080",
|
|
|
|
highres: "best"
|
|
|
|
};
|
|
|
|
|
|
|
|
if (fix.hasOwnProperty(USEROPTS.default_quality)) {
|
|
|
|
USEROPTS.default_quality = fix[USEROPTS.default_quality];
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2014-02-03 02:04:50 +00:00
|
|
|
var VOLUME = parseFloat(getOrDefault("volume", 1));
|
|
|
|
|
2013-07-13 20:15:57 +00:00
|
|
|
var NO_WEBSOCKETS = USEROPTS.altsocket;
|
2014-02-03 02:04:50 +00:00
|
|
|
var NO_VIMEO = Boolean(location.host.match("cytu.be"));
|
2013-07-13 20:15:57 +00:00
|
|
|
|
2014-07-02 03:11:54 +00:00
|
|
|
var JSPREF = getOpt("channel_js_pref") || {};
|
2017-01-10 05:02:42 +00:00
|
|
|
// Dunno why this happens
|
|
|
|
if (typeof JSPREF !== "object" || JSPREF === null) {
|
|
|
|
try {
|
|
|
|
JSPREF = JSON.parse(JSPREF);
|
|
|
|
} catch (e) {
|
|
|
|
console.error("JSPREF is bugged: " + e + " (" + JSPREF + ")");
|
|
|
|
JSPREF = {};
|
|
|
|
setOpt("channel_js_pref", JSPREF);
|
|
|
|
}
|
|
|
|
}
|
2014-07-02 03:11:54 +00:00
|
|
|
|
2013-06-19 23:39:40 +00:00
|
|
|
var Rank = {
|
|
|
|
Guest: 0,
|
|
|
|
Member: 1,
|
|
|
|
Leader: 1.5,
|
|
|
|
Moderator: 2,
|
|
|
|
Admin: 3,
|
|
|
|
Owner: 10,
|
|
|
|
Siteadmin: 255
|
|
|
|
};
|
|
|
|
|
|
|
|
function createCookie(name,value,days) {
|
|
|
|
if (days) {
|
|
|
|
var date = new Date();
|
|
|
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
|
|
|
var expires = "; expires="+date.toGMTString();
|
|
|
|
}
|
|
|
|
else var expires = "";
|
|
|
|
document.cookie = name+"="+value+expires+"; path=/";
|
|
|
|
}
|
|
|
|
|
|
|
|
function readCookie(name) {
|
|
|
|
var nameEQ = name + "=";
|
|
|
|
var ca = document.cookie.split(";");
|
|
|
|
for(var i=0;i < ca.length;i++) {
|
|
|
|
var c = ca[i];
|
|
|
|
while (c.charAt(0)==" ") c = c.substring(1,c.length);
|
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function eraseCookie(name) {
|
|
|
|
createCookie(name,"",-1);
|
|
|
|
}
|
|
|
|
|
2014-02-25 00:25:49 +00:00
|
|
|
(function () {
|
|
|
|
var localVersion = parseFloat(getOpt("version"));
|
|
|
|
if (isNaN(localVersion)) {
|
2016-07-08 11:31:32 +00:00
|
|
|
USEROPTS.theme = DEFAULT_THEME;
|
2014-02-25 00:25:49 +00:00
|
|
|
USEROPTS.layout = "fluid";
|
2016-07-08 11:31:32 +00:00
|
|
|
setOpt("theme", DEFAULT_THEME);
|
2014-02-25 00:25:49 +00:00
|
|
|
setOpt("layout", "fluid");
|
|
|
|
setOpt("version", CL_VERSION);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2013-06-19 23:39:40 +00:00
|
|
|
/* to be implemented in callbacks.js */
|
|
|
|
function setupCallbacks() { }
|