2022-12-21 20:23:42 -05:00
<!DOCTYPE html>
< html >
2022-12-21 21:29:12 -05:00
<!-- Hello! You have found my TV Controller. The API provided in this source is behind a firewall and will be of no use to you. Move along! -->
2022-12-22 02:25:16 -05:00
< head >
< div id = "view2" > < / div >
< / head >
2022-12-21 20:32:54 -05:00
< title > Samsung TVController< / title >
2022-12-21 20:30:06 -05:00
2022-12-22 04:20:26 -05:00
<!-- Styles -->
2022-12-22 00:03:10 -05:00
< style >
body {
background-color: #101010;
color: #ffffff;
}
h1 {
color: #ffffff;
}
nav a {
color: #ffffff;
}
footer {
color: #ffffff;
}
< / style >
2022-12-22 04:19:27 -05:00
2022-12-22 02:25:16 -05:00
< link href = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel = "stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
< script src = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous">< / script >
2022-12-22 04:19:27 -05:00
<!-- END Styles -->
2022-12-22 02:25:16 -05:00
2022-12-22 04:19:27 -05:00
<!-- MAIN JS -->
2022-12-22 00:03:10 -05:00
< script >
2022-12-22 04:19:27 -05:00
// Set API URL
2022-12-22 00:03:10 -05:00
let rootURL = "https://grwh.work:3031"
2022-12-22 04:19:27 -05:00
// Init timer VAR
2022-12-22 01:15:51 -05:00
var timer;
2022-12-22 04:19:27 -05:00
// Youtube Shorts Timer - Skip Every 55 Seconds
2022-12-22 01:15:51 -05:00
function startTimer() {
console.log("Shorts timer started!")
2022-12-22 02:58:58 -05:00
showSuccessAlert("Started Shorts Timer")
2022-12-22 01:15:51 -05:00
timer = setInterval(function () {
2022-12-22 02:58:58 -05:00
console.log("Time is up, going to next short");
2022-12-22 01:15:51 -05:00
fetch(rootURL + "/down")
.then(function (response) {
return response.json();
2022-12-22 02:58:58 -05:00
}).then(function (data) {
console.log("Resonse from AutoScroll Request: " + data)
2022-12-22 02:37:07 -05:00
if (data == 1) {
showSuccessAlert("Next Short Requested Successfully!")
2022-12-22 02:58:58 -05:00
console.log("Command: Next Short - SENT!")
2022-12-22 02:37:07 -05:00
} else {
showSuccessAlert("Next Short Request FAILED!")
2022-12-22 02:58:58 -05:00
console.log("Command: Next Short FAILED!")
2022-12-22 02:37:07 -05:00
}
2022-12-22 01:15:51 -05:00
})
2022-12-22 03:30:34 -05:00
}, 55000);
2022-12-22 01:15:51 -05:00
}
2022-12-22 04:19:27 -05:00
// Kill the Timer
2022-12-22 01:15:51 -05:00
function stopTimer() {
2022-12-22 02:25:16 -05:00
showSuccessAlert("Shorts Timer Disabled!")
2022-12-22 01:15:51 -05:00
clearInterval(timer);
}
2022-12-22 04:19:27 -05:00
// Settng up success alerts
2022-12-22 02:25:16 -05:00
function showSuccessAlert(message) {
document.getElementById("view2").innerHTML = "< div class = \"alert alert-success \ " role = \"alert\" > < CENTER > " + message + "< / CENTER > < / div > ";
setInterval(function () {
2022-12-22 03:30:34 -05:00
document.getElementById("view2").innerHTML = "< BR > < BR > < BR > ";
2022-12-22 02:25:16 -05:00
2022-12-22 02:37:07 -05:00
}, 15000);
2022-12-22 02:25:16 -05:00
}
2022-12-22 04:19:27 -05:00
// Setting up Failed Alerts
2022-12-22 02:25:16 -05:00
function showFailAlert(message) {
document.getElementById("view2").innerHTML = "< div class = \"alert alert-danger \ " role = \"alert\" > < CENTER > " + message + "< / CENTER > < / div > ";
setInterval(function () {
console.log("60 seconds are up, going to next short");
2022-12-22 03:30:34 -05:00
document.getElementById("view2").innerHTML = "< BR > < BR > < BR > ";
2022-12-22 02:25:16 -05:00
2022-12-22 02:58:58 -05:00
}, 15000);
2022-12-22 02:25:16 -05:00
}
2022-12-22 04:19:27 -05:00
// This function is only used for the Refresh Button
2022-12-22 03:47:02 -05:00
function generateNewToken() {
fetch(rootURL + "/newToken")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("New Token Request Sent Successfully!")
return console.log("Command: New Token Request - SENT!")
} else {
showSuccessAlert("New Token Request FAILED!")
return console.log("Command: New Token Request FAILED!")
}
})
}
2022-12-22 04:19:27 -05:00
// Ask the user for the password.
2022-12-22 00:03:10 -05:00
let pass = prompt("Enter the password!", "");
2022-12-22 01:18:25 -05:00
let text;
2022-12-22 02:25:16 -05:00
2022-12-22 04:19:27 -05:00
// Ask the API if the password is correct
2022-12-22 00:03:10 -05:00
fetch(rootURL + "/checkPass?pass=" + pass)
.then(function (response) {
return response.json();
2022-12-22 04:19:27 -05:00
}) // Check for a positive 1 response back
2022-12-22 00:03:10 -05:00
.then(function (data) {
if (data == "1") {
2022-12-22 04:19:27 -05:00
// If they do not submit a password OR hit cancel, fail the login!
2022-12-22 00:03:10 -05:00
if (pass == null || pass == "") {
document.getElementById("view").innerHTML = "WOO"
} else {
2022-12-22 04:19:27 -05:00
// If we got this far, we have logged in, lets tell the user that
showSuccessAlert("You have logged in successfully!")
2022-12-22 03:47:02 -05:00
document.getElementById("view").innerHTML = "< CENTER > < IMG SRC = \"../images/icon.png\" > < / CENTER > < a href = \"javascript:window.open('help.html','Click for Key ShortCuts ! ' , ' width = 600,height=400')\" > Click for Key ShortCuts!< / a > < BR > < BR > < a href = \"javascript:window.open('input.html','Click to Send Text Imput ! ' , ' width = 600,height=400')\" > < button type = \"button\" class = \"btn btn-primary \ " > Open Text Input< / button > < / a > < BR > < BR > < button type = \"button\" class = \"btn btn-primary \ " onclick = \"startTimer()\" > Enable AutoScroll< / button > / < button type = \"button\" class = \"btn btn-primary \ " onclick = \"stopTimer()\" > Disable< / button > < BR > < BR > Commands Not Working? Issue a new Token using: < BR > < button type = \"button\" class = \"btn btn-primary \ " onclick = \"generateNewToken()\" > Request new Token< / button > ";
2022-12-22 00:03:10 -05:00
2022-12-22 04:19:27 -05:00
// Adding the event Listening Function
2022-12-22 00:03:10 -05:00
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
} else if (element.attachEvent) {
element.attachEvent("on" + eventName, callback);
} else {
element["on" + eventName] = callback;
}
}
2022-12-21 20:30:06 -05:00
2022-12-22 04:19:27 -05:00
// Lets now listen for events
2022-12-22 00:03:10 -05:00
addEvent(document, "keypress", function (e) {
e = e || window.event;
2022-12-21 20:30:06 -05:00
2022-12-22 04:19:27 -05:00
// Command UP
2022-12-22 00:03:10 -05:00
if (e.key == "w" || e.code == "Numpad8") {
fetch(rootURL + "/up")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("UP Sent Successfully!")
return console.log("Command: UP - SENT!")
} else {
showSuccessAlert("UP FAILED!")
return console.log("Command: UP FAILED!")
}
2022-12-22 00:03:10 -05:00
})
2022-12-21 20:30:06 -05:00
}
2022-12-22 00:03:10 -05:00
2022-12-22 04:19:27 -05:00
// Command LEFT
2022-12-22 00:03:10 -05:00
if (e.key == "a" || e.code == "Numpad4") {
fetch(rootURL + "/left")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("LEFT Sent Successfully!")
return console.log("Command: LEFT - SENT!")
} else {
showSuccessAlert("LEFT FAILED!")
return console.log("Command: LEFT FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command DOWN
2022-12-22 00:03:10 -05:00
if (e.key == "s" || e.key == "2") {
fetch(rootURL + "/down")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("DOWN Sent Successfully!")
return console.log("Command: DOWN - SENT!")
} else {
showSuccessAlert("DOWN FAILED!")
return console.log("Command: DOWN FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command RIGHT
2022-12-22 00:03:10 -05:00
if (e.key == "d" || e.code == "Numpad6") {
fetch(rootURL + "/right")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("RIGHT Sent Successfully!")
return console.log("Command: RIGHT - SENT!")
} else {
showSuccessAlert("UP FAILED!")
return console.log("Command: RIGHT FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command ENTER
2022-12-22 01:15:51 -05:00
if (e.key == "Enter" || e.code == "Numpad5") {
fetch(rootURL + "/enter")
2022-12-22 00:03:10 -05:00
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("ENTER Sent Successfully!")
return console.log("Command: ENTER - SENT!")
} else {
showSuccessAlert("ENTER FAILED!")
return console.log("Command: ENTEr FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command BACK
2022-12-22 00:03:10 -05:00
if (e.key == "x" || e.code == "NumpadDecimal") {
fetch(rootURL + "/back")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("BACK Sent Successfully!")
return console.log("Command: BACK - SENT!")
} else {
showSuccessAlert("BACK FAILED!")
return console.log("Command: BACK FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command VOL UP
2022-12-22 00:03:10 -05:00
if (e.key == "p" || e.code == "NumpadAdd") {
fetch(rootURL + "/volumeUp")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("VOLUME UP Sent Successfully!")
return console.log("Command: VOLUME UP - SENT!")
} else {
showSuccessAlert("VOLUME UP FAILED!")
return console.log("Command: VOLUME UP FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command VOL DOWN
2022-12-22 00:03:10 -05:00
if (e.key == "o" || e.code == "NumpadSubtract") {
fetch(rootURL + "/volumeDown")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("VOLUME DOWN Sent Successfully!")
return console.log("Command: VOLUME DOWN - SENT!")
} else {
showSuccessAlert("VOLUME DOWN FAILED!")
return console.log("Command: VOLUME DOWN FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Request new token using the R shortcut
2022-12-22 00:03:10 -05:00
if (e.key == "r") {
fetch(rootURL + "/newToken")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("New Token Request Sent Successfully!")
return console.log("Command: New Token Request - SENT!")
} else {
showSuccessAlert("New Token Request FAILED!")
return console.log("Command: New Token Request FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command MUTE
2022-12-22 00:03:10 -05:00
if (e.key == "m" || e.code == "Numpad0") {
fetch(rootURL + "/mute")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("Mute Sent Successfully!")
return console.log("Command: BACK - SENT!")
} else {
showSuccessAlert("Mute FAILED!")
return console.log("Command: Mute FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command Picture Mode
2022-12-22 00:03:10 -05:00
if (e.key == "l") {
fetch(rootURL + "/pmode")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("Picture Mode Sent Successfully!")
return console.log("Command: Picutr Mode - SENT!")
} else {
showSuccessAlert("Picture Mode FAILED!")
return console.log("Command: Picture Mode FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
2022-12-22 04:19:27 -05:00
// Command HOME
2022-12-22 01:15:51 -05:00
if (e.key == "h") {
2022-12-22 00:03:10 -05:00
fetch(rootURL + "/home")
.then(function (response) {
return response.json();
})
.then(function (data) {
2022-12-22 02:25:16 -05:00
if (data == 1) {
showSuccessAlert("HOME Sent Successfully!")
return console.log("Command: HOME - SENT!")
} else {
showSuccessAlert("HOME FAILED!")
return console.log("Command: HOME FAILED!")
}
2022-12-22 00:03:10 -05:00
})
}
});
}
} else {
2022-12-22 04:19:27 -05:00
// Login Failed!
2022-12-22 03:40:32 -05:00
showFailAlert("The password was incorrect!")
document.getElementById("view").innerHTML = "< meta http-equiv = \"refresh\" content = 3; > "
2022-12-22 00:03:10 -05:00
}
})
< / script >
2022-12-22 04:19:27 -05:00
<!-- END MAIN JS -->
2022-12-22 00:03:10 -05:00
< / head >
< body >
2022-12-22 04:19:27 -05:00
<!-- MAIN VIEWPORT -->
2022-12-22 02:25:16 -05:00
2022-12-22 04:19:27 -05:00
< center >
2022-12-22 00:03:10 -05:00
< div id = "view" > < / div >
< center >
2022-12-22 04:19:27 -05:00
<!-- END MAIN VIEWPORT -->
2022-12-22 00:03:10 -05:00
< / body >
2022-12-21 20:23:42 -05:00
< / html >