Skip to content

Commit

Permalink
Merge branch 'master' of github.com:not-nullptr/OldTwitter
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Jul 15, 2024
2 parents 4b16746 + 4adf839 commit 56e29e3
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 16 deletions.
13 changes: 11 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,5 +634,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)" }
}
14 changes: 7 additions & 7 deletions _locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
"message": "Varsayılan bağlantı rengi"
},
"font": {
"message": "Font"
"message": "Yazı tipi"
},
"color_sync": {
"message": "Bağlantı rengi eşitlenimi"
Expand Down Expand Up @@ -854,10 +854,10 @@
}
},
"last_searches": {
"message": "Last searches"
"message": "Son aramalar"
},
"saved_searches": {
"message": "Saved searches"
"message": "Kaydedilmiş aramalar"
},
"everyone": {
"message": "Herkese açık",
Expand Down Expand Up @@ -960,7 +960,7 @@
"message": "Konuşmayı susturmayı geri al"
},
"no_big_font": {
"message": "Kısa/popüler tweetler için büyük fontu devre dışı bırak"
"message": "Kısa/popüler tweetler için büyük yazı tipini devre dışı bırak"
},
"emoji": {
"message": "Emoji"
Expand Down Expand Up @@ -1398,7 +1398,7 @@
"description": "You should probably use word 'Profile' in your language"
},
"tweet_text_font": {
"message": "Tweet yazı fontu"
"message": "Tweet yazı tipi"
},
"use_old_default_profile": {
"message": "Varsayılan profil fotoğrafını yumurta yap"
Expand Down Expand Up @@ -1573,7 +1573,7 @@
"message": "Karanlık mod değişkenleri"
},
"css_theme_hint": {
"message": "Lütfen 'göz-kanatıcı' veya diğer herhangi rahatsız edici şeyler yapmayın. (Örneğin takip butonunu çok büyük yapmak gibi), bunun yüzünden erişimini kaybedersin.<br><br>Senin CSS'in kullanıcının ayarladığı temanın üzerine yazılır.<br><br>Resimleri için sadece i.imgur.com, fontlar için de sadece fonts.googleapis.com kullanabilirsin (veya <a target='_blank' href='https://dimden.dev/fonts/'>'daki fontlar</a>).<br><br>You can see list of CSS variables <a href='https://github.com/dimdenGD/OldTwitter/blob/5e235a0a7435083428bddd7d43123e2afa344cba/scripts/injection.js#L252' target='_blank'>here</a>.<br><br>To target specific theme you can use <code>.body-dark</code>, <code>.body-pitch-black</code> (pitch black mode will also include <code>.body-dark</code>) and <code>.body-light</code> classes."
"message": "Lütfen 'göz-kanatıcı' veya diğer herhangi rahatsız edici şeyler yapmayın. (Örneğin takip butonunu çok büyük yapmak gibi), bunun yüzünden erişimini kaybedersin.<br><br>Senin CSS'in kullanıcının ayarladığı temanın üzerine yazılır.<br><br>Resimleri için sadece i.imgur.com, yazı tipleri için de sadece fonts.googleapis.com kullanabilirsin (veya <a target='_blank' href='https://dimden.dev/fonts/'>'daki yazı tiplerini</a>).<br><br>You can see list of CSS variables <a href='https://github.com/dimdenGD/OldTwitter/blob/5e235a0a7435083428bddd7d43123e2afa344cba/scripts/injection.js#L252' target='_blank'>here</a>.<br><br>To target specific theme you can use <code>.body-dark</code>, <code>.body-pitch-black</code> (pitch black mode will also include <code>.body-dark</code>) and <code>.body-light</code> classes."
},
"profile_colors_moved": {
"message": "Renk senkronizasyonunu profiline bağla (Edit butonunun solundaki kalem butonu)."
Expand Down Expand Up @@ -1814,7 +1814,7 @@
"message": "Eklenti uyumluluk modu (Başka bir eklentinin OldTwitter ile aynı anda çalışmasını istiyorsanız etkinleştirin, eğer eklenti hala çalışmıyorsa bunu kapatın (büyük ihtimalle çalışmayacak), çünkü bu seçenek sayfayı kastırabilir)"
},
"enter_custom_font_name": {
"message": "Özel font ismi girin"
"message": "Özel yazı tipi ismi girin"
},
"disable_data_saver": {
"message": "Veri kaydediciyi mobil verideyken kapatın",
Expand Down
16 changes: 15 additions & 1 deletion layouts/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,20 @@ <h1>__MSG_custom_css__</h1><br>
<button class="nice-button" id="custom-css-save">__MSG_save_css__</button>
<br>
<hr>
<h1>__MSG_custom_downloadtemplate__</h1><br>
<span>__MSG_custom_downloadtemplate_text__</span><br>
<br><span>__MSG_custom_downloadtemplate_hintName1__</span>
<br><span>__MSG_custom_downloadtemplate_hintName2__</span>
<br><span>__MSG_custom_downloadtemplate_hintTime__</span>
<br><span>__MSG_custom_downloadtemplate_hintExtension__</span>
<br><span>__MSG_custom_downloadtemplate_hintID__</span>
<br><span>__MSG_custom_downloadtemplate_hintIndex__</span>
<br><br>
<div class="setting">
<input type="text" style="width: 550px;" id="custom-download" placeholder="{user_screen_name}_{timestamp}_{id}{index}.{extension}"></input>
</div>
<button class="nice-button" id="custom-download-save">__MSG_save_downloadtemplate__</button>
<hr>
<h1>__MSG_advanced_options__</h1><br>
<div class="setting" id="advanced-settings">
<button class="nice-button" id="import-settings">__MSG_import_settings__</button>
Expand Down Expand Up @@ -443,4 +457,4 @@ <h1>__MSG_who_to_follow__</h1><br>
</div>
</main>
</body>
</html>
</html>
13 changes: 12 additions & 1 deletion layouts/settings/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ setTimeout(async () => {
let disableFindHotkey = document.getElementById('disable-find-hotkey');
let customCSS = document.getElementById('custom-css');
let customCSSSave = document.getElementById('custom-css-save');
let customDownloadTemplate = document.getElementById('custom-download');
let customDownloadTemplateSave = document.getElementById('custom-download-save');
let savePreferredQuality = document.getElementById('save-preferred-quality');
let roundAvatars = document.getElementById('round-avatars-switch');
let modernUI = document.getElementById('modern-ui-switch');
Expand Down Expand Up @@ -913,6 +915,14 @@ setTimeout(async () => {
console.error("Error saving CSS to DB:", error);
});
});
customDownloadTemplateSave.addEventListener('click', () => {
let val = customDownloadTemplate.value;

vars.customDownloadTemplate = val;
chrome.storage.sync.set({
customDownloadTemplate: val
}, () => { });
});
autotranslateLanguageList.addEventListener('change', () => {
addAutotranslateLanguage.disabled = autotranslateLanguageList.value === 'select';
});
Expand Down Expand Up @@ -1053,6 +1063,7 @@ setTimeout(async () => {
writeCSSToDB(vars.customCSS)
}
customCSS.value = await readCSSFromDB();
customDownloadTemplate.value = vars.customDownloadTemplate;
document.getElementById('stt-div').hidden = vars.timelineType !== 'algo' && vars.timelineType !== 'algov2';
savePreferredQuality.checked = !!vars.savePreferredQuality;
showOriginalImages.checked = !!vars.showOriginalImages;
Expand Down Expand Up @@ -1288,4 +1299,4 @@ setTimeout(async () => {
setInterval(updateUserData, 60000 * 3);
setInterval(() => renderDiscovery(false), 60000 * 15);
setInterval(renderTrends, 60000 * 5);
}, 50);
}, 50);
10 changes: 8 additions & 2 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function loadVars() {
'acknowledgedCustomizationButton', 'modernUI', 'showExactValues', 'hideTimelineTypes', 'autotranslateLanguages',
'autotranslationMode', 'muteVideos', 'dontPauseVideos', 'showUserPreviewsOnMobile', 'systemDarkMode', 'localizeDigit',
'disableRetweetHotkey', 'disableLikeHotkey', 'disableFindHotkey', 'extensionCompatibilityMode', 'disableDataSaver', 'disableAcceptType',
'showUserFollowerCountsInLists', 'showQuoteCount', 'hideUnfollowersPage', 'transitionProfileBanner'
'showUserFollowerCountsInLists', 'showQuoteCount', 'hideUnfollowersPage', 'transitionProfileBanner', 'customDownloadTemplate'
], data => {
// default variables
if(typeof(data.linkColorsInTL) !== 'boolean') {
Expand Down Expand Up @@ -83,6 +83,12 @@ async function loadVars() {
customCSSVariables: ''
}, () => {});
}
if(typeof(data.customDownloadTemplate) !== 'string') {
data.customDownloadTemplate = '';
chrome.storage.sync.set({
customDownloadTemplate: ''
}, () => {});
}
if(typeof(data.copyLinksAs) !== 'string') {
data.copyLinksAs = 'twitter.com';
chrome.storage.sync.set({
Expand Down Expand Up @@ -240,4 +246,4 @@ async function loadVars() {
};

console.log(1, vars);
loadVars();
loadVars();
16 changes: 15 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3595,8 +3595,22 @@ async function appendTweet(t, timelineContainer, options = {}) {
let extension = url.pathname.split('.').pop();
let _index = t.extended_entities.media.length > 1 ? "_"+(index+1) : "";
let filename = `${t.user.screen_name}_${ts}_${t.id_str}${_index}.${extension}`;
a.download = filename;
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
24 changes: 22 additions & 2 deletions scripts/tweetviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2458,8 +2458,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 = "";
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 56e29e3

Please sign in to comment.