diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3c558f75..1c00c80d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -520,7 +520,7 @@ "show_user_previews_on_mobile": { "message": "Show user previews on hold (this can be annoying)", "description": "This option only appears on mobile" }, "separate_text": { "message": "Separate text", "description": "This option appears in three-dot menu of tweets only on mobile and makes text bigger and adds padding on top and bottom on tap" }, "leave_conversation": { "message": "Are you sure you want to leave/remove this conversation?"}, - "autotranslation_help1": { "message": "This function can find the tweets and trigger translation automatically, without having to click the button manually."}, + "autotranslation_help1": { "message": "This function can find the tweets and trigger translation automatically, without having to click the button manually."}, "autotranslation_help2": { "message": "To use it, select autotranslation mode and set the language list. The tweets that meet the conditions will be automatically translated."}, "autotranslation_help3": { "message": "Specifically:"}, "autotranslation_help4": { "message": "\"Translate when in language list\" with no languages set cause function to be disabled (default)."}, @@ -645,5 +645,6 @@ "nonexistent_user_desc": { "message": "Try searching for another." }, "suspended_user": { "message": "Account suspended" }, "suspended_user_desc": { "message": "The profile you are trying to view has been suspended." }, - "show_boring_indicators": { "message": "Show indicator in followers/following page if last tweet of person is a retweet/quote/non-existent/old" } + "show_boring_indicators": { "message": "Show indicator in followers/following page if last tweet of person is a retweet/quote/non-existent/old" }, + "hide_original_languages":{"message": "Hide original languages when translated" } } diff --git a/_locales/he/messages.json b/_locales/he/messages.json index 6e0a2200..1e8565f7 100644 --- a/_locales/he/messages.json +++ b/_locales/he/messages.json @@ -858,5 +858,8 @@ "no_big_font": { "message": "ביטול גופן מוגדל עבור ציוצים קצרים/פופולריים" }, "mmdd":{ "message": "$MONTH$ $DATE$", "description":"July 1st", "placeholders": { "month": { "content": "July" }, "date": { "content": "1st" } }}, "mmddyy":{ "message": "$MONTH$ $DATE$, $YEAR$", "description":"July 1st, 2015", "placeholders": { "year": { "content": "2015" },"month": { "content": "July" }, "date": { "content": "1st" } }}, - "yyyy":{ "message": "$YEAR$", "description":"2015", "placeholders": { "year": { "content": "2015" } } } + "yyyy":{ "message": "$YEAR$", "description":"2015", "placeholders": { "year": { "content": "2015" } } }, + "hide_original_languages":{ + "message": "הסר טקסט מקורי כאשר ציוצים מתורגמים" + } } diff --git a/layouts/settings/index.html b/layouts/settings/index.html index d7b550da..8a3c8595 100644 --- a/layouts/settings/index.html +++ b/layouts/settings/index.html @@ -211,6 +211,9 @@

__MSG_autotranslation__

? +
+ +

__MSG_mobile__


diff --git a/layouts/settings/script.js b/layouts/settings/script.js index c069d0f5..79514823 100644 --- a/layouts/settings/script.js +++ b/layouts/settings/script.js @@ -319,6 +319,7 @@ setTimeout(async () => { let showExactValues = document.getElementById('show-exact-values'); let localizeDigit = document.getElementById('localize-digit'); let hideTimelineTypes = document.getElementById('hide-timeline-types'); + let hideOriginalLanguages = document.getElementById('hide-original-languages'); let autotranslationMode = document.getElementById('autotranslation-mode'); let autotranslateLanguages = document.getElementById('autotranslate-languages'); let autotranslateLanguageList = document.getElementById('autotranslate-language-list'); @@ -980,6 +981,12 @@ setTimeout(async () => { autotranslateLanguages.appendChild(div); } + hideOriginalLanguages.addEventListener('change', () => { + chrome.storage.sync.set({ + hideOriginalLanguages: hideOriginalLanguages.checked + }, () => { }); + }); + // Set values if(vars.linkColor) { linkColor.value = vars.linkColor; @@ -1049,6 +1056,7 @@ setTimeout(async () => { pinBookmarksOnNavbar.checked = !!vars.pinBookmarksOnNavbar; pinListsOnNavbar.checked = !!vars.pinListsOnNavbar; useOldDefaultProfileImage.checked = !!vars.useOldDefaultProfileImage; + hideOriginalLanguages.checked = !!vars.hideOriginalLanguages; uncensorAdultContentAutomatically.checked = !!vars.uncensorAdultContentAutomatically; uncensorGraphicViolenceAutomatically.checked = !!vars.uncensorGraphicViolenceAutomatically; uncensorSensitiveContentAutomatically.checked = !!vars.uncensorSensitiveContentAutomatically; diff --git a/scripts/config.js b/scripts/config.js index a7a561f5..411361ff 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -30,7 +30,7 @@ async function loadVars() { 'uncensorGraphicViolenceAutomatically', 'uncensorAdultContentAutomatically', 'uncensorSensitiveContentAutomatically', 'useOldStyleReply', 'enableAd', 'acknowledgedCssAccess', 'disableProfileCustomizations', 'openNotifsAsModal', 'enableIframeNavigation', 'acknowledgedCustomizationButton', 'modernUI', 'showExactValues', 'hideTimelineTypes', 'autotranslateLanguages', - 'autotranslationMode', 'muteVideos', 'dontPauseVideos', 'showUserPreviewsOnMobile', 'systemDarkMode', 'localizeDigit', + 'autotranslationMode', 'hideOriginalLanguages', 'muteVideos', 'dontPauseVideos', 'showUserPreviewsOnMobile', 'systemDarkMode', 'localizeDigit', 'disableRetweetHotkey', 'disableLikeHotkey', 'disableFindHotkey', 'extensionCompatibilityMode', 'disableDataSaver', 'disableAcceptType', 'showUserFollowerCountsInLists', 'showQuoteCount', 'hideUnfollowersPage', 'transitionProfileBanner', 'customDownloadTemplate', 'showBoringIndicators' @@ -210,6 +210,12 @@ async function loadVars() { disableAcceptType: false }, () => {}); } + if(typeof(data.hideOriginalLanguages) !== 'boolean') { + data.hideOriginalLanguages = false; + chrome.storage.sync.set({ + hideOriginalLanguages: false + }, () => {}); + } if(typeof(data.autotranslateProfiles) !== 'object') { data.autotranslateProfiles = []; chrome.storage.sync.set({ diff --git a/scripts/helpers.js b/scripts/helpers.js index 99e90dab..41a0d32b 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -2644,6 +2644,7 @@ async function appendTweet(t, timelineContainer, options = {}) { let tt = t.full_text.replace(/^(@[a-zA-Z0-9_]{1,15}\s?)*/, "").replace(/\shttps:\/\/t.co\/[a-zA-Z0-9\-]{8,10}$/, "").trim(); if(translated.text.trim() === tt) return; if(translated.text.trim() === tt.replace(/(hihi)|(hehe)/g, 'lol')) return; // lol + const { hideOriginalLanguages } = await chrome.storage.sync.get('hideOriginalLanguages'); let translatedMessage; if(LOC.translated_from.message.includes("$LANGUAGE$")) { translatedMessage = LOC.translated_from.message.replace("$LANGUAGE$", `[${translated.translated_lang}]`); @@ -2653,6 +2654,10 @@ async function appendTweet(t, timelineContainer, options = {}) { if(translated.text.length > 600) { translated.text = translated.text.substring(0, 600) + '...'; } + if (hideOriginalLanguages) { + translatedMessage = ''; + tweetBodyQuoteText.innerHTML = ''; + } tweetBodyQuoteText.innerHTML += `${translatedMessage}:`+ `${escapeHTML(translated.text)}`; @@ -2683,6 +2688,8 @@ async function appendTweet(t, timelineContainer, options = {}) { let tt = t.full_text.replace(/^(@[a-zA-Z0-9_]{1,15}\s?)*/, "").replace(/\shttps:\/\/t.co\/[a-zA-Z0-9\-]{8,10}$/, "").trim(); if(translated.text.trim() === tt) return; if(translated.text.trim() === tt.replace(/(hihi)|(hehe)/g, 'lol')) return; // lol + const { hideOriginalLanguages } = await chrome.storage.sync.get('hideOriginalLanguages'); + let translatedMessage; if(LOC.translated_from.message.includes("$LANGUAGE$")) { translatedMessage = LOC.translated_from.message.replace("$LANGUAGE$", `[${translated.translated_lang}]`); @@ -2696,10 +2703,18 @@ async function appendTweet(t, timelineContainer, options = {}) { let translatedFrom = document.createElement('span'); translatedFrom.classList.add('translated-from'); translatedFrom.innerText = translatedMessage; + + + let translatedText = document.createElement('span'); translatedText.classList.add('tweet-translated-text'); translatedText.innerHTML = await renderTweetBodyHTML(translatedT); - tweetBodyText.append(document.createElement('br'), translatedFrom, translatedText); + if (hideOriginalLanguages) { + tweetBodyText.innerHTML = ''; + tweetBodyText.append(translatedText); + } else { + tweetBodyText.append(document.createElement('br'), translatedFrom, translatedText); + } if(vars.enableTwemoji) twemoji.parse(tweetBodyText); }); if(options.translate || vars.autotranslateProfiles.includes(t.user.id_str) || (typeof toAutotranslate !== 'undefined' && toAutotranslate) || (vars.autotranslateLanguages.includes(t.lang) && vars.autotranslationMode === 'whitelist') || (!vars.autotranslateLanguages.includes(t.lang) && vars.autotranslationMode === 'blacklist')) { diff --git a/scripts/tweetviewer.js b/scripts/tweetviewer.js index 67735f1a..a6e58bd7 100644 --- a/scripts/tweetviewer.js +++ b/scripts/tweetviewer.js @@ -1608,6 +1608,8 @@ class TweetViewer { let tt = t.full_text.replace(/^(@[a-zA-Z0-9_]{1,15}\s?)*/, "").replace(/\shttps:\/\/t.co\/[a-zA-Z0-9\-]{8,10}$/, "").trim(); if(translated.text.trim() === tt) return; if(translated.text.trim() === tt.replace(/(hihi)|(hehe)/g, 'lol')) return; // lol + const { hideOriginalLanguages } = await chrome.storage.sync.get('hideOriginalLanguages'); + let translatedMessage; if(LOC.translated_from.message.includes("$LANGUAGE$")) { translatedMessage = LOC.translated_from.message.replace("$LANGUAGE$", `[${translated.translated_lang}]`); @@ -1617,6 +1619,10 @@ class TweetViewer { if(translated.text.length > 600) { translated.text = translated.text.substring(0, 600) + '...'; } + if (hideOriginalLanguages) { + translatedMessage = ''; + tweetBodyQuoteText.innerHTML = ''; + } tweetBodyQuoteText.innerHTML += `${translatedMessage}:`+ `${escapeHTML(translated.text)}`; @@ -1647,6 +1653,9 @@ class TweetViewer { let tt = t.full_text.replace(/^(@[a-zA-Z0-9_]{1,15}\s?)*/, "").replace(/\shttps:\/\/t.co\/[a-zA-Z0-9\-]{8,10}$/, "").trim(); if(translated.text.trim() === tt) return; if(translated.text.trim() === tt.replace(/(hihi)|(hehe)/g, 'lol')) return; // lol + + const { hideOriginalLanguages } = await chrome.storage.sync.get('hideOriginalLanguages'); + let translatedMessage; if(LOC.translated_from.message.includes("$LANGUAGE$")) { translatedMessage = LOC.translated_from.message.replace("$LANGUAGE$", `[${translated.translated_lang}]`); @@ -1660,10 +1669,18 @@ class TweetViewer { let translatedFrom = document.createElement('span'); translatedFrom.classList.add('translated-from'); translatedFrom.innerText = translatedMessage; + + + let translatedText = document.createElement('span'); translatedText.classList.add('tweet-translated-text'); translatedText.innerHTML = await renderTweetBodyHTML(translatedT); - tweetBodyText.append(document.createElement('br'), translatedFrom, translatedText); + if (hideOriginalLanguages) { + tweetBodyText.innerHTML = ''; + tweetBodyText.append(translatedText); + } else { + tweetBodyText.append(document.createElement('br'), translatedFrom, translatedText); + } if(vars.enableTwemoji) twemoji.parse(tweetBodyText); }); if(options.translate || vars.autotranslateProfiles.includes(t.user.id_str) || (typeof toAutotranslate !== 'undefined' && toAutotranslate) || (vars.autotranslateLanguages.includes(t.lang) && vars.autotranslationMode === 'whitelist') || (!vars.autotranslateLanguages.includes(t.lang) && vars.autotranslationMode === 'blacklist')) {