Skip to content

Commit

Permalink
Correctly show the errors from _downloadVideoMediaEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
AlttiRi authored Jul 24, 2024
1 parent 44f6cbd commit eb8856b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions twitter-click-and-save.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Twitter Click'n'Save
// @version 1.11.2-2024.05.29
// @version 1.11.3-2024.07.24
// @namespace gh.alttiri
// @description Add buttons to download images and videos in Twitter, also does some other enhancements.
// @match https://twitter.com/*
Expand Down Expand Up @@ -50,6 +50,8 @@ const Tweet = hoistTweet();
const Features = hoistFeatures();
const I18N = getLanguageConstants();



// ---------------------------------------------------------------------------------------------------------------------

function getStorageNames() {
Expand Down Expand Up @@ -865,12 +867,21 @@ function hoistFeatures() {
btn.title = "API.getVideoInfo Error";
throw new Error("API.getVideoInfo Error");
}

await Features._downloadVideoMediaEntry(mediaEntry, btn, id);
try {
await Features._downloadVideoMediaEntry(mediaEntry, btn, id);
} catch (err) {
console.error(err);
btn.classList.add("ujs-error");
btnErrorTextElem.textContent = "Error";
btn.title = err.message + " Error";
}
Features._markButtonAsDownloaded(btn);
}

static async _downloadVideoMediaEntry(mediaEntry, btn, id /* of original tweet */) {
if (!mediaEntry) {
throw new Error("No mediaEntry found");
}
const {
screen_name: author,
tweet_id: videoTweetId,
Expand Down

0 comments on commit eb8856b

Please sign in to comment.