Skip to content

Commit

Permalink
update other renderer & english localization
Browse files Browse the repository at this point in the history
  • Loading branch information
suwacrab committed Jul 15, 2024
1 parent d9d694a commit 627a8f0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
20 changes: 10 additions & 10 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,6 @@
"save_vars": { "message": "Save variables" },
"custom_css_text": { "message": "Custom CSS to add on every page." },
"save_css": { "message": "Save CSS" },
"custom_downloadtemplate": { "message": "Custom download template" },
"custom_downloadtemplate_text": { "message": "Allows you to customize the names of the files when downloading a tweet's media." },
"save_downloadtemplate": { "message": "Save download template" },
"custom_downloadtemplate_hintName1": { "message": "<code>{user_name}</code>: User's name." },
"custom_downloadtemplate_hintName2": { "message": "<code>{user_screen_name}</code>: User's account name. (Example: @dril)" },
"custom_downloadtemplate_hintTime": { "message": "<code>{timestamp}</code>: Tweet's post date & time." },
"custom_downloadtemplate_hintExtension": { "message": "<code>{extension}</code>: Downloaded tweet's file extension." },
"custom_downloadtemplate_hintID": { "message": "<code>{id}</code>: Tweet's ID." },
"custom_downloadtemplate_hintIndex": { "message": "<code>{index}</code>: Index for each file to download. (for posts with multiple media)" },
"error_setting_color": { "message": "Error setting link color" },
"link_color_set": { "message": "Link color set!" },
"retweeted_by": { "message": "Retweeted by" },
Expand Down Expand Up @@ -641,5 +632,14 @@
"anniversary_tweet": { "message": "Do you remember when you joined Twitter? I do!\n#MyTwitterAnniversary" },
"you_shared_tweet": { "message": "You shared a tweet" },
"user_shared_tweet": { "message": "$NAME$ shared a tweet", "placeholders": { "name": { "content": "Display Name" } } },
"transition_profile_banner": { "message": "Use transition on profile banner" }
"transition_profile_banner": { "message": "Use transition on profile banner" },
"custom_downloadtemplate": { "message": "Custom download template" },
"custom_downloadtemplate_text": { "message": "Allows you to customize the names of the files when downloading a tweet's media." },
"save_downloadtemplate": { "message": "Save download template" },
"custom_downloadtemplate_hintName1": { "message": "<code>{user_name}</code>: User's name." },
"custom_downloadtemplate_hintName2": { "message": "<code>{user_screen_name}</code>: User's account name. (Example: @dril)" },
"custom_downloadtemplate_hintTime": { "message": "<code>{timestamp}</code>: Tweet's post date & time." },
"custom_downloadtemplate_hintExtension": { "message": "<code>{extension}</code>: Downloaded tweet's file extension." },
"custom_downloadtemplate_hintID": { "message": "<code>{id}</code>: Tweet's ID." },
"custom_downloadtemplate_hintIndex": { "message": "<code>{index}</code>: Index for each file to download. (for posts with multiple media)" }
}
24 changes: 22 additions & 2 deletions scripts/tweetviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2455,8 +2455,28 @@ class TweetViewer {
downloading = false;
let a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = media.type === 'photo' ? media.media_url_https.split('/').pop() : media.video_info.variants[0].url.split('/').pop();
a.download = a.download.split('?')[0];

let ts = new Date(t.created_at).toISOString().split("T")[0];
let extension = url.split('.').pop();
//let _index = t.extended_entities.media.length > 1 ? "_"+(index+1) : "";
let _index = 1;
let filename = `${t.user.screen_name}_${ts}_${t.id_str}${_index}.${extension}`;
let filename_template = vars.customDownloadTemplate;

// use the filename from the user's custom download template, if any
if(filename_template && (filename_template.length > 0)) {
const filesave_map = {
"user_screen_name": t.user.screen_name,
"user_name": t.user.name,
"extension": extension,
"timestamp": ts,
"id": t.id_str,
"index": _index
};
filename = filename_template.replace(/\{([\w]+)\}/g, (_, key) => filesave_map[key]);
}

a.download = filename;
a.click();
a.remove();
}).catch(e => {
Expand Down

0 comments on commit 627a8f0

Please sign in to comment.