[Tuto] Script to change plug.dj's background

Anything and everything that doesn't fit in another section.
Post Reply
User avatar
Illyasviel
Posts: 1
Joined: November 11th, 2014, 2:55 pm

[Tuto] Script to change plug.dj's background

Post by Illyasviel » November 11th, 2014, 6:31 pm

Warning, the /rider is made to the users who uses Tastyplug

Here is the script written by Umcookies on a potatoe. All honors go to my senpai <3
API.on(API.chatLog("Use /background to set your new background and /player /vote /join /avatars to change the position of the respective UI elements", 1));
API.on(API.chatLog("You can use /move if any UI part's move, it wont prompt for any inputs. You can also use /keeppos which will check every second if a UI element has moved (recommended)"));
API.on(API.CHAT_COMMAND, awesomethings);
//variables
var backgroundurl = "https://cdn.plug.dj/_/static/images/com ... 98f284.jpg";
var playerWhereX = document.getElementById("playback").style.left.replace("px", "");
var playerWhereY = "54";
var voteWhereX = document.getElementById("vote").style.left.replace("px", "");
var voteWhereY = document.getElementById("vote").style.top.replace("px", "");
var joinWhereX = document.getElementById("dj-button").style.left.replace("px", "");
var joinWhereY = document.getElementById("dj-button").style.top.replace("px", "");
var avatarsWhereX = document.getElementById("avatars-container").style.left.replace("px", "");
var avatarsWhereY = document.getElementById("avatars-container").style.left.replace("px", "");
var loopKeeppos = '0';
//functions
function awesomethings(data) {
var commands = data;
if (commands == "/background") {
backgroundurl = prompt("Please input the URL of the picture you would like to use");
API.chatLog("It'll take a few seconds to load the picture, if you entered a valid picture please be patient");
document.getElementsByClassName("room-background")[0].setAttribute('style', 'background: url(' + backgroundurl + ')');
}
if (commands == "/player") {
playerWhereX = prompt("Please input how many pixels from the left of the screen you would like the player", "585");
playerWhereY = prompt("Please input how many pixels from the top of the screen you would like the player", "54");
document.getElementById("playback").setAttribute('style', 'left:' + playerWhereX + 'px; top: ' + playerWhereY + 'px;');
}
if (commands == "/vote") {
voteWhereX = prompt("How many pixels from the left hand side of the screen would you like the vote buttons to be ?", "945.5");
voteWhereY = prompt("How many pixels from the top of the screen would you like the vote buttons to be ?", "772");
document.getElementById("vote").setAttribute('style', 'left: ' + voteWhereX + 'px; top: ' + voteWhereY + 'px;')
}
if (commands == "/join") {
joinWhereX = prompt("How many pixels from the left hand side of the screen would you like the waitlist buttons to be ?", "398.5");
joinWhereY = prompt("How many pixels from the top of the screen would you like the waitlist button to be ?", "772");
document.getElementById("dj-button").setAttribute('style', 'left: ' + joinWhereX + 'px; top: ' + voteWhereY + 'px;')
}
if (commands == "/avatars") {
avatarsWhereX = prompt("How many pixels from the left hand side of the screen would you like the avatars to be ?", "385");
avatarsWhereY = prompt("How many pixels from the top of the screen would you like the avatars to be ?", "544");
document.getElementById("avatars-container").setAttribute('style', 'left: ' + avatarsWhereX + 'px; top: ' + avatarsWhereY + 'px;')
}
if (commands == "/move") {
document.getElementById("playback").setAttribute('style', 'left:' + playerWhereX + 'px; top: ' + playerWhereY + 'px;');
document.getElementById("avatars-container").setAttribute('style', 'left: ' + avatarsWhereX + 'px; top: ' + avatarsWhereY + 'px;');
document.getElementById("dj-button").setAttribute('style', 'left: ' + joinWhereX + 'px; top: ' + voteWhereY + 'px;');
document.getElementById("vote").setAttribute('style', 'left: ' + voteWhereX + 'px; top: ' + voteWhereY + 'px;');
}
if (commands == "/umcookies") {
document.getElementsByClassName("room-background")[0].setAttribute('style', 'background: url("https://www.dropbox.com/sh/q9miyunbh5mz ... 9.png?dl=1")');
playerWhereX = "12";
playerWhereY = "54";
voteWhereX = "0";
voteWhereY = "335";
joinWhereX = "0";
joinWhereY = "396";
avatarsWhereX = "-100";
avatarsWhereY = "500";
loopKeeppos = '1';
loopCheck();
}
if (commands == "/rider") {
document.getElementsByClassName("room-background")[0].setAttribute('style', 'background: url("http://www.simpleimageresizer.com/_uplo ... 3.jpg?dl=1")');
playerWhereX = "120";
playerWhereY = "54";
voteWhereX = "0";
voteWhereY = "348";
joinWhereX = "0";
joinWhereY = "409";
avatarsWhereX = "30";
avatarsWhereY = "280";
loopKeeppos = '1';
loopCheck();
}
if (commands == "/keeppos") {
if (loopKeeppos == '0') {
loopKeeppos = '1';
loopCheck();
API.chatLog("UI element positions are now being automatically fixed")
}
else if (loopKeeppos == '1') {
loopKeeppos = '0';
API.chatLog("UI element positions are no longer being automatically fixed")
}
}
if (commands == "/savepos") {
var saveName = prompt("Please enter the name you would like to save everything under, you MUST remember this", "default");
var umcookiesBgArray = [backgroundurl, playerWhereX, playerWhereY, voteWhereX, voteWhereY, joinWhereX, joinWhereY, avatarsWhereX, avatarsWhereY, loopKeeppos];
localStorage.setItem(saveName, JSON.stringify(umcookiesBgArray))
}
if (commands == "/loadpos"){
var saveName = prompt("What is the name of your save file?");
backgroundurl = (JSON.parse(localStorage.getItem(saveName)))[0];
playerWhereX = (JSON.parse(localStorage.getItem(saveName)))[1];
playerWhereY = (JSON.parse(localStorage.getItem(saveName)))[2];
voteWhereX = (JSON.parse(localStorage.getItem(saveName)))[3];
voteWhereY = (JSON.parse(localStorage.getItem(saveName)))[4];
joinWhereX = (JSON.parse(localStorage.getItem(saveName)))[5];
joinWhereY = (JSON.parse(localStorage.getItem(saveName)))[6];
avatarsWhereX = (JSON.parse(localStorage.getItem(saveName)))[7];
avatarsWhereY = (JSON.parse(localStorage.getItem(saveName)))[8];
loopKeeppos = (JSON.parse(localStorage.getItem(saveName)))[9];
}
}
function loopCheck() {
setTimeout(function () {
if (loopKeeppos == '1') {
document.getElementById("playback").setAttribute('style', 'left:' + playerWhereX + 'px; top: ' + playerWhereY + 'px;');
document.getElementById("avatars-container").setAttribute('style', 'left: ' + avatarsWhereX + 'px; top: ' + avatarsWhereY + 'px;');
document.getElementById("dj-button").setAttribute('style', 'left: ' + joinWhereX + 'px; top: ' + joinWhereY + 'px;');
document.getElementById("vote").setAttribute('style', 'left: ' + voteWhereX + 'px; top: ' + voteWhereY + 'px;');
loopCheck();
}
}, 1000)
}
i let you guess how it works ;)
Image
User avatar
emilemil1
Posts: 544
Joined: July 30th, 2014, 11:48 pm
Contact:

Re: [Tuto] Script to change plug.dj's background

Post by emilemil1 » November 11th, 2014, 8:28 pm

That's some seriously sloppy code formatting ^^ Anyway, I can tell right away that the /rider command won't work because it's referring to a page that's not found.
Post Reply