mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 11:40:13 +00:00
remove reduntant popup elements
This commit is contained in:
parent
e87468900c
commit
122114d099
@ -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">
|
||||
|
@ -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"));
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user