Made work
This commit is contained in:
parent
a27898c41b
commit
5417618084
@ -1,7 +1 @@
|
|||||||
function openPage() {
|
// console.log(document.querySelector(".video-stream").getCurrentTime());
|
||||||
browser.tabs.create({
|
|
||||||
url: "https://youtube.com"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.browserAction.onClicked.addListener(openPage);
|
|
||||||
|
|||||||
@ -1,19 +1,28 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Upto",
|
"name": "Upto",
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
|
|
||||||
"description": "Uploads the URL+timestamp to the uptoserver",
|
"description": "Uploads the URL+timestamp to the uptoserver",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "icons/48.png"
|
"48": "icons/48.png"
|
||||||
},
|
},
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"]
|
||||||
|
},
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["*://*.youtube.com/*"],
|
||||||
|
"js": ["test.js"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permissions": ["*://home.lovelynet.net/*", "webRequest"],
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"browser_style": true,
|
"browser_style": true,
|
||||||
"default_popup": "popup/choose.html",
|
"default_popup": "popup/choose.html",
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"16": "icons/48.png"
|
"16": "icons/48.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
test.js
Normal file
40
test.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
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);
|
||||||
Loading…
x
Reference in New Issue
Block a user