Re-init download button in case of error

This commit is contained in:
TC
2020-11-22 10:23:20 +01:00
parent 2937db3dde
commit 4d4aadfdfc

View File

@ -19,6 +19,14 @@ const observer = new MutationObserver((mutations, observer) => {
}
});
const reinit = () => {
if (!progress) {
console.warn("Cannot update progress");
} else {
progress.innerHTML = "Download";
}
};
global.download = () => {
const videoUrl = window.location.href;
@ -33,14 +41,9 @@ global.download = () => {
},
(error) => {
triggerAction(CHANNEL, ACTIONS.ERROR, error);
reinit();
},
() => {
if (!progress) {
console.warn("Cannot update progress");
} else {
progress.innerHTML = "Download";
}
}
reinit
);
};