remove reduntant popup elements

This commit is contained in:
simon 2022-11-24 16:31:13 +07:00
parent e87468900c
commit 122114d099
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 2 additions and 104 deletions

View File

@ -17,7 +17,6 @@
<span>v0.0.3</span> <span>v0.0.3</span>
</div> </div>
<hr> <hr>
<div class="youtube-page" id="download"></div>
<form class="login-form"> <form class="login-form">
<label for="url">Tube Archivist IP:</label> <label for="url">Tube Archivist IP:</label>
<input type="text" id="url" name="url"> <input type="text" id="url" name="url">

View File

@ -141,68 +141,6 @@ function setStatusIcon(connected) {
} }
function downloadEvent() {
let button = document.getElementById("downloadButton");
let payload = {
"download": {
"url": button.getAttribute("data-id")
}
};
function handleResponse(message) {
console.log("popup.js response: " + JSON.stringify(message));
browserType.storage.local.remove("youtube").then(response => {
let download = document.getElementById("download");
download.innerHTML = ""
let message = document.createElement("p");
message.innerText = "Download link sent to Tube Archivist"
download.appendChild(message)
download.appendChild(document.createElement("hr"));
})
}
function handleError(error) {
console.log(`Error: ${error}`);
}
let sending = browserType.runtime.sendMessage(payload);
sending.then(handleResponse, handleError)
}
function subscribeEvent() {
let button = document.getElementById("subscribeButton");
let payload = {
"subscribe": {
"url": button.getAttribute("data-id")
}
};
function handleResponse(message) {
console.log("popup.js response: " + JSON.stringify(message));
browserType.storage.local.remove("youtube").then(response => {
let download = document.getElementById("download");
download.innerHTML = ""
let message = document.createElement("p");
message.innerText = "Subscribe link sent to Tube Archivist"
download.appendChild(message)
download.appendChild(document.createElement("hr"));
})
}
function handleError(error) {
console.log(`Error: ${error}`);
}
let sending = browserType.runtime.sendMessage(payload);
sending.then(handleResponse, handleError)
}
// fill in form // fill in form
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", async () => {
@ -241,41 +179,4 @@ document.addEventListener("DOMContentLoaded", async () => {
setCookiesOptions(result) setCookiesOptions(result)
}) })
browserType.storage.local.get("youtube", function(result) {
if (result.youtube) {
createButtons(result);
}
})
}) })
function createButtons(result) {
let download = document.getElementById("download");
let linkType = document.createElement("h3");
linkType.innerText = result.youtube.type.charAt(0).toUpperCase() + result.youtube.type.slice(1);
let title = document.createElement("p");
title.innerText = result.youtube.title;
// dl button
let downloadButton = document.createElement("button");
downloadButton.innerText = "download";
downloadButton.id = "downloadButton";
downloadButton.setAttribute("data-id", result.youtube.url);
downloadButton.addEventListener("click", function(){downloadEvent()}, false);
// subscribe button
let subscribeButton = document.createElement("button");
subscribeButton.innerText = "subscribe";
subscribeButton.id = "subscribeButton";
subscribeButton.setAttribute("data-id", result.youtube.url);
subscribeButton.addEventListener("click", function(){subscribeEvent()}, false);
download.appendChild(linkType);
download.appendChild(title);
download.appendChild(downloadButton);
download.appendChild(subscribeButton);
download.appendChild(document.createElement("hr"));
}

View File

@ -48,8 +48,7 @@ hr {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.submit button, .submit button {
.youtube-page button {
margin: 10px; margin: 10px;
border-radius: 0; border-radius: 0;
padding: 5px 13px; padding: 5px 13px;
@ -58,8 +57,7 @@ hr {
background-color: #259485; background-color: #259485;
color: #ffffff; color: #ffffff;
} }
.submit button:hover, .submit button:hover {
.youtube-page button:hover {
background-color: #97d4c8; background-color: #97d4c8;
transform: scale(1.05); transform: scale(1.05);
color: #00202f; color: #00202f;