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>
</div>
<hr>
<div class="youtube-page" id="download"></div>
<form class="login-form">
<label for="url">Tube Archivist IP:</label>
<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
document.addEventListener("DOMContentLoaded", async () => {
@ -241,41 +179,4 @@ document.addEventListener("DOMContentLoaded", async () => {
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;
justify-content: center;
}
.submit button,
.youtube-page button {
.submit button {
margin: 10px;
border-radius: 0;
padding: 5px 13px;
@ -58,8 +57,7 @@ hr {
background-color: #259485;
color: #ffffff;
}
.submit button:hover,
.youtube-page button:hover {
.submit button:hover {
background-color: #97d4c8;
transform: scale(1.05);
color: #00202f;