mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 03:30:14 +00:00
add autostart option
This commit is contained in:
parent
62fa12d218
commit
7ce3835ef3
@ -101,8 +101,13 @@ async function verifyConnection() {
|
||||
|
||||
// send youtube link from injected buttons
|
||||
async function download(url) {
|
||||
let apiURL = 'api/download/';
|
||||
let autostart = await browserType.storage.local.get('autostart');
|
||||
if (Object.keys(autostart).length > 0 && autostart.autostart.checked) {
|
||||
apiURL += '?autostart=true';
|
||||
}
|
||||
return await sendData(
|
||||
'api/download/',
|
||||
apiURL,
|
||||
{
|
||||
data: [
|
||||
{
|
||||
|
@ -30,8 +30,14 @@
|
||||
<hr>
|
||||
<p>Options:</p>
|
||||
<div class="options">
|
||||
<input type="checkbox" id="sendCookies" name="sendCookies">
|
||||
<span>Sync YouTube cookies</span><span id="sendCookiesStatus"></span>
|
||||
<div>
|
||||
<input type="checkbox" id="sendCookies" name="sendCookies">
|
||||
<span>Sync YouTube cookies</span><span id="sendCookiesStatus"></span>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="autostart" name="autostart">
|
||||
<span>Autostart Downloads</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="icons">
|
||||
|
@ -73,6 +73,11 @@ document.getElementById('sendCookies').addEventListener('click', function () {
|
||||
sendCookie();
|
||||
});
|
||||
|
||||
// autostart
|
||||
document.getElementById('autostart').addEventListener('click', function () {
|
||||
toggleAutostart();
|
||||
});
|
||||
|
||||
function sendCookie() {
|
||||
console.log('popup send cookie');
|
||||
clearError();
|
||||
@ -104,6 +109,18 @@ function sendCookie() {
|
||||
sending.then(handleResponse, handleError);
|
||||
}
|
||||
|
||||
function toggleAutostart() {
|
||||
let checked = document.getElementById('autostart').checked;
|
||||
let toStore = {
|
||||
autostart: {
|
||||
checked: checked,
|
||||
},
|
||||
};
|
||||
browserType.storage.local.set(toStore, function () {
|
||||
console.log('stored option: ' + JSON.stringify(toStore));
|
||||
});
|
||||
}
|
||||
|
||||
// send ping message to TA backend
|
||||
function pingBackend() {
|
||||
clearError();
|
||||
@ -190,6 +207,16 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
setCookieState();
|
||||
}
|
||||
|
||||
function setAutostartOption(result) {
|
||||
console.log(result);
|
||||
if (!result.autostart || result.autostart.checked === false) {
|
||||
console.log('autostart not set');
|
||||
return;
|
||||
}
|
||||
console.log('set options: ' + JSON.stringify(result));
|
||||
document.getElementById('autostart').checked = true;
|
||||
}
|
||||
|
||||
browserType.storage.local.get('access', function (result) {
|
||||
onGot(result);
|
||||
});
|
||||
@ -197,4 +224,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
browserType.storage.local.get('sendCookies', function (result) {
|
||||
setCookiesOptions(result);
|
||||
});
|
||||
|
||||
browserType.storage.local.get('autostart', function (result) {
|
||||
setAutostartOption(result);
|
||||
});
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ hr {
|
||||
color: #00202f;
|
||||
}
|
||||
.options {
|
||||
display: flex;
|
||||
display: block;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.options span {
|
||||
|
Loading…
Reference in New Issue
Block a user