1.1-Indev Final commit before merging to master. Everything seems to

work fine, while being reasonably preformant and pretty.
This commit is contained in:
rainbownapkin 2022-08-29 00:06:44 +00:00
parent 85fbe6bb5a
commit adab2eb3f9
24 changed files with 25117 additions and 756 deletions

View file

@ -15,11 +15,12 @@ along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
*/ */
import fs from 'fs'; import fs from 'fs';
var InfoGetter = require ("../get-info"); const InfoGetter = require ("../get-info");
var ChannelModule = require("./module"); const XSS = require("../xss");
var Media = require("../media"); const ChannelModule = require("./module");
var util = require("../utilities"); const Media = require("../media");
var Server = require("../server"); const util = require("../utilities");
const Server = require("../server");
//type declerations //type declerations
const TYPE_NEWBUMP = { const TYPE_NEWBUMP = {
@ -304,6 +305,7 @@ AutobumpModule.prototype.onUserPostJoin = function (user){//on user join
user.socket.typecheckedOn("toggleRtoke", TYPE_DELBUMP, this.handleToggleRtoke.bind(this, user));//toggle rtoke user.socket.typecheckedOn("toggleRtoke", TYPE_DELBUMP, this.handleToggleRtoke.bind(this, user));//toggle rtoke
user.socket.typecheckedOn("toggleNoauto", TYPE_DELBUMP, this.handleToggleNoauto.bind(this, user));//toggle rtoke user.socket.typecheckedOn("toggleNoauto", TYPE_DELBUMP, this.handleToggleNoauto.bind(this, user));//toggle rtoke
user.socket.typecheckedOn("newBumplist", '', this.handleNewBumplist.bind(this, user));//handle newBumplist user.socket.typecheckedOn("newBumplist", '', this.handleNewBumplist.bind(this, user));//handle newBumplist
user.socket.typecheckedOn("cloneBumplist", '', this.handleCloneBumplist.bind(this, user));//handle newBumplist
user.socket.typecheckedOn("delBumplist", '', this.handleDelBumplist.bind(this, user));//handle newBumplist user.socket.typecheckedOn("delBumplist", '', this.handleDelBumplist.bind(this, user));//handle newBumplist
user.socket.typecheckedOn("renameBumplist", TYPE_LISTRENAME, this.handleRenameBumplist.bind(this, user));//handle newBumplist user.socket.typecheckedOn("renameBumplist", TYPE_LISTRENAME, this.handleRenameBumplist.bind(this, user));//handle newBumplist
user.socket.typecheckedOn("setActive", '', this.handleSetActive.bind(this, user));//handle newBumplist user.socket.typecheckedOn("setActive", '', this.handleSetActive.bind(this, user));//handle newBumplist
@ -463,12 +465,12 @@ AutobumpModule.prototype.roundRobin = function roundRobin(){
}); });
if(curin != null){//if we found an index if(curin != null){//if we found an index
if(alist.length <= curin + 1){//if we hit the end of the list if(alist.length <= curin + 1){//if we hit the end of the list
this.queueBump(alist[0].listname, alist[0].id);//wrap around list and queue from beggining this.queueBump(alist[0].listname, alist[0].id, true);//wrap around list and queue from beggining
}else{//otherwise }else{//otherwise
this.queueBump(alist[curin + 1].listname, alist[curin + 1].id);//queue next bump this.queueBump(alist[curin + 1].listname, alist[curin + 1].id, true);//queue next bump
} }
}else if(alist[0] != null){//or if we didnt }else if(alist[0] != null){//or if we didnt
this.queueBump(alist[0].listname, alist[0].id);//assume we haven't played anything and play the first bump in the list. this.queueBump(alist[0].listname, alist[0].id, true);//assume we haven't played anything and play the first bump in the list.
} }
}; };
@ -506,13 +508,13 @@ AutobumpModule.prototype.lastHalfRandom = function lastHalfRandom(){
AutobumpModule.prototype.handleQueueBump = function(user, data){ AutobumpModule.prototype.handleQueueBump = function(user, data){
if(user != null && user.account.effectiveRank >= 2){ if(user != null && user.account.effectiveRank >= 2){
this.queueBump(data.bl, data.id); this.queueBump(XSS.sanitizeText(data.bl), data.id);
} }
}; };
AutobumpModule.prototype.autobump = function(){ AutobumpModule.prototype.autobump = function(){
var bcount = randrange(this.bumpFreq[0], this.bumpFreq[1]); var bcount = randrange(this.bumpFreq[0], this.bumpFreq[1]);
if(this.channel.modules.playlist.current.media.seconds > this.minBump){//if current item is long enough to have a bump if(this.channel.modules.playlist.current.media.seconds > this.minBump || this.channel.modules.playlist.current.media.isBump){//if current item is long enough to have a bump (make an exception for bumps, so that we can queue infinite bumps at playlist end)
for(var i = 0; i < bcount; i++){//for bcount for(var i = 0; i < bcount; i++){//for bcount
this.selmed();//queue bump via selmed this.selmed();//queue bump via selmed
} }
@ -524,6 +526,7 @@ AutobumpModule.prototype.queueBump = function(listn, bid){//listname, bump ID
var bump = null; var bump = null;
var data = null; var data = null;
var _this = this; var _this = this;
var pbump = 'next';
if(list != null){//if bumplist exists if(list != null){//if bumplist exists
bump = list.bumps[bid] bump = list.bumps[bid]
@ -542,12 +545,17 @@ AutobumpModule.prototype.queueBump = function(listn, bid){//listname, bump ID
_this.sendHist(user); _this.sendHist(user);
}); });
if(this.channel.modules.playlist.current != null && this.channel.modules.playlist.current.next != null && this.channel.modules.playlist.current.next.media.isBump){
pbump = this.findBlockEnd(this.channel.modules.playlist.current.next).uid;
}
if(bump != null){ if(bump != null){
data = { //create faux data object for _addItem function data = { //create faux data object for _addItem function
id: bump.media.id, id: bump.media.id,
type: bump.media.type, type: bump.media.type,
pos: 'next', pos: pbump,
title: false, title: false,
subtitle: false, subtitle: false,
link: util.formatLink(bump.media.id, bump.media.type), link: util.formatLink(bump.media.id, bump.media.type),
@ -562,7 +570,7 @@ AutobumpModule.prototype.queueBump = function(listn, bid){//listname, bump ID
nmed.isBump = true; nmed.isBump = true;
nmed.tokeBump = bump.rtoke; nmed.tokeBump = bump.rtoke;
this.channel.modules.playlist._addItem(nmed, data, "autobump"); this.channel.modules.playlist._addItem(nmed, data, "autobump", null, true);
} }
} }
@ -722,13 +730,13 @@ AutobumpModule.prototype.handleSetMinBump = function(user, data){
//list management/commands //list management/commands
AutobumpModule.prototype.handleSetActive = function(user, data){ AutobumpModule.prototype.handleSetActive = function(user, data){
if(user != null && user.account.effectiveRank >= 2){ if(user != null && user.account.effectiveRank >= 2){
var bl = bumplists.get(data.toLowerCase().replace(lowerReg, "")); var bl = bumplists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""));
if(bl != null){//if bumplist exists if(bl != null){//if bumplist exists
if(this.activeLists.get(data.toLowerCase().replace(lowerReg, "")) != null){ if(this.activeLists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")) != null){
console.log("list already active"); console.log("list already active");
return; return;
} }
this.activeLists.set(data.toLowerCase().replace(lowerReg, ""), bl); this.activeLists.set(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""), bl);
} }
this.saveConfig(); this.saveConfig();
@ -737,8 +745,8 @@ AutobumpModule.prototype.handleSetActive = function(user, data){
AutobumpModule.prototype.handleRemoveActive = function(user, data){ AutobumpModule.prototype.handleRemoveActive = function(user, data){
if(user != null && user.account.effectiveRank >= 2){ if(user != null && user.account.effectiveRank >= 2){
if(this.activeLists.has(data.toLowerCase().replace(lowerReg, ""))){ if(this.activeLists.has(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""))){
this.activeLists.delete(data.toLowerCase().replace(lowerReg, "")); this.activeLists.delete(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""));
}else{ }else{
console.log("list not active!") console.log("list not active!")
} }
@ -821,14 +829,14 @@ AutobumpModule.prototype.sendConf = function(user){
AutobumpModule.prototype.handleNewBumplist = function(user, data){//handle newBumplist AutobumpModule.prototype.handleNewBumplist = function(user, data){//handle newBumplist
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
if(bumplists.get(data.toLowerCase().replace(lowerReg, "")) == null){ if(bumplists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")) == null){
bumplists.set(data.toLowerCase().replace(lowerReg, ""), new bumplist(data));//create new bumplist bumplists.set(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""), new bumplist(XSS.sanitizeText(data)));//create new bumplist
this.sendList(user,data.toLowerCase().replace(lowerReg, "")); this.sendList(user,XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""));
}else{ }else{
user.socket.emit("errorMsg", { user.socket.emit("errorMsg", {
msg: "Bumplist name taken: " + data.toLowerCase().replace(lowerReg, ""), msg: "Bumplist name taken: " + XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""),
alert: true alert: true
}); });
return; return;
@ -836,19 +844,43 @@ AutobumpModule.prototype.handleNewBumplist = function(user, data){//handle newBu
} }
}; };
AutobumpModule.prototype.handleCloneBumplist = function(user, data){//handle newBumplist
if(user.account.effectiveRank >= 2){
if(bumplists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")) == null){
var cbumps = [];
this.channel.modules.playlist.items.forEach(function(item){
var cbump = new bump(item.media.title, null, false, item.media, null, false);
cbump.listname = XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "");
cbump.id = cbumps.length;
cbumps.push(cbump);
});
var blist = new bumplist(XSS.sanitizeText(data), cbumps)
bumplists.set(blist.lowername, blist);//create new bumplist
blist.saveList();
}else{
user.socket.emit("errorMsg", {
msg: "Bumplist name taken: " + XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""),
alert: true
});
return;
}
}
}
AutobumpModule.prototype.handleRenameBumplist = function(user, data){//handle newBumplist AutobumpModule.prototype.handleRenameBumplist = function(user, data){//handle newBumplist
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
if(bumplists.get(data.oldname.toLowerCase().replace(lowerReg, "")) != null){ if(bumplists.get(XSS.sanitizeText(data.oldname).toLowerCase().replace(lowerReg, "")) != null){
var active = false; var active = false;
var _this = this; var _this = this;
var list = bumplists.get(data.oldname.toLowerCase().replace(lowerReg, "")); var list = bumplists.get(XSS.sanitizeText(data.oldname).toLowerCase().replace(lowerReg, ""));
if(active = this.activeLists.get(data.oldname.toLowerCase().replace(lowerReg, "")) != null) if(active = this.activeLists.get(XSS.sanitizeText(data.oldname).toLowerCase().replace(lowerReg, "")) != null)
this.activeLists.delete(data.oldname.toLowerCase().replace(lowerReg, "")); this.activeLists.delete(XSS.sanitizeText(data.oldname).toLowerCase().replace(lowerReg, ""));
list.rename(data.oldname, data.newname, function(){ list.rename(XSS.sanitizeText(data.oldname), XSS.sanitizeText(data.newname), function(){
if(active){ if(active){
_this.activeLists.set(data.newname.toLowerCase().replace(lowerReg, ""), list); _this.activeLists.set(XSS.sanitizeText(data.newname).toLowerCase().replace(lowerReg, ""), list);
_this.saveConfig(); _this.saveConfig();
} }
}); });
@ -856,7 +888,7 @@ AutobumpModule.prototype.handleRenameBumplist = function(user, data){//handle ne
}else{ }else{
user.socket.emit("errorMsg", { user.socket.emit("errorMsg", {
msg: "Non-Existant Bumplist: " + data.oldname.toLowerCase().replace(lowerReg, ""), msg: "Non-Existant Bumplist: " + XSS.sanitizeText(data.oldname).toLowerCase().replace(lowerReg, ""),
alert: true alert: true
}); });
} }
@ -866,14 +898,14 @@ AutobumpModule.prototype.handleRenameBumplist = function(user, data){//handle ne
AutobumpModule.prototype.handleDelBumplist = function(user, data){//handle newBumplist AutobumpModule.prototype.handleDelBumplist = function(user, data){//handle newBumplist
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
var active = false; var active = false;
if(bumplists.get(data.toLowerCase().replace(lowerReg, "")) != null){ if(bumplists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")) != null){
if(active = this.activeLists.get(data.toLowerCase().replace(lowerReg, "")) != null) if(active = this.activeLists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")) != null)
this.activeLists.delete(data.toLowerCase().replace(lowerReg, "")); this.activeLists.delete(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""));
bumplists.get(data.toLowerCase().replace(lowerReg, "")).deleteList(); bumplists.get(XSS.sanitizeText(data).toLowerCase().replace(lowerReg, "")).deleteList();
}else{ }else{
user.socket.emit("errorMsg", { user.socket.emit("errorMsg", {
msg: "Non-Existant Bumplist: " + data.toLowerCase().replace(lowerReg, ""), msg: "Non-Existant Bumplist: " + XSS.sanitizeText(data).toLowerCase().replace(lowerReg, ""),
alert: true alert: true
}); });
return; return;
@ -895,17 +927,19 @@ AutobumpModule.prototype.handleNewBump = function(user, data){//handle newBump
} }
if(data.user === ""){ if(data.user === ""){
data.user = null; data.user = null;
}else{
data.user = XSS.sanitizeText(data.user);
} }
var newbump = new bump(data.name, data.user, data.rtoke, media, data.bumplist, data.noauto);//create new bump var newbump = new bump(XSS.sanitizeText(data.name), data.user, data.rtoke, media, XSS.sanitizeText(data.bumplist), data.noauto);//create new bump
}); });
} }
}; };
AutobumpModule.prototype.handleRenameBump = function(user, data){ AutobumpModule.prototype.handleRenameBump = function(user, data){
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
if(bumplists.get(data.bl) != null && bumplists.get(data.bl).bumps[data.id] != null){ if(bumplists.get(XSS.sanitizeText(data.bl)) != null && bumplists.get(XSS.sanitizeText(data.bl)).bumps[data.id] != null){
bumplists.get(data.bl).bumps[data.id].rename(data.name); bumplists.get(XSS.sanitizeText(data.bl)).bumps[data.id].rename(XSS.sanitizeText(data.name));
bumplists.get(data.bl).saveList(); bumplists.get(XSS.sanitizeText(data.bl)).saveList();
} }
} }
@ -913,9 +947,9 @@ AutobumpModule.prototype.handleRenameBump = function(user, data){
AutobumpModule.prototype.handleChangeCreator = function(user, data){ AutobumpModule.prototype.handleChangeCreator = function(user, data){
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
if(bumplists.get(data.bl) != null && bumplists.get(data.bl).bumps[data.id] != null){ if(bumplists.get(XSS.sanitizeText(data.bl)) != null && bumplists.get(XSS.sanitizeText(data.bl)).bumps[data.id] != null){
bumplists.get(data.bl).bumps[data.id].user = (data.name); bumplists.get(XSS.sanitizeText(data.bl)).bumps[data.id].user = (XSS.sanitizeText(data.name));
bumplists.get(data.bl).saveList(); bumplists.get(XSS.sanitizeText(data.bl)).saveList();
} }
} }
} }
@ -940,12 +974,12 @@ AutobumpModule.prototype.handleToggleRtoke = function(user, data){
AutobumpModule.prototype.handleDeleteBump = function(user, data){ AutobumpModule.prototype.handleDeleteBump = function(user, data){
if(user.account.effectiveRank >= 2){ if(user.account.effectiveRank >= 2){
var bl = bumplists.get(data.bl); var bl = bumplists.get(XSS.sanitizeText(data.bl));
if(bl != null){ if(bl != null){
bl.deleteBump(bl.bumps[data.id]); bl.deleteBump(bl.bumps[data.id]);
}else{ }else{
user.socket.emit("errorMsg", { user.socket.emit("errorMsg", {
msg: "Bumplist: " + data.bl + " not found!", msg: "Bumplist: " + XSS.sanitizeText(data.bl) + " not found!",
alert: true alert: true
}); });
} }

View file

@ -43,55 +43,56 @@ var fs = require("fs");
var path = require("path"); var path = require("path");
var sio = require("socket.io"); var sio = require("socket.io");
var db = require("../database"); var db = require("../database");
var JoinMsg = [//join messages, bool(ifpostfix, if it is a string then it acts as prefix, and other string acts as postfix), str join message] var JoinMsg = [//join messages, bool(ifpostfix, if it is a string then it acts as prefix, and other string acts as postfix), str join message]
[true, "joined"], "%UNAME% joined.",
[true, "arrived"], "%UNAME% arrived.",
[true, "appeared"], "%UNAME% appeared.",
[true, "hopped in"], "%UNAME% hopped in.",
[true, "checked in"], "%UNAME% checked in.",
[true, "checked in to see what condition their condition was in"], "%UNAME% checked in to see what condition their condition was in.",
[true, "logged in"], "%UNAME% logged in.",
[true, "turned on, tuned in, and dropped out"], "%UNAME% turned on, tuned in, and dropped out.",
[true, "is now using Ourfore.st"], "%UNAME% is now using Ourfore.st.",
[true, "tuned in"], "%UNAME% tuned in.",
[true, "is ready to sparkem"], "%UNAME% is ready to sparkem.",
[true, "connected"], "%UNAME% connected.",
[true, "joins the battle"], "%UNAME% joins the battle.",
[true, "hopped on"], "%UNAME% hopped on.",
[true, "logged on"], "%UNAME% logged on.",
[false, "Ourfore.st, population:"], "Ourfore.st, population: %UNAME%",
[false, "Welcome,"], "Welcome, %UNAME%.",
[false, "Salutations,"], "Salutations, %UNAME%.",
[false, "Hello,"], "Hello, %UNAME%.",
[false, "Greetings,"], "Greetings, %UNAME%.",
[false, "Sup,"], "Sup, %UNAME%.",
[false, "I AM THE GOD OF HELLFIRE, AND I BRING YOU:"], "I AM THE GOD OF HELLFIRE, AND I BRING YOU: %UNAME%!",
["A wild","has appeared"] "A wild %UNAME% has appeared!"
] ]
var LeaveMsg = [//join messages, bool(ifpostfix, if it is a string then it acts as prefix, and other string acts as postfix), str join message] var LeaveMsg = [//join messages, bool(ifpostfix, if it is a string then it acts as prefix, and other string acts as postfix), str join message]
[true, "left"], "%UNAME% left.",
[true, "dropped out"], "%UNAME% dropped out.",
[true, "checked out"], "%UNAME% checked out.",
[true, "quit"], "%UNAME% quit.",
[true, "is no longer with us"], "%UNAME% is no longer with us.",
[true, "is no longer using Ourfore.st"], "%UNAME% is no longer using Ourfore.st.",
[true, "dipped"], "%UNAME% dipped.",
[true, "booked it"], "%UNAME% booked it.",
[true, "cheesed it"], "%UNAME% cheesed it.",
[true, "vanished"], "%UNAME% vanished.",
[true, "said dueces"], "%UNAME% said dueces.",
[true, "has left the building"], "%UNAME% has left the building.",
[true, "bounced"], "%UNAME% bounced.",
[true, "is beyond the horizon"], "%UNAME% is beyond the horizon.",
[true, "has drifted into space"], "%UNAME% has drifted into space.",
[true, "is outskies"], "%UNAME% is outskies.",
[false, "Goodbye,"], "Goodbye, %UNAME%.",
[false, "Dueces,"], "Dueces, %UNAME%.",
[false, "Bye,"], "Bye, %UNAME%.",
[false, "Farewell,"], "Farewell, %UNAME%.",
[false, "l8r"], "l8r %UNAME%.",
[false, "That'll do,"] "That'll do, %UNAME%."
] ]
import * as ChannelStore from '../channel-storage/channelstore'; import * as ChannelStore from '../channel-storage/channelstore';
@ -560,14 +561,7 @@ Channel.prototype.acceptUser = function (user) {
var jms = JoinMsg[Math.floor(Math.random()*JoinMsg.length)]; var jms = JoinMsg[Math.floor(Math.random()*JoinMsg.length)];
if(jms[0] == true){ self.modules.chat.sendModMessage(jms.replace("%UNAME%", user.getName()), -1);
jms = (user.getName() + " " + jms[1] + ".");
}else if(jms[0] == false){
jms = (jms[1] + " " + user.getName() + ".");
}else{
jms = (jms[0] + " " + user.getName() + " " + jms[1] + ".");
}
self.modules.chat.sendModMessage(jms, -1);
self.modules.chat.sendModMessage("(aliases: " + user.account.aliases.join(",") + ")", 2); self.modules.chat.sendModMessage("(aliases: " + user.account.aliases.join(",") + ")", 2);
}; };
@ -580,14 +574,7 @@ Channel.prototype.partUser = function (user) {
var lms = LeaveMsg[Math.floor(Math.random()*LeaveMsg.length)]; var lms = LeaveMsg[Math.floor(Math.random()*LeaveMsg.length)];
if(lms[0] == true){ this.modules.chat.sendModMessage(lms.replace("%UNAME%", user.getName()), -1);
lms = (user.getName() + " " + lms[1] + ".");
}else if(lms[0] == false){
lms = (lms[1] + " " + user.getName() + ".");
}else{
lms = (lms[0] + " " + user.getName() + " " + lms[1] + ".");
}
this.modules.chat.sendModMessage(lms, -1);
this.modules.chat.sendModMessage("(aliases: " + user.account.aliases.join(",") + ")", 2); this.modules.chat.sendModMessage("(aliases: " + user.account.aliases.join(",") + ")", 2);
this.logger.log("[login] " + user.displayip + " (" + user.getName() + ") " + this.logger.log("[login] " + user.displayip + " (" + user.getName() + ") " +
@ -771,18 +758,6 @@ Channel.prototype.sendUserJoin = function (users, user) {
u.socket.emit("addUser", data.base); u.socket.emit("addUser", data.base);
} }
}); });
/*var jms = JoinMsg[Math.floor(Math.random()*JoinMsg.length)];
if(jms[0] == true){
jms = (user.getName() + " " + jms[1] + ".");
}else if(jms[0] == false){
jms = (jms[1] + " " + user.getName() + ".");
}else{
jms = (jms[0] + " " + user.getName() + " " + jms[1] + ".");
}
self.modules.chat.sendModMessage(jms, -1);
self.modules.chat.sendModMessage("(aliases: " + user.account.aliases.join(",") + ")", 2);*/
}; };
Channel.prototype.readLog = function (cb) { Channel.prototype.readLog = function (cb) {

View file

@ -79,7 +79,7 @@ function ChatModule(_channel) {
this.registerCommand("!sp", this.handleCmdSp.bind(this)); this.registerCommand("!sp", this.handleCmdSp.bind(this));
this.registerCommand("!announce", this.handleCmdSay.bind(this)); this.registerCommand("!announce", this.handleCmdSay.bind(this));
this.registerCommand("!clear", this.handleCmdClear.bind(this)); this.registerCommand("!clear", this.handleCmdClear.bind(this));
this.registerCommand("!a", this.handleCmdAdminflair.bind(this)); this.registerCommand("!af", this.handleCmdAdminflair.bind(this));
this.registerCommand("!afk", this.handleCmdAfk.bind(this)); this.registerCommand("!afk", this.handleCmdAfk.bind(this));
this.registerCommand("!mute", this.handleCmdMute.bind(this)); this.registerCommand("!mute", this.handleCmdMute.bind(this));
this.registerCommand("!smute", this.handleCmdSMute.bind(this)); this.registerCommand("!smute", this.handleCmdSMute.bind(this));
@ -357,20 +357,26 @@ ChatModule.prototype.processChatMsg = function (user, data) {
msgobj.meta.addClass = "greentext"; msgobj.meta.addClass = "greentext";
} }
var qcmd = data.msg.indexOf("!") === 0;
var rcmd = qcmd ? data.msg : data.msg.replace(/\s+/,"");
//if (data.msg.indexOf("/") === 0) {Legacy from cytube '/' commands //if (data.msg.indexOf("/") === 0) {Legacy from cytube '/' commands
if (data.msg.indexOf("!") === 0) { if (rcmd.indexOf("!") === 0){
var space = data.msg.indexOf(" "); var space = rcmd.indexOf(" ");
var cmd; var cmd;
if (space < 0) { if (space < 0) {
cmd = data.msg.substring(1); cmd = rcmd.substring(1);
} else { } else {
cmd = data.msg.substring(1, space); cmd = rcmd.substring(1, space);
} }
if (cmd in this.commandHandlers) { if (cmd.toLowerCase() in this.commandHandlers) {
this.commandHandlers[cmd](user, data.msg, data.meta); this.commandHandlers[cmd.toLowerCase()](user, rcmd, data.meta);
if (data.msg.indexOf("!") === 0) {
return; return;
} }
}
} }
if (user.is(Flags.U_SMUTED)) { if (user.is(Flags.U_SMUTED)) {
@ -502,7 +508,7 @@ ChatModule.prototype.sendMessage = function (msgobj) {
ChatModule.prototype.registerCommand = function (cmd, cb) { ChatModule.prototype.registerCommand = function (cmd, cb) {
//cmd = cmd.replace(/^\//, ""); Legacy from cytube '/' commands //cmd = cmd.replace(/^\//, ""); Legacy from cytube '/' commands
cmd = cmd.replace(/^!/, ""); cmd = cmd.replace(/^!/, "").toLowerCase();
this.commandHandlers[cmd] = cb; this.commandHandlers[cmd] = cb;
}; };
@ -540,7 +546,7 @@ ChatModule.prototype.handleCmdSay = function (user, msg, meta) {
args.shift(); args.shift();
if(user.account.channelRank == 256){//if admin if(user.account.channelRank == 256){//if admin
args.unshift("!a") args.unshift("!af");
} }
this.processChatMsg(user, { msg: args.join(" "), meta: meta }); this.processChatMsg(user, { msg: args.join(" "), meta: meta });
}; };

View file

@ -540,7 +540,7 @@ PlaylistModule.prototype.handleQueue = function (user, data) {
subtitle: data.subtitle, subtitle: data.subtitle,
link: link, link: link,
temp: temp, temp: temp,
shouldAddToLibrary: !temp, shouldAddToLibrary: true,//for now chan library will act as a history
queueby: queueby, queueby: queueby,
duration: duration, duration: duration,
maxlength: maxlength maxlength: maxlength
@ -1013,8 +1013,7 @@ PlaylistModule.prototype._delete = function (uid) {
return success; return success;
}; };
PlaylistModule.prototype._addItem = function (media, data, user, cb) { PlaylistModule.prototype._addItem = function (media, data, user, cb, abump) {
var abump = user === "autobump";
var self = this; var self = this;
var allowDuplicates = false; var allowDuplicates = false;
if (this.channel.modules.options && this.channel.modules.options.get("allow_dupes")) { if (this.channel.modules.options && this.channel.modules.options.get("allow_dupes")) {
@ -1223,7 +1222,7 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
this.items.append(item); this.items.append(item);
return success(); return success();
} else { } else {
if (this.items.insertAfter(item, this.current.uid)) { if (this.items.insertAfter(item, (data.pos === "next" ? this.current.uid : data.pos))) {
if (existing && !allowDuplicates) { if (existing && !allowDuplicates) {
item.temp = existing.temp; item.temp = existing.temp;
this._delete(existing.uid); this._delete(existing.uid);

View file

@ -14,6 +14,7 @@ along with fore.st. If not, see < http://www.gnu.org/licenses/ >.
(C) 2022- by rainbownapkin, <ourforest@420blaze.it> (C) 2022- by rainbownapkin, <ourforest@420blaze.it>
*/ */
import fs from 'fs'; import fs from 'fs';
const XSS = require("../xss");
var ChannelModule = require("./module"); var ChannelModule = require("./module");
@ -94,7 +95,7 @@ TokebotModule.prototype.statmap = null;
TokebotModule.prototype.onMediaChange = function(data){ TokebotModule.prototype.onMediaChange = function(data){
if(data.tokeBump){ if(data.tokeBump && this.toking == 2){
this.ctime = 0; this.ctime = 0;
console.log("[Tokebot] Cooldown reset on " + this.channel.name + " triggered by bump."); console.log("[Tokebot] Cooldown reset on " + this.channel.name + " triggered by bump.");
} }
@ -119,7 +120,7 @@ TokebotModule.prototype.updatetokesCmd = function(user, msg, _meta){
TokebotModule.prototype.tokesayCmd = function(user, msg, _meta){ TokebotModule.prototype.tokesayCmd = function(user, msg, _meta){
if(user.account.effectiveRank >= 256){ if(user.account.effectiveRank >= 256){
var fmsg = msg.split(" "); var fmsg = XSS.sanitizeText(msg).split(" ");
fmsg.shift(); fmsg.shift();
this.tokesay(fmsg.join(' '), true); this.tokesay(fmsg.join(' '), true);
} }
@ -127,7 +128,7 @@ TokebotModule.prototype.tokesayCmd = function(user, msg, _meta){
TokebotModule.prototype.tokeyellCmd = function(user, msg, _meta){ TokebotModule.prototype.tokeyellCmd = function(user, msg, _meta){
if(user.account.effectiveRank >= 256){ if(user.account.effectiveRank >= 256){
var fmsg = msg.split(" "); var fmsg = XSS.sanitizeText(msg).split(" ");
fmsg.shift(); fmsg.shift();
this.tokesay(fmsg.join(' '), false); this.tokesay(fmsg.join(' '), false);
} }
@ -135,7 +136,7 @@ TokebotModule.prototype.tokeyellCmd = function(user, msg, _meta){
TokebotModule.prototype.tokewhisperCmd = function(user, msg, _meta){ TokebotModule.prototype.tokewhisperCmd = function(user, msg, _meta){
if(user.account.effectiveRank >= 256){ if(user.account.effectiveRank >= 256){
var fmsg = msg.split(" "); var fmsg = XSS.sanitizeText(msg).split(" ");
fmsg.shift(); fmsg.shift();
this.tokewhisper(fmsg.join(' ')); this.tokewhisper(fmsg.join(' '));
} }
@ -155,7 +156,7 @@ TokebotModule.prototype.toke = function (user, msg, _meta){
}*/ }*/
switch (this.toking){ switch (this.toking){
case 0://ready to start toke case 0://ready to start toke
this.tokesay("A group toke has been started by " + name + "! We'll be taking a toke in 60 seconds - join in by posting " + msg); this.tokesay("A group toke has been started by " + name + "! We'll be taking a toke in 60 seconds - join in by posting " + msg.split(/\s+/g)[0]);
this.cdown = 3; this.cdown = 3;
this.toking = 1; this.tokers.push(name); this.toking = 1; this.tokers.push(name);
setTimeout(this.countdown, 57000, this); setTimeout(this.countdown, 57000, this);
@ -267,7 +268,7 @@ TokebotModule.prototype.tokesay = function (msg,quiet){
meta:{ meta:{
addClass: (quiet ? null : "shout"), addClass: (quiet ? null : "shout"),
addClassToNameAndTimestamp: true, addClassToNameAndTimestamp: true,
forceShowName: (quiet ? true : false), //It's loud enough when announcing. Toke chats are rare enouhg to be more prominent :P forceShowName: (quiet ? true : false), //It's loud enough when announcing. Toke chats are rare enough to be more prominent :P
modflair: 3 modflair: 3
}, },
time: Date.now() time: Date.now()

View file

@ -41,6 +41,7 @@ const https = require("https");
const Media = require("./media"); const Media = require("./media");
const CustomEmbedFilter = require("./customembed").filter; const CustomEmbedFilter = require("./customembed").filter;
const Config = require("./config"); const Config = require("./config");
const XSS = require("./xss");
const ffmpeg = require("./ffmpeg"); const ffmpeg = require("./ffmpeg");
const mediaquery = require("@cytube/mediaquery"); const mediaquery = require("@cytube/mediaquery");
const YouTube = require("@cytube/mediaquery/lib/provider/youtube"); const YouTube = require("@cytube/mediaquery/lib/provider/youtube");
@ -242,7 +243,7 @@ var Getters = {
var options = { var options = {
host: Config.get("invidious-source"), host: Config.get("invidious-source"),
port: 443, port: 443,
path: "/api/v1/search?q='" + query + "'", path: "/api/v1/search?q='" + encodeURI(XSS.sanitizeText(query)) + "'",
method: "GET", method: "GET",
timeout: 1000 timeout: 1000
}; };

View file

@ -91,7 +91,7 @@ html(lang="en")
#videowrap #videowrap
.embed-responsive.embed-responsive-16by9 .embed-responsive.embed-responsive-16by9
#ytapiplayer.embed-responsive-item #ytapiplayer.embed-responsive-item
div#subliminaltoke div#st
img(src="/img/tokeleaf.png") img(src="/img/tokeleaf.png")
h3 Take a <a onclick="chatsmack('!toke')">Toke!</a> h3 Take a <a onclick="chatsmack('!toke')">Toke!</a>
#chatwrap #chatwrap
@ -134,10 +134,10 @@ html(lang="en")
span.glyphicon.glyphicon-search span.glyphicon.glyphicon-search
button#showplaylistmanager.btn.btn-sm.btn-default(title="Manage playlists", data-toggle="collapse", data-target="#playlistmanager") button#showplaylistmanager.btn.btn-sm.btn-default(title="Manage playlists", data-toggle="collapse", data-target="#playlistmanager")
span.glyphicon.glyphicon-list span.glyphicon.glyphicon-list
button#scrollitm.btn.btn-sm.btn-default(title="Scroll to Current Item",onclick="javascript:scrollQueue()") button#scrollitm.btn.btn-sm.btn-default(title="Scroll to Current Item",onclick="javascript:scrollQueue(true)")
span.glyphicon.glyphicon-hand-right span.glyphicon.glyphicon-hand-right
button#getplaylist.btn.btn-sm.btn-default(title="Retrieve playlist links") button#getplaylist.btn.btn-sm.btn-default(title="Export Queue")
span.glyphicon.glyphicon-link span.glyphicon.glyphicon-export
button#shuffleplaylist.btn.btn-sm.btn-default(title="Shuffle the playlist") button#shuffleplaylist.btn.btn-sm.btn-default(title="Shuffle the playlist")
span.glyphicon.glyphicon-sort span.glyphicon.glyphicon-sort
button#clearplaylist.btn.btn-sm.btn-default(title="Clear the playlist") button#clearplaylist.btn.btn-sm.btn-default(title="Clear the playlist")
@ -151,6 +151,7 @@ html(lang="en")
span#plcount 0 items span#plcount 0 items
br br
span#pllength 00:00:00 span#pllength 00:00:00
#plmenus
#searchcontrol.collapse.plcontrol-collapse.col-lg-12.col-md-12 #searchcontrol.collapse.plcontrol-collapse.col-lg-12.col-md-12
.vertical-spacer .vertical-spacer
.input-group .input-group

View file

@ -30,11 +30,17 @@ mixin us-general
label.control-label.col-sm-4(for="#us-theme") Theme label.control-label.col-sm-4(for="#us-theme") Theme
.col-sm-8 .col-sm-8
select#us-theme.form-control select#us-theme.form-control
option(value="/css/themes/fore.st.css") fore.st option(value="/css/themes/fore.st.css") Dawn [Frosted Glass]
option(value="/css/themes/fore.st.lite.css") Dawn [Smoked Quartz]
option(value="/css/themes/fore.st.dusk.css") Dusk [Frosted Glass]
option(value="/css/themes/fore.st.dusk.lite.css") Dusk [Smoked Quartz]
option(value="/css/themes/fore.st.neon.css") Neon [Frosted Glass]
option(value="/css/themes/fore.st.neon.lite.css") Neon [Smoked Quartz]
.col-sm-4 .col-sm-4
.col-sm-8 .col-sm-8
+rcheckbox("us-no-channelcss", "Ignore Channel CSS") +rcheckbox("us-no-channelcss", "Ignore Channel CSS")
+rcheckbox("us-no-channeljs", "Ignore Channel Javascript") +rcheckbox("us-no-channeljs", "Ignore Channel Javascript")
+textbox("us-chat-min", "Chat Width Minimum (Locked to Aspect only.)", "30")
.clear .clear
mixin us-scripts mixin us-scripts
@ -124,3 +130,5 @@ mixin us-mod
+rcheckbox("us-shadowchat", "Show shadowmuted messages") +rcheckbox("us-shadowchat", "Show shadowmuted messages")
+rcheckbox("us-show-ip-in-tooltip", "Show IP addresses in profile tooltip") +rcheckbox("us-show-ip-in-tooltip", "Show IP addresses in profile tooltip")
+rcheckbox("us-show-playlist", "Legacy Playlist") +rcheckbox("us-show-playlist", "Legacy Playlist")
+rcheckbox("us-scroll-playlist", "Scroll playlist on change.")
+rcheckbox("us-add-invid", "Queue Invidious links as YT links (may cause issues when queueing raw files).")

View file

@ -347,7 +347,7 @@ li.ui-sortable-helper, li.ui-sortable-placeholder + li.queue_entry {
} }
#fpcontdiv{ #fpcontdiv{
} }
#subliminaltoke{ #st{
background-color: #111111C0; background-color: #111111C0;
position: absolute; position: absolute;
left: calc(50% - 12em); left: calc(50% - 12em);
@ -356,8 +356,9 @@ li.ui-sortable-helper, li.ui-sortable-placeholder + li.queue_entry {
padding: 2em 2em 1em 2em; padding: 2em 2em 1em 2em;
border: 1px solid #949494; border: 1px solid #949494;
display: none; display: none;
z-index: 10001;
} }
#subliminaltoke img{ #st img{
max-height: 20em; max-height: 20em;
} }
.emotecontdiv{ .emotecontdiv{
@ -401,10 +402,8 @@ li.ui-sortable-helper, li.ui-sortable-placeholder + li.queue_entry {
} }
#emotecont{ #emotecont{
display: flex; display: flex;
position: fixed; position: absolute;
width: 100%; width: 100%;
background-color: #1119;
backdrop-filter: blur(12px);
} }
#esearchbar{ #esearchbar{
border-right: 1px solid #949494; border-right: 1px solid #949494;
@ -821,7 +820,9 @@ table td {
#userlisttoggle { #userlisttoggle {
padding-bottom: 2px; padding-bottom: 2px;
} }
#abumpdiv{
overflow-y: auto;
}
.queue_entry, .ab-bumparray-bump{ .queue_entry, .ab-bumparray-bump{
line-height: 22px; line-height: 22px;
padding: 2px; padding: 2px;
@ -843,7 +844,7 @@ table td {
float: right; float: right;
} }
#ab-bumphist-div{ #ab-bumphist-div{
overflow: scroll; overflow-y: auto;
max-height: 25em; max-height: 25em;
} }
.ab-bumplist-lbl, .ab-newlist-form{ .ab-bumplist-lbl, .ab-newlist-form{
@ -872,7 +873,7 @@ table td {
} }
.ab-bumplist-bumps{ .ab-bumplist-bumps{
max-height: 30em; max-height: 30em;
overflow: scroll; overflow-y: auto;
} }
.ab-bumplist-delete{ .ab-bumplist-delete{
float: right; float: right;
@ -990,7 +991,4 @@ body.hd #resize-video-larger, body.hd #resize-video-smaller {
.userlist-ignored { .userlist-ignored {
text-decoration: line-through; text-decoration: line-through;
} }
#bumpi{
background-image: url("../img/bumps.png");
background-size: 2.2em;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

BIN
www/img/bumpsdusk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
www/img/frstdusk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 MiB

View file

@ -523,7 +523,6 @@ Callbacks = {
chatMsg: function(data) { chatMsg: function(data) {
if(data.username === "tokebot"){ if(data.username === "tokebot"){
console.log(data);
if(data.meta.addClass === "server-whisper"){ if(data.meta.addClass === "server-whisper"){
data.meta.modflair = 3; data.meta.modflair = 3;
if( USEROPTS.toke_pm){ if( USEROPTS.toke_pm){
@ -540,6 +539,14 @@ Callbacks = {
if(usrColors[0].includes(n)){ if(usrColors[0].includes(n)){
$(".userlist_" + n).data().meta.toke++; $(".userlist_" + n).data().meta.toke++;
} }
});
}else if(data.meta.addClass === "shout" && (data.msg.startsWith("A group toke has been started by " + CLIENT.name + "!") || data.msg.startsWith(CLIENT.name + " joined the toke!"))){
data.msg.split(" ").forEach(function(w){
if(w.charAt(0) === '!' && w !== "!toke"){
storeToke(w);
}
}); });
} }
} }
@ -744,7 +751,7 @@ Callbacks = {
li.attr("id", "filei"); li.attr("id", "filei");
} }
if(data[i].media.isBump){ if(data[i].media.isBump){
li.attr("id", "bumpi"); li.addClass("bumpi");
} }
li.appendTo(q); li.appendTo(q);
} }
@ -763,7 +770,6 @@ Callbacks = {
}, },
queue: function(data) { queue: function(data) {
console.log(data);
PL_ACTION_QUEUE.queue(function (plq) { PL_ACTION_QUEUE.queue(function (plq) {
stopQueueSpinner(data.item.media); stopQueueSpinner(data.item.media);
var li = makeQueueEntry(data.item, true); var li = makeQueueEntry(data.item, true);
@ -777,7 +783,7 @@ Callbacks = {
} }
if(data.item.media.isBump){ if(data.item.media.isBump){
li.attr("id", "bumpi"); li.addClass("bumpi");
} }
li.hide(); li.hide();
@ -893,10 +899,13 @@ Callbacks = {
function loadNext() { function loadNext() {
if(PLAYER){ if(PLAYER){
PLAYER.latch(); PLAYER.latch();
PLAYER.latchseek();
} }
$("#latchvid").hide(); $("#latchvid").hide();
if (!PLAYER || data.type !== PLAYER.mediaType) { if (!PLAYER || data.type !== PLAYER.mediaType) {
loadMediaPlayer(data); loadMediaPlayer(data);
PLAYER.latch();
PLAYER.latchseek();
} else { } else {
handleMediaUpdate(data); handleMediaUpdate(data);
} }
@ -1259,7 +1268,6 @@ Callbacks = {
rmBumplist: function (data){ rmBumplist: function (data){
CHANNEL.bumpdata.lists.forEach(function(list, i){ CHANNEL.bumpdata.lists.forEach(function(list, i){
if(data === list.lowername){ if(data === list.lowername){
console.log(data);
CHANNEL.bumpdata.lists.splice(i, 1); CHANNEL.bumpdata.lists.splice(i, 1);
} }
}); });

View file

@ -171,8 +171,11 @@ var USEROPTS = {
sort_rank : getOrDefault("sort_rank", true), sort_rank : getOrDefault("sort_rank", true),
sort_afk : getOrDefault("sort_afk", false), sort_afk : getOrDefault("sort_afk", false),
legacy_emote : getOrDefault("legacy_emote", false), legacy_emote : getOrDefault("legacy_emote", false),
scroll_list : getOrDefault("scroll_list", false),
toke_pm : getOrDefault("toke_pm", false), toke_pm : getOrDefault("toke_pm", false),
yt_source : getOrDefault("yt_source", "vid.puffyan.us"), yt_source : getOrDefault("yt_source", "vid.puffyan.us"),
add_invid : getOrDefault("add_invid", true),
chat_min : getOrDefault("chat_min", 25),
show_seconds : getOrDefault("show_seconds", false), show_seconds : getOrDefault("show_seconds", false),
default_quality : getOrDefault("default_quality", "auto"), default_quality : getOrDefault("default_quality", "auto"),
boop : getOrDefault("boop", "never"), boop : getOrDefault("boop", "never"),

View file

@ -36,6 +36,9 @@ function closeFPanel(cb){//close and null out fpanel, cb function to call when p
function sizeFPDiv(){//set inner div height to fix overflow function sizeFPDiv(){//set inner div height to fix overflow
$("#fpaneldiv").outerWidth($("#chatwrap").outerWidth() * 0.7); $("#fpaneldiv").outerWidth($("#chatwrap").outerWidth() * 0.7);
$("#fpcontdiv").outerHeight($("#fpaneldiv").height() - $("#fptitlediv").outerHeight()); $("#fpcontdiv").outerHeight($("#fpaneldiv").height() - $("#fptitlediv").outerHeight());
if(CURRENTFPANEL != null){
CURRENTFPANEL.size();
}
} }
function panelbtn(panel){ function panelbtn(panel){
@ -74,6 +77,9 @@ fpmenu.prototype.popMenu = function(idata){//POP goes the weasal!
CURRENTFPANEL = this; CURRENTFPANEL = this;
$("#fpaneldiv").show("slide", 250, function() {sizeFPDiv()});//show panel and correct size once open $("#fpaneldiv").show("slide", 250, function() {sizeFPDiv()});//show panel and correct size once open
} }
fpmenu.prototype.size = function(){
};
//---base nested menu bar--- //---base nested menu bar---
function nmenu(title,p,menus,elm){//nested menu constructor(title(defaults to formatted parent title), parent, menu object array,append element(defaults to #fpcontdiv) function nmenu(title,p,menus,elm){//nested menu constructor(title(defaults to formatted parent title), parent, menu object array,append element(defaults to #fpcontdiv)
this.title = (title == null ? p.title.toLowerCase().replace(' ','-') + "-nested" : title); this.title = (title == null ? p.title.toLowerCase().replace(' ','-') + "-nested" : title);
@ -259,6 +265,14 @@ fpset.ocall = function(){
processOpts(); processOpts();
}), }),
), ),
$("<form>").append(
$("<label>").prop("for","qs-chat-min").html("Min Chat Width (Locked to Aspect only): "),
$("<input>").prop("id","qs-chat-min").prop("type","text").addClass("qs-form").change(function() {
USEROPTS.chat_min = ($("#qs-chat-min").val() >= 80 ? 80 : $("#qs-chat-min").val());
$("#qs-chat-min").val(USEROPTS.chat_min)
processOpts();
}).keydown(function(ev){if(ev.keyCode === 13){$(this).change();return false;}}),
),
$("<h4>").html("Playback Preferences"), $("<h4>").html("Playback Preferences"),
@ -279,7 +293,7 @@ fpset.ocall = function(){
$("<input>").prop("id","qs-sync-threshold").prop("type","text").addClass("qs-form").change(function() { $("<input>").prop("id","qs-sync-threshold").prop("type","text").addClass("qs-form").change(function() {
USEROPTS.sync_accuracy = parseFloat($("#qs-sync-threshold").val()) || 2; USEROPTS.sync_accuracy = parseFloat($("#qs-sync-threshold").val()) || 2;
processOpts(); processOpts();
}), }).keydown(function(ev){return !(ev.keyCode === 13)}),
), ),
$("<form>").append( $("<form>").append(
@ -352,6 +366,7 @@ fpset.ocall = function(){
fpset.loadSettings = function(){ fpset.loadSettings = function(){
$("#us-theme").children().clone().appendTo($("#qs-theme")); $("#us-theme").children().clone().appendTo($("#qs-theme"));
$("#qs-chat-min").val(USEROPTS.chat_min);
$("#us-yt-source").children().clone().appendTo($("#qs-yt-source")); $("#us-yt-source").children().clone().appendTo($("#qs-yt-source"));
$("#qs-theme").val(USEROPTS.theme); $("#qs-theme").val(USEROPTS.theme);
$("#qs-orient-buttons").prop("checked", USEROPTS.show_orientation); $("#qs-orient-buttons").prop("checked", USEROPTS.show_orientation);
@ -538,6 +553,20 @@ fpmod.ocall = function(){
processOpts(); processOpts();
}), }),
), ),
$("<form>").append(
$("<label>").prop("for","mp-scroll-playlist").html("Scroll playlist on change: "),
$("<input>").prop("id","mp-scroll-playlist").prop("type","checkbox").addClass("qs-form").prop("checked",USEROPTS.scroll_list).change(function() {
USEROPTS.scroll_list = $("#mp-scroll-playlist").prop("checked");
processOpts();
}),
),
$("<form>").append(
$("<label>").prop("for","mp-add-invid").html("Queue Invidious URLs as Youtube: "),
$("<input>").prop("id","mp-add-invid").prop("type","checkbox").addClass("qs-form").prop("checked",USEROPTS.add_invid).change(function() {
USEROPTS.add_invid = $("#mp-add-invid").prop("checked");
processOpts();
}),
),
); );
@ -547,7 +576,9 @@ fpmod.ocall = function(){
addOpt(); addOpt();
//---Quick Tools--- //---Quick Tools---
usrColors[0].map(function(u){ usrColors[0].map(function(u){
if(u !== "tokebot"){
$("#qt-clearuser").append($('<option value="' + u + '">' + u + "</option>")); $("#qt-clearuser").append($('<option value="' + u + '">' + u + "</option>"));
}
}); });
modNested.popMenu(); modNested.popMenu();
} }
@ -561,17 +592,12 @@ fpplaylist.elm = [//fpmod element array
fpplaylist.ocall = function(){ fpplaylist.ocall = function(){
modNested.popMenu(); modNested.popMenu();
if(!USEROPTS.show_playlist){ if(!USEROPTS.show_playlist){
nesth = $("#mod-nested").outerHeight();
panlh = $("#fpcontdiv").outerHeight();
prow = $("#playlistrow").show().appendTo("#fpcontdiv"); prow = $("#playlistrow").show().appendTo("#fpcontdiv");
prow.find("#rightcontrols").show().addClass("floatcont").prependTo("#fpcontdiv"); prow.find("#rightcontrols").show().addClass("floatcont").prependTo("#fpcontdiv");
conth = $("#rightcontrols").outerHeight();
$("#rightpane").css("background-color","rgba(0,0,0,0)"); $("#rightpane").css("background-color","rgba(0,0,0,0)");
prow.find("#queue").css("max-height", panlh - conth - nesth + "px").css("margin-top",conth + "px").css("margin-bottom", nesth + "px"); this.size();
scrollQueue(true);
}else{ }else{
$("<h4>").html("Please disable the Legacy Playlist setting to use this tab.").appendTo("#fpcontdiv"); $("<h4>").html("Please disable the Legacy Playlist setting to use this tab.").appendTo("#fpcontdiv");
} }
@ -579,6 +605,19 @@ fpplaylist.ocall = function(){
} }
fpplaylist.size = function(){
nesth = $("#mod-nested").outerHeight();
panlh = $("#fpcontdiv").outerHeight();
scont = $("#searchcontrol").is(":visible") ? $("#searchcontrol").outerHeight() : 0;
aurl = $("#addfromurl").is(":visible") ? $("#addfromurl").outerHeight() : 0;
cembed = $("#customembed").is(":visible") ? $("#customembed").outerHeight() : 0;
pman = $("#playlistmanager").is(":visible") ? $("#playlistmanager").outerHeight() : 0;
qfail = $("#queuefail").is(":visible") ? $("#queuefail").outerHeight() : 0;
conth = $("#rightcontrols").outerHeight() - (scont + aurl + cembed + pman + qfail);
prow.find("#queue").css("max-height", panlh - conth - nesth + "px").css("margin-top",conth + "px").css("margin-bottom", nesth + "px");
}
fpplaylist.ccall = function(){ fpplaylist.ccall = function(){
if(!USEROPTS.show_playlist){ if(!USEROPTS.show_playlist){
$("#rightcontrols").hide().removeClass("floatcont").prependTo("#rightpane-inner"); $("#rightcontrols").hide().removeClass("floatcont").prependTo("#rightpane-inner");
@ -598,9 +637,9 @@ fpbump.ocall = function(){
modNested.popMenu(); modNested.popMenu();
var ladd = $("<form>").addClass("ab-newlist-form").append( var ladd = $("<form>").addClass("ab-newlist-form").append(
$("<input>").prop("id","ab-newlist-name").prop("type","text").addClass("qs-form").attr("placeholder", "New Bumplist Title").change(function(){$("#ab-newlist-newbtn").click();}), $("<input>").prop("id","ab-newlist-name").prop("type","text").addClass("qs-form").attr("placeholder", "New Bumplist Title").keydown(function(ev){if(ev.keyCode === 13){$("#ab-newlist-newbtn").click();}}),
//$("<button/>").addClass("btn btn-primary btn-ln").text("Add List").prop("type","button").click(function(){ //$("<button/>").addClass("btn btn-primary btn-ln").text("Add List").prop("type","button").click(function(){
$("<span>").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Create Bumplist").attr("id","ab-newlist-newbtn").click(function(){ $("<span>").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Create New Bumplist").attr("id","ab-newlist-newbtn").click(function(){
var nlname = $("#ab-newlist-name").val() var nlname = $("#ab-newlist-name").val()
if(nlname != null && nlname !== ""){ if(nlname != null && nlname !== ""){
socket.emit("newBumplist",nlname); socket.emit("newBumplist",nlname);
@ -610,13 +649,23 @@ fpbump.ocall = function(){
} }
}), }),
$("<span>").addClass("qsbtn glyphicon glyphicon-ban-circle pointer").attr("title","Cancel").click(function(){ $("<span>").addClass("qsbtn glyphicon glyphicon-import pointer").attr("title","Clone Bumplist from Queue").attr("id","ab-newlist-clonebtn").click(function(){
var nlname = $("#ab-newlist-name").val()
if(nlname != null && nlname !== ""){
socket.emit("cloneBumplist",nlname);
$("#ab-newlist-name").val("");
$(this).parent().after(laddbtn.clone(true));
$(".ab-newlist-form").remove();
}
}),
$("<span>").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-ban-circle pointer").attr("title","Cancel").click(function(){
$(this).parent().after(laddbtn.clone(true)); $(this).parent().after(laddbtn.clone(true));
$(".ab-newlist-form").remove(); $(".ab-newlist-form").remove();
}), }),
); );
var laddbtn = $("<span>").prop("id","ab-newlist-btn").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Create Bumplist").click(function(){ var laddbtn = $("<span>").prop("id","ab-newlist-btn").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Add Bumplist").click(function(){
$(this).replaceWith(ladd.clone(true)); $(this).replaceWith(ladd.clone(true));
}); });
@ -629,6 +678,7 @@ fpbump.ocall = function(){
}); });
$("#fpcontdiv").append( $("#fpcontdiv").append(
$("<div>").attr("id","abumpdiv").append(
$("<h4>").html("General Config"), $("<h4>").html("General Config"),
$("<form>").append( $("<form>").append(
$("<label>").prop("for","ab-agro").html("Agression Level: "), $("<label>").prop("for","ab-agro").html("Agression Level: "),
@ -654,7 +704,7 @@ fpbump.ocall = function(){
$("<label>").prop("for","ab-dur-min").html("Duration Minimum (seconds): "), $("<label>").prop("for","ab-dur-min").html("Duration Minimum (seconds): "),
$("<input>").prop("id","ab-dur-min").prop("type","text").addClass("qs-form").change(function() { $("<input>").prop("id","ab-dur-min").prop("type","text").addClass("qs-form").change(function() {
socket.emit("setMinBump", parseInt($("#ab-dur-min").val())); socket.emit("setMinBump", parseInt($("#ab-dur-min").val()));
}) }).keydown(function(ev){return !(ev.keyCode === 13)})
), ),
$("<form>").append( $("<form>").append(
$("<label>").prop("for","ab-bsel").html("Bump Selection Method: "), $("<label>").prop("for","ab-bsel").html("Bump Selection Method: "),
@ -724,11 +774,17 @@ fpbump.ocall = function(){
}), }),
$("<h5>").html("Bump History (" + this.getHist().length + ")").attr("style", "display: inline").addClass("ab-bumphist-lbl").click(function(){$("#ab-bumphist-exp").click()}), $("<h5>").html("Bump History (" + this.getHist().length + ")").attr("style", "display: inline").addClass("ab-bumphist-lbl").click(function(){$("#ab-bumphist-exp").click()}),
$("<div>").prop("id", "ab-bumphist-div").append(this.showBumps(this.getHist())), $("<div>").prop("id", "ab-bumphist-div").append(this.showBumps(this.getHist())),
)
); );
this.loadSettings(); this.loadSettings();
} }
fpbump.loadSettings = function(){ fpbump.loadSettings = function(){
if(CHANNEL.bumpdata.agro == null || CHANNEL.bumpdata.freq == null){
console.error("null autobump settings, re-fetching from server");
socket.emit("getBumplists");
return;
}
$("#ab-agro")[0].value = CHANNEL.bumpdata.agro; $("#ab-agro")[0].value = CHANNEL.bumpdata.agro;
$("#ab-freq-min").val(CHANNEL.bumpdata.freq[0]); $("#ab-freq-min").val(CHANNEL.bumpdata.freq[0]);
$("#ab-freq-max").val(CHANNEL.bumpdata.freq[1]); $("#ab-freq-max").val(CHANNEL.bumpdata.freq[1]);
@ -747,9 +803,12 @@ fpbump.loadSettings = function(){
} }
fpbump.reloadPanel = function(){ fpbump.reloadPanel = function(){
var activec = [];
var allc = [];
var alists = [];
this.loadSettings(); this.loadSettings();
var alists = [];
CHANNEL.bumpdata.active.forEach(function(bname){ CHANNEL.bumpdata.active.forEach(function(bname){
CHANNEL.bumpdata.lists.forEach(function(list){ CHANNEL.bumpdata.lists.forEach(function(list){
if(list.lowername === bname) if(list.lowername === bname)
@ -757,13 +816,34 @@ fpbump.reloadPanel = function(){
}); });
}); });
$(".ab-activebumplists-div").children().each(function(i,item){
if($(item.children[1]).attr("style") == "rotate: 0;"){
var tar = [item.id.replace("ab-bumplist-",'') ,$($(item).children()[6]).scrollTop()]
activec.push(tar);
}
});
$(".ab-allbumplists-div").children().each(function(i,item){
if($(item.children[1]).attr("style") == "rotate: 0;"){
var tar = [item.id.replace("ab-bumplist-",'') ,$($(item).children()[6]).scrollTop()]
allc.push(tar);
}
});
$(".ab-activebumplists-lbl").html("Active Lists (" + CHANNEL.bumpdata.active.length + ")"); $(".ab-activebumplists-lbl").html("Active Lists (" + CHANNEL.bumpdata.active.length + ")");
$(".ab-allbumplists-lbl").html("All Lists (" + CHANNEL.bumpdata.lists.length + ")"); $(".ab-allbumplists-lbl").html("All Lists (" + CHANNEL.bumpdata.lists.length + ")");
$(".ab-bumphist-lbl").html("Bump History (" + this.getHist().length + ")"); $(".ab-bumphist-lbl").html("Bump History (" + this.getHist().length + ")");
$(".ab-activebumplists-div").html(this.showLists(alists)); $(".ab-activebumplists-div").html(this.showLists(alists, activec));
$(".ab-allbumplists-div").html(this.showLists()); $(".ab-allbumplists-div").html(this.showLists(null, allc));
$("#ab-bumphist-div").html(this.showBumps(this.getHist())); $("#ab-bumphist-div").html(this.showBumps(this.getHist()));
$(".ab-bumplist-bumps").each(function(i,item){
if(item.scrollb != null){
item.scrollb();
}
});
} }
fpbump.getHist = function(){ fpbump.getHist = function(){
@ -778,7 +858,7 @@ fpbump.getHist = function(){
return fHist; return fHist;
} }
fpbump.showLists = function(lists){ fpbump.showLists = function(lists, exp){
var lDivs = []; var lDivs = [];
var _this = this; var _this = this;
if(lists == null){ if(lists == null){
@ -796,7 +876,7 @@ fpbump.showLists = function(lists){
$("<input>").prop("id","ab-newbump-rtoke").prop("type","checkbox").addClass("qs-form"), $("<input>").prop("id","ab-newbump-rtoke").prop("type","checkbox").addClass("qs-form"),
$("<label>").prop("for","ab-newbump-noauto").html("Manual Only: "), $("<label>").prop("for","ab-newbump-noauto").html("Manual Only: "),
$("<input>").prop("id","ab-newbump-noauto").prop("type","checkbox").addClass("qs-form"), $("<input>").prop("id","ab-newbump-noauto").prop("type","checkbox").addClass("qs-form"),
$("<span>").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Add Bump").attr("id","ab-newlist-newbtn").click(function(){ $("<span>").addClass("qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Add Bump").attr("id","ab-newlist-newbtn").click(function(){
if($("#ab-newbump-url").val() !== ""){ if($("#ab-newbump-url").val() !== ""){
var mdata = parseMediaLink($("#ab-newbump-url").val()); var mdata = parseMediaLink($("#ab-newbump-url").val());
@ -818,7 +898,7 @@ fpbump.showLists = function(lists){
} }
}), }),
).clone(true), ).clone(true),
$("<span>").prop("id","ab-newbump-cancel").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-ban-circle pointer").click(function(){ $("<span>").prop("id","ab-newbump-cancel").addClass("qsbtn glyphicon glyphicon-ban-circle pointer").click(function(){
$(this).prev().prev().remove();//gotta take out that br... $(this).prev().prev().remove();//gotta take out that br...
$(this).prev().remove(); $(this).prev().remove();
$(this).replaceWith(ob); $(this).replaceWith(ob);
@ -827,17 +907,27 @@ fpbump.showLists = function(lists){
lists.forEach(function(list){ lists.forEach(function(list){
var blist = $("<div>").addClass("ab-bumplist-bumps").append(_this.showBumps(list.bumps, true)); var blist = $("<div>").addClass("ab-bumplist-bumps").append(_this.showBumps(list.bumps, true));
var active = false; var active = CHANNEL.bumpdata.active.includes(list.lowername);
CHANNEL.bumpdata.active.forEach(function(lname){ var ex = false;
if(!active)
active = list.lowername === lname; if(exp != null){
exp.forEach(function(item){
if(item[0] === list.lowername){
ex = item;
}
});
}
var bcount = 0;
list.bumps.forEach(function(item){
bcount += (item == null ? 0 : 1);
}); });
lDivs.push( lDivs.push(
$("<div>").addClass("ab-bumplist-list").attr("id", "ab-bumplist-" + list.lowername).append( $("<div>").addClass("ab-bumplist-list").attr("id", "ab-bumplist-" + list.lowername).append(
$("<span>").addClass("ab-bumplist-setactive" + (active ? "-active " : " ") + "qsbtn glyphicon glyphicon-ok pointer").attr("title",(active ? "Set List Inactive" : "Set List Active")).click(function(){ $("<span>").addClass("ab-bumplist-setactive" + (active ? "-active " : " ") + "qsbtn glyphicon glyphicon-ok pointer").attr("title",(active ? "Set List Inactive" : "Set List Active")).click(function(){
socket.emit((active ? "remove" : "set") + "Active", list.lowername); socket.emit((active ? "remove" : "set") + "Active", list.lowername);
}), }),
$("<span>").prop("id","ab-bumplist-bumps-exp").addClass("qsbtn glyphicon glyphicon-chevron-down pointer").attr("style","rotate: 270deg").click(function(){ $("<span>").prop("id","ab-bumplist-bumps-exp").addClass("qsbtn glyphicon glyphicon-chevron-down pointer").attr("style",(ex ? "rotate: 0;" : "rotate: 270deg")).click(function(){
if(blist.is(":visible")){ if(blist.is(":visible")){
blist.hide("blind"), blist.hide("blind"),
$(this).attr("style", "rotate: 270deg;"); $(this).attr("style", "rotate: 270deg;");
@ -846,8 +936,8 @@ fpbump.showLists = function(lists){
$(this).attr("style", "rotate: 0;"); $(this).attr("style", "rotate: 0;");
} }
}), }),
$("<h6>").html(list.name + " (" + list.bumps.length + ")").addClass("ab-bumplist-listname").click(function(){$(this).prev().click()}), $("<h6>").html(list.name + " (" + bcount + ")").addClass("ab-bumplist-listname").click(function(){$(this).prev().click()}),
$("<span>").prop("id","ab-bumplist-rename").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-pencil pointer").click(function(){ $("<span>").prop("id","ab-bumplist-rename").addClass("qsbtn glyphicon glyphicon-pencil pointer").click(function(){
var link = $(this).prev().clone(true); var link = $(this).prev().clone(true);
var ebtn = $(this).clone(true); var ebtn = $(this).clone(true);
@ -870,7 +960,7 @@ fpbump.showLists = function(lists){
}) })
); );
}), }),
$("<span>").addClass("ab-bumparray-edit qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Add Bump").attr("id","ab-newlist-newbtn").click(function(){ $("<span>").addClass("qsbtn glyphicon glyphicon-plus-sign pointer").attr("title","Add Bump").attr("id","ab-newlist-newbtn").click(function(){
var abtn = $(this).clone(true); var abtn = $(this).clone(true);
$(this).replaceWith(badd(list.lowername, abtn)); $(this).replaceWith(badd(list.lowername, abtn));
}), }),
@ -879,9 +969,17 @@ fpbump.showLists = function(lists){
socket.emit("delBumplist",list.lowername); socket.emit("delBumplist",list.lowername);
} }
}), }),
blist.hide(), blist,
), ),
); );
if(!ex){
blist[0].scrollb = null;
blist.hide();
}else{
blist[0].scrollb = function (){//annoyingly this shit cant just be called since this hasnt been placed yet, will be called be refresh function :P
blist.scrollTop(ex[1]);
};
}
}); });
return lDivs; return lDivs;
@ -987,6 +1085,10 @@ fpbump.showBumps = function(bumps, controls){
return bDivs; return bDivs;
} }
fpbump.size = function(){
$("#abumpdiv").outerHeight($("#fpcontdiv").outerHeight() - $("#mod-nested").outerHeight());
}
//---Tokebot--- //---Tokebot---
var fptoke = new fpmenu("Tokebot");//create new panel fpmod var fptoke = new fpmenu("Tokebot");//create new panel fpmod
@ -1049,5 +1151,59 @@ fptoke.ocall = function(){
modNested.popMenu(); modNested.popMenu();
} }
//---Export Playlist---
var fpexport = new fpmenu("Export Queue");
fpexport.ocall = function(data){
var list = [];
for(var i = 0; i < data.length; i++) {
var entry = [data[i].media.title, formatURL(data[i].media)];
list.push(entry);
}
$("#fpcontdiv").append(
$("<h4>").attr("id","ex-lbl").html("Export Queue"),
$("<form>").addClass("qt").attr("id","ex-form").append(
$("<button/>").addClass("btn btn-primary btn-ln").attr("id","ex-hmn-btn").text("Export as Human Readable").prop("type","button").click(function(){
$("#ex-txt-area").val("");
list.forEach(function(item, i){
$("#ex-txt-area").val($("#ex-txt-area").val() + i + ': "' + item[0] + '" - [' + item[1] + "]\n");
});
}),
$("<button/>").addClass("btn btn-primary btn-ln").attr("id","ex-json-btn").text("Export as JSON").prop("type","button").click(function(){
$("#ex-txt-area").val(JSON.stringify(list));
}),
$("<button/>").addClass("btn btn-primary btn-ln").attr("id","ex-csv-btn").text("Export as CSV").prop("type","button").click(function(){
$("#ex-txt-area").val("");
list.forEach(function(item){
$("#ex-txt-area").val($("#ex-txt-area").val() + item[0] + "," + item[1] + "\n");
});
}),
$("<button/>").addClass("btn btn-primary btn-ln").attr("id","ex-db-btn").text("Export as DB Format").prop("type","button").click(function(){
var out = [];
list.forEach(function(item, i){
re1=new RegExp('\\\\', 'g');
re2=new RegExp('\'', 'g');
title=item[0].replace(re1, '\\\\').replace(re2, '\\\'');
out.push('[\''+item[1]+'\', \''+title+'\'],');
});
$("#ex-txt-area").val(out.join('\n'));
}),
),
$("<textarea>").attr("id","ex-txt-area").addClass("form-control").attr("style", "font-family: mono; width: 100%;"),
);
$("#ex-hmn-btn").click();
modNested.popMenu();
}
fpexport.size = function(){
$("#ex-txt-area").outerHeight($("#fpcontdiv").outerHeight() - ($("#mod-nested").outerHeight() + $("#ex-form").outerHeight(true) + $("#ex-lbl").outerHeight(true)));
}
//---Mod Panel Nested Menu--- //---Mod Panel Nested Menu---
modNested = new nmenu(null,fpmod,[fpplaylist,fpbump,fptoke]); modNested = new nmenu(null,fpmod,[fpplaylist,fpbump,fptoke]);

View file

@ -26,6 +26,7 @@ function dispSTimes(){//update sTimes
var ptimeString, ltimeString; var ptimeString, ltimeString;
calcRefs();//iterate and findRefs before calcTime calcRefs();//iterate and findRefs before calcTime
//TODO: replace this with foreach
//iterate and print //iterate and print
for(var i = 0; i < startTimes[0].length; i++){//for every item startTime for(var i = 0; i < startTimes[0].length; i++){//for every item startTime
var rdif = startTimes[1][i] - rptime; var rdif = startTimes[1][i] - rptime;

View file

@ -41,10 +41,17 @@
Player.prototype.unlatch = function() { Player.prototype.unlatch = function() {
if (!this.seeklatch) { if (!this.seeklatch) {
if (this.latched) {
var _this = this;
this.getTime(function(ct){//checks to make sure the video isn't starting as this gets called like crazy :P
if(ct > 0){
if (_this.latched) {
$("#latchvid").show(); $("#latchvid").show();
} }
return this.latched = false; _this.latched = false;
}
});
} else { } else {
return this.seeklatch = false; return this.seeklatch = false;
} }
@ -648,6 +655,7 @@
VideoJSPlayer.prototype.loadPlayer = function(data) { VideoJSPlayer.prototype.loadPlayer = function(data) {
this.latched = true; this.latched = true;
this.ofyt = data.ofyt;
return waitUntilDefined(window, 'videojs', (function(_this) { return waitUntilDefined(window, 'videojs', (function(_this) {
return function() { return function() {
var attrs, video; var attrs, video;
@ -1766,6 +1774,7 @@
return console.error(e); return console.error(e);
} }
} else if ((USEROPTS.yt_source !== "OFYT" && data.type == "yt")) { } else if ((USEROPTS.yt_source !== "OFYT" && data.type == "yt")) {
data.ofyt = data.id;
data.id = data.meta.rawLink;//set link and spoof mov/h264 data.id = data.meta.rawLink;//set link and spoof mov/h264
data.type = "fi"; data.type = "fi";
data.meta.codec = "mov/h264"; data.meta.codec = "mov/h264";
@ -1803,6 +1812,7 @@
data.currentTime = 0; data.currentTime = 0;
} }
PLAYER.load(data); PLAYER.load(data);
PLAYER.latchseek();
PLAYER.play(); PLAYER.play();
} }
if (waiting) { if (waiting) {

View file

@ -1,4 +1,4 @@
/* /*;
fore.st is free software: you can redistribute it and/or modify fore.st is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
@ -103,7 +103,7 @@ function moveSplit(dper, mx){//Gross and hacky, but this prevents code re-use
} }
} }
$("#fpaneldiv").outerWidth($("#chatwrap").outerWidth() * 0.7); sizeFPDiv();
} }
@ -313,7 +313,7 @@ function callChat(){
if(msg.trim()) { if(msg.trim()) {
var meta = {}; var meta = {};
if (USEROPTS.adminhat && CLIENT.rank >= 255) { if (USEROPTS.adminhat && CLIENT.rank >= 255) {
msg = "!a " + msg; msg = "!af " + msg;
} else if (USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) { } else if (USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) {
meta.modflair = CLIENT.rank; meta.modflair = CLIENT.rank;
} }
@ -324,10 +324,6 @@ function callChat(){
msg = msg.substring(3); msg = msg.substring(3);
} }
if (msg.charAt(0) === '!' && msg != "!toke"){
storeToke(msg);
}
socket.emit("chatMsg", { socket.emit("chatMsg", {
msg: msg, msg: msg,
meta: meta meta: meta
@ -796,34 +792,7 @@ $("#getplaylist").click(function() {
if (idx >= 0) { if (idx >= 0) {
socket.listeners("playlist").splice(idx); socket.listeners("playlist").splice(idx);
} }
var list = []; fpexport.popMenu(data);
for(var i = 0; i < data.length; i++) {
var entry = formatURL(data[i].media);
list.push(entry);
}
var urls = list.join(",");
var outer = $("<div/>").addClass("modal fade")
.appendTo($("body"));
modal = $("<div/>").addClass("modal-dialog").appendTo(outer);
modal = $("<div/>").addClass("modal-content").appendTo(modal);
var head = $("<div/>").addClass("modal-header")
.appendTo(modal);
$("<button/>").addClass("close")
.attr("data-dismiss", "modal")
.attr("aria-hidden", "true")
.html("&times;")
.appendTo(head);
$("<h3/>").text("Playlist URLs").appendTo(head);
var body = $("<div/>").addClass("modal-body").appendTo(modal);
$("<input/>").addClass("form-control").attr("type", "text")
.val(urls)
.appendTo(body);
$("<div/>").addClass("modal-footer").appendTo(modal);
outer.on("hidden.bs.modal", function() {
outer.remove();
});
outer.modal();
}; };
socket.on("playlist", callback); socket.on("playlist", callback);
var errCallback = function(data) { var errCallback = function(data) {

View file

@ -277,7 +277,7 @@ function addUserDropdown(entry) {
} }
/* pm button */ /* pm button */
if (name !== CLIENT.name) { if (name !== CLIENT.name && name !== "tokebot") {
var pm = $("<button/>").addClass("btn btn-xs btn-default") var pm = $("<button/>").addClass("btn btn-xs btn-default")
.text("Private Message") .text("Private Message")
.appendTo(btngroup) .appendTo(btngroup)
@ -543,9 +543,9 @@ function sortUserlist() {
/* queue stuff */ /* queue stuff */
function scrollQueue() { function scrollQueue(ovr) {
var li = playlistFind(PL_CURRENT); var li = playlistFind(PL_CURRENT);
if(!li) if(!li || (!USEROPTS.scroll_list && !ovr))
return; return;
li = $(li); li = $(li);
@ -736,6 +736,7 @@ function showUserOptions() {
$("#us-theme").val(USEROPTS.theme); $("#us-theme").val(USEROPTS.theme);
$("#us-no-channelcss").prop("checked", USEROPTS.ignore_channelcss); $("#us-no-channelcss").prop("checked", USEROPTS.ignore_channelcss);
$("#us-no-channeljs").prop("checked", USEROPTS.ignore_channeljs); $("#us-no-channeljs").prop("checked", USEROPTS.ignore_channeljs);
$("#us-chat-min").val(USEROPTS.chat_min);
$("#us-synch").prop("checked", USEROPTS.synch); $("#us-synch").prop("checked", USEROPTS.synch);
$("#us-synch-accuracy").val(USEROPTS.sync_accuracy); $("#us-synch-accuracy").val(USEROPTS.sync_accuracy);
@ -764,6 +765,8 @@ function showUserOptions() {
$("#us-shadowchat").prop("checked", USEROPTS.show_shadowchat); $("#us-shadowchat").prop("checked", USEROPTS.show_shadowchat);
$("#us-show-ip-in-tooltip").prop("checked", USEROPTS.show_ip_in_tooltip); $("#us-show-ip-in-tooltip").prop("checked", USEROPTS.show_ip_in_tooltip);
$("#us-show-playlist").prop("checked", USEROPTS.show_playlist); $("#us-show-playlist").prop("checked", USEROPTS.show_playlist);
$("#us-scroll-playlist").prop("checked", USEROPTS.scroll_list);
$("#us-add-invid").prop("checked", USEROPTS.add_invid);
formatScriptAccessPrefs(); formatScriptAccessPrefs();
@ -776,8 +779,12 @@ function saveUserOptions() {
createCookie("cytube-theme", USEROPTS.theme, 1000); createCookie("cytube-theme", USEROPTS.theme, 1000);
USEROPTS.ignore_channelcss = $("#us-no-channelcss").prop("checked"); USEROPTS.ignore_channelcss = $("#us-no-channelcss").prop("checked");
USEROPTS.ignore_channeljs = $("#us-no-channeljs").prop("checked"); USEROPTS.ignore_channeljs = $("#us-no-channeljs").prop("checked");
USEROPTS.chat_min = ($("#us-chat-min").val() >= 80 ? 80 : $("#us-chat-min").val());
USEROPTS.show_ip_in_tooltip = $("#us-show-ip-in-tooltip").prop("checked"); USEROPTS.show_ip_in_tooltip = $("#us-show-ip-in-tooltip").prop("checked");
USEROPTS.show_playlist = $("#us-show-playlist").prop("checked"); USEROPTS.show_playlist = $("#us-show-playlist").prop("checked");
USEROPTS.scroll_list = $("#us-scroll-playlist").prop("checked");
USEROPTS.add_invid = $("#us-add-invid").prop("checked");
USEROPTS.synch = $("#us-synch").prop("checked"); USEROPTS.synch = $("#us-synch").prop("checked");
USEROPTS.sync_accuracy = parseFloat($("#us-synch-accuracy").val()) || 2; USEROPTS.sync_accuracy = parseFloat($("#us-synch-accuracy").val()) || 2;
@ -821,6 +828,7 @@ function storeOpts() {
} }
function applyOpts() { function applyOpts() {
handleVideoResize();
if ($("#usertheme").attr("href") !== USEROPTS.theme) { if ($("#usertheme").attr("href") !== USEROPTS.theme) {
var old = $("#usertheme").attr("id", "usertheme_old"); var old = $("#usertheme").attr("id", "usertheme_old");
var theme = USEROPTS.theme; var theme = USEROPTS.theme;
@ -1233,7 +1241,8 @@ function handlePermissionChange() {
rebuildPlaylist(); rebuildPlaylist();
if(!USEROPTS.show_playlist && $("#playlistrow").parent()[0].className == "container"){ if(!USEROPTS.show_playlist && $("#playlistrow").parent()[0].className == "container"){
$("#hideplaylist").click(); $("#rightcontrols").hide();
$("#playlistrow").hide();
$("#rightcontrols").hide(); $("#rightcontrols").hide();
$("#playlistrow").hide(); $("#playlistrow").hide();
$("#showplaylist").hide(); $("#showplaylist").hide();
@ -1607,6 +1616,7 @@ function parseMediaLink(url) {
} }
// Generic for the rest. // Generic for the rest.
if ((m = url.match(/^([a-z]{2}):([^\?&#]+)/))) { if ((m = url.match(/^([a-z]{2}):([^\?&#]+)/))) {
return { return {
id: m[2], id: m[2],
type: m[1] type: m[1]
@ -1622,6 +1632,11 @@ function parseMediaLink(url) {
id: url, id: url,
type: "cm" type: "cm"
}; };
} else if(USEROPTS.add_invid && (m = url.match(/(?<=\/watch\?v\=).*/))) {//catch invidious links
return {
id: m[0],
type: "yt"
};
} else { } else {
// Assume raw file (server will check) // Assume raw file (server will check)
return { return {
@ -1641,12 +1656,13 @@ function sendVideoUpdate() {
if (!CLIENT.leader) { if (!CLIENT.leader) {
return; return;
} }
console.log(PLAYER.ofyt ? "yt" : PLAYER.mediaType);
PLAYER.getTime(function (seconds) { PLAYER.getTime(function (seconds) {
socket.emit("mediaUpdate", { socket.emit("mediaUpdate", {
id: PLAYER.mediaId, id: (PLAYER.ofyt != null ? PLAYER.ofyt : PLAYER.mediaId),
currentTime: seconds, currentTime: seconds,
paused: PLAYER.paused, paused: PLAYER.paused,
type: PLAYER.mediaType type: (PLAYER.ofyt != null ? "yt" : PLAYER.mediaType)
}); });
}); });
} }
@ -1938,8 +1954,8 @@ function handleWindowResize() {
$("#videowrap").outerHeight(rheight); $("#videowrap").outerHeight(rheight);
$(".embed-responsive").outerHeight(rheight); $(".embed-responsive").outerHeight(rheight);
$("#ytapiplayer").outerHeight(rheight); $("#ytapiplayer").outerHeight(rheight);
h = h - rheight - $("#videowrap-header").outerHeight(); h = h - ($("#videowrap").is(":visible") ? rheight : 0 )- $("#videowrap-header").outerHeight();
rawh = rawh - rheight - $("#videowrap-header").outerHeight(); rawh = rawh - ($("#videowrap").is(":visible") ? rheight : 0 ) - $("#videowrap-header").outerHeight();
} }
} }
@ -1950,7 +1966,6 @@ function handleWindowResize() {
$("#chatwrap").outerHeight(rawh); $("#chatwrap").outerHeight(rawh);
sizeFPDiv();//resize fpanel sizeFPDiv();//resize fpanel
handleVideoResize(); handleVideoResize();
} }
@ -1962,11 +1977,12 @@ function handleVideoResize() {//rewritten to adjust width to aspect ratio
res = x != null ? x : [0,0]; res = x != null ? x : [0,0];
}); });
rwidth = (res[0]/res[1]) * parseInt($("#ytapiplayer").css("height")); var rwidth = (res[0]/res[1]) * parseInt($("#ytapiplayer").css("height"));
var rper = ((rwidth/$("body").outerWidth()) * 100);
var mper = (rper < (100 - USEROPTS.chat_min) ? rper:(100 - USEROPTS.chat_min))
rper = ((rwidth/$("body").outerWidth()) * 100); $("#videowrap").css("flex-basis", mper + "%");//theres probably cleaner ways to do this but i was high as balls and tired as fuck so you're getting this hacky shit
$("#videowrap").css("flex-basis", rper + "%");//theres probably cleaner ways to do this but i was high as balls and tired as fuck so you're getting this hacky shit moveSplit(mper,0)
moveSplit(rper,0)
} }
} }
@ -1979,14 +1995,14 @@ function blindVideo(){//this and the next one especially are fucking spaghetti
$("#flipx-video").hide(""); $("#flipx-video").hide("");
$("#flipy-video").hide(""); $("#flipy-video").hide("");
$("#minicontrol").show(""); $("#minicontrol").show("",handleWindowResize);
setMini(); setMini();
$("#videowrap-header").css("flex-basis","auto"); $("#videowrap-header").css("flex-basis","auto");
}else{ }else{
$("#minicontrol").hide(""); $("#minicontrol").hide("");
$("#videowrap").show(handleVideoResize); $("#videowrap").show(handleWindowResize);
if(!RATIO_LOCKED){ if(!RATIO_LOCKED){
$("#lockaspect").show(""); $("#lockaspect").show("");
} }
@ -2920,10 +2936,11 @@ function initPm(user) {
}); });
var buffer = $("<div/>").addClass("pm-buffer linewrap").appendTo(body); var buffer = $("<div/>").addClass("pm-buffer linewrap").appendTo(body);
$("<hr/>").appendTo(body); $("<hr/>").appendTo(body);
var input = $("<input/>").addClass("form-control pm-input").attr("type", "text") var input = $("<input/>").attr("placeholder","Private Message...").addClass("form-control pm-input").attr("type", "text")
.attr("maxlength", 320) .attr("maxlength", 320)
.appendTo(body); .appendTo(body);
if(user !== "tokebot"){
input.keydown(function (ev) { input.keydown(function (ev) {
if (ev.keyCode === 13) { if (ev.keyCode === 13) {
if (CHATTHROTTLE) { if (CHATTHROTTLE) {
@ -2959,6 +2976,9 @@ function initPm(user) {
return false; return false;
} }
}); });
}
input.prop('disabled', user === "tokebot")
return pm; return pm;
} }
@ -3411,6 +3431,21 @@ function startQueueSpinner(data) {
progress.appendTo($("#addfromurl")); progress.appendTo($("#addfromurl"));
} }
function ot(){
$("#st").show();
setTimeout(ht,1000);
}
function ht(){
$("#st").hide();
var mn = 1800;
var mx = 18000;
var dl = (Math.random() * (mx - mn) + mn);
setTimeout(ot, dl * 1000);
}
ht();
function stopQueueSpinner(data) { function stopQueueSpinner(data) {
// TODO: this is a temp hack, need to replace media ID check with // TODO: this is a temp hack, need to replace media ID check with
// a passthrough request ID (since media ID from API is not necessarily // a passthrough request ID (since media ID from API is not necessarily