Frontend: proxy checkbox

This commit is contained in:
DarkCat09 2024-05-28 13:27:53 +04:00
parent 9071017dbf
commit 312a688c89
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
2 changed files with 9 additions and 4 deletions

View file

@ -15,11 +15,13 @@
<div> <div>
<select id="site-select"> <select id="site-select">
<option value="youtube" selected>YouTube</option> <option value="youtube" selected>YouTube</option>
<option value="yt_proxied">YT proxied</option>
<option value="soundcloud">SoundCloud</option> <option value="soundcloud">SoundCloud</option>
<option value="yandex">Yandex Music</option> <option value="yandex">Yandex Music</option>
</select> </select>
</div> </div>
<div>
<label for="proxy-cb"><input type="checkbox" id="proxy-cb">Proxy</label>
</div>
<div> <div>
<button type="button" id="items-btn">Get playlist items</button> <button type="button" id="items-btn">Get playlist items</button>
</div> </div>

View file

@ -3,14 +3,15 @@ addEventListener('DOMContentLoaded', () => {
const urlField = document.getElementById('url') const urlField = document.getElementById('url')
/** @type{HTMLSelectElement} */ /** @type{HTMLSelectElement} */
const site = document.getElementById('site-select') const site = document.getElementById('site-select')
/** @type{HTMLInputElement} */
const proxyFlag = document.getElementById('proxy-cb')
document.getElementById('guess-site-btn').addEventListener('click', () => { document.getElementById('guess-site-btn').addEventListener('click', () => {
const url = urlField.value const url = urlField.value
if (url.includes('/watch?v=') || url.includes('/playlist?list=')) { if (url.includes('/watch?v=') || url.includes('/playlist?list=')) {
if (site.value == 'yt_proxied') {
return
}
site.value = 'youtube' site.value = 'youtube'
} else if (url.includes('soundcloud.com/')) {
site.value = 'soundcloud'
} else if (url.includes('://music.yandex.')) { } else if (url.includes('://music.yandex.')) {
site.value = 'yandex' site.value = 'yandex'
} }
@ -28,6 +29,7 @@ addEventListener('DOMContentLoaded', () => {
action: 'list', action: 'list',
site: site.value, site: site.value,
url: urlField.value, url: urlField.value,
proxy: proxyFlag.checked,
})) }))
logField.textContent = '' // clear logField.textContent = '' // clear
}) })
@ -37,6 +39,7 @@ addEventListener('DOMContentLoaded', () => {
action: 'download', action: 'download',
site: site.value, site: site.value,
url: urlField.value, url: urlField.value,
proxy: proxyFlag.checked,
items: items, items: items,
})) }))
items = [] items = []