Added lukes button and made good

This commit is contained in:
Benjamyn Love 2020-06-13 17:02:20 +10:00
parent 5417618084
commit 19cb309d58
2 changed files with 4 additions and 2 deletions

View File

@ -13,7 +13,7 @@
}, },
"content_scripts": [ "content_scripts": [
{ {
"matches": ["*://*.youtube.com/*"], "matches": ["*://*.youtube.com/*", "*://*.youtu.be/*"],
"js": ["test.js"] "js": ["test.js"]
} }
], ],

View File

@ -2,6 +2,8 @@ function getTime() {
// Youtube can get fucked, this is the worst way I can get this to work -_- // Youtube can get fucked, this is the worst way I can get this to work -_-
// console.log("Why does this not fucking work"); // console.log("Why does this not fucking work");
let url = window.location.href; let url = window.location.href;
url = url.split("&t")[0];
url = url.split("&start")[0];
let d = document.querySelector(".video-stream"); let d = document.querySelector(".video-stream");
return url + "&t=" + Math.ceil(d.currentTime); return url + "&t=" + Math.ceil(d.currentTime);
} }
@ -30,7 +32,7 @@ function postURL(url) {
.catch((err) => console.log(err)); .catch((err) => console.log(err));
} }
ele = document.createElement("p"); ele = document.createElement("button");
text = document.createTextNode("Save Timestamp"); text = document.createTextNode("Save Timestamp");
ele.addEventListener("click", () => postURL(getTime())); ele.addEventListener("click", () => postURL(getTime()));
ele.appendChild(text); ele.appendChild(text);