Cookie Validation Button (#242)
* Added cookie validate button & message placeholder * Added handleCookieValidate(), postCookieValidate() * show validation only if enbled, add processing message for immediate feedback Co-authored-by: simon <simobilleter@gmail.com>
This commit is contained in:
parent
fcac10a6ce
commit
4eba36f7a0
|
@ -119,7 +119,12 @@
|
|||
<div class="settings-item">
|
||||
<p>Import YouTube cookie: <span class="settings-current">{{ config.downloads.cookie_import }}</span><br></p>
|
||||
<i>Place your cookie file named <span class="settings-current">cookies.google.txt</span> in /cache/import before enabling.</i><br>
|
||||
{{ app_form.downloads_cookie_import }}
|
||||
{{ app_form.downloads_cookie_import }}<br>
|
||||
{% if config.downloads.cookie_import %}
|
||||
<div id="cookieMessage">
|
||||
<button onclick="handleCookieValidate()" type="button" id="cookieButton">Validate Cookie File</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
|
|
|
@ -699,6 +699,24 @@ function postSponsorSegmentVote(videoId, uuid, vote) {
|
|||
apiRequest(apiEndpoint, "POST", data);
|
||||
}
|
||||
|
||||
function handleCookieValidate() {
|
||||
document.getElementById("cookieButton").remove();
|
||||
var cookieMessageElement = document.getElementById("cookieMessage");
|
||||
cookieMessageElement.innerHTML = `<span>Processing.</span>`;
|
||||
response = postCookieValidate();
|
||||
if (response.cookie_validated == true) {
|
||||
cookieMessageElement.innerHTML = `<span>The cookie file is valid.</span>`;
|
||||
} else {
|
||||
cookieMessageElement.innerHTML = `<span class="danger-zone">Warning, the cookie file is invalid.</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Check youtube cookie settings
|
||||
function postCookieValidate() {
|
||||
var apiEndpoint = "/api/cookie/";
|
||||
return apiRequest(apiEndpoint, "POST");
|
||||
}
|
||||
|
||||
// Makes api requests when passed an endpoint and method ("GET", "POST", "DELETE")
|
||||
function apiRequest(apiEndpoint, method, data) {
|
||||
const xhttp = new XMLHttpRequest();
|
||||
|
|
Loading…
Reference in New Issue