2020-06-13 16:47:47 +10:00

41 lines
1.1 KiB
JavaScript

function getTime() {
// Youtube can get fucked, this is the worst way I can get this to work -_-
// console.log("Why does this not fucking work");
let url = window.location.href;
let d = document.querySelector(".video-stream");
return url + "&t=" + Math.ceil(d.currentTime);
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function getTitleHTMLElement() {
await sleep(2000);
let test = document.querySelector("ytd-video-primary-info-renderer");
return test;
}
function postURL(url) {
console.log(url);
fetch("https://home.lovelynet.net/testingapi/", {
method: "POST",
body: JSON.stringify({
url: url,
authcode: "VGhlIGF1dGhjb2RlIGlzIHRoZSBhdXRoY29kZQ==",
}),
})
.then((resp) => resp.text())
.then((data) => console.log(data))
.catch((err) => console.log(err));
}
ele = document.createElement("p");
text = document.createTextNode("Save Timestamp");
ele.addEventListener("click", () => postURL(getTime()));
ele.appendChild(text);
getTitleHTMLElement().then((data) => data.appendChild(ele));
// setInterval(getTime, 10);
console.log(test);