Made work
This commit is contained in:
parent
a27898c41b
commit
5417618084
@ -1,7 +1 @@
|
||||
function openPage() {
|
||||
browser.tabs.create({
|
||||
url: "https://youtube.com"
|
||||
});
|
||||
}
|
||||
|
||||
browser.browserAction.onClicked.addListener(openPage);
|
||||
// console.log(document.querySelector(".video-stream").getCurrentTime());
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "Upto",
|
||||
"version": "0.1",
|
||||
@ -9,11 +8,21 @@
|
||||
"icons": {
|
||||
"48": "icons/48.png"
|
||||
},
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://*.youtube.com/*"],
|
||||
"js": ["test.js"]
|
||||
}
|
||||
],
|
||||
"permissions": ["*://home.lovelynet.net/*", "webRequest"],
|
||||
"browser_action": {
|
||||
"browser_style": true,
|
||||
"default_popup": "popup/choose.html",
|
||||
"default_icon": {
|
||||
"16": "icons/48.png"
|
||||
}
|
||||
"browser_style": true,
|
||||
"default_popup": "popup/choose.html",
|
||||
"default_icon": {
|
||||
"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