diff --git a/_locales/en/messages.json b/_locales/en/messages.json index dcdb1da9..193e8a6c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -575,5 +575,7 @@ "uploading": { "message": "Uploading" }, "finalization": { "message": "Finalization" }, "processing": { "message": "Processing" }, - "quotes": { "message": "Quotes" } + "quotes": { "message": "Quotes" }, + "share_tweet_in_dms": { "message": "Share tweet in DMs" }, + "share_tweet_to": { "message": "Share tweet to..." } } \ No newline at end of file diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index 09113391..e2bd489c 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -566,5 +566,7 @@ "uploading": { "message": "Загрузка" }, "finalization": { "message": "Завершение" }, "processing": { "message": "Обработка" }, - "quotes": { "message": "Цитаты" } + "quotes": { "message": "Цитаты" }, + "share_tweet_in_dms": { "message": "Поделиться твитом в сообщениях" }, + "share_tweet_to": { "message": "Поделиться твитом..." } } \ No newline at end of file diff --git a/_locales/uk/messages.json b/_locales/uk/messages.json index 98443765..321d2477 100644 --- a/_locales/uk/messages.json +++ b/_locales/uk/messages.json @@ -566,5 +566,7 @@ "uploading": { "message": "Завантаження" }, "finalization": { "message": "Завершення" }, "processing": { "message": "Обробка" }, - "quotes": { "message": "Цитати" } + "quotes": { "message": "Цитати" }, + "share_tweet_in_dms": { "message": "Поширити твіт повідомленням" }, + "share_tweet_to": { "message": "Поширити твіт..." } } \ No newline at end of file diff --git a/layouts/header/script.js b/layouts/header/script.js index 045f9bd2..9c95e11d 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -8,6 +8,7 @@ let notificationsOpened = false; let isDarkModeEnabled = typeof vars !== 'undefined' ? (vars.darkMode || (vars.timeMode && isDark())) : false; let activeTweet; let seenAlgoTweets = [], algoTweetsChanged = false; +let tweetUrlToShareInDMs = null; setInterval(() => { if(!algoTweetsChanged) return; algoTweetsChanged = false; @@ -1065,6 +1066,7 @@ let userDataFunction = async user => { if(messageUsers.length === 1) messageHeaderLink.href = `https://twitter.com/${messageUsers[0].screen_name}`; setTimeout(() => { modal.querySelector(".message-new-input").focus(); + if(tweetUrlToShareInDMs) modal.querySelector(".message-new-input").value = tweetUrlToShareInDMs; }); renderConversation(messageData, c.conversation_id); @@ -1153,6 +1155,7 @@ let userDataFunction = async user => { if(location.hash === '#dm') { location.hash = ""; } + tweetUrlToShareInDMs = null; }); modal.querySelector('.modal-close').hidden = true; const inboxList = modal.querySelector('.inbox-list'); @@ -1228,6 +1231,7 @@ let userDataFunction = async user => { messageHeaderLink.href = `https://twitter.com/${u.screen_name}`; setTimeout(() => { modal.querySelector(".message-new-input").focus(); + if(tweetUrlToShareInDMs) modal.querySelector(".message-new-input").value = tweetUrlToShareInDMs; }); renderConversation(messageData, `${user.id_str}-${u.id_str}`); @@ -2249,6 +2253,7 @@ let userDataFunction = async user => { messageHeaderLink.href = `https://twitter.com/${u.screen_name}`; setTimeout(() => { modal.querySelector(".message-new-input").focus(); + if(tweetUrlToShareInDMs) modal.querySelector(".message-new-input").value = tweetUrlToShareInDMs; }); renderConversation(messageData, convo_id); diff --git a/layouts/header/style.css b/layouts/header/style.css index feaa4875..1b678e35 100644 --- a/layouts/header/style.css +++ b/layouts/header/style.css @@ -1621,6 +1621,9 @@ span.tweet-body-text { .tweet-interact-more-menu-share:before { content: "\f185" } +.tweet-interact-more-menu-share-dms:before { + content: "\f157" +} .tweet-interact-more-menu-analytics:before { content: "\f200" diff --git a/scripts/helpers.js b/scripts/helpers.js index 983e1e93..d30c5e9e 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1940,6 +1940,7 @@ async function appendTweet(t, timelineContainer, options = {}) { ${LOC.copy_link.message} ${LOC.embed_tweet.message} ${navigator.canShare ? `${LOC.share_tweet.message}` : ''} + ${LOC.share_tweet_in_dms.message} ${LOC.open_tweet_newtwitter.message} ${t.user.id_str === user.id_str ? /*html*/`
@@ -2317,6 +2318,7 @@ async function appendTweet(t, timelineContainer, options = {}) { const tweetInteractMoreMenuCopyUserId = tweet.getElementsByClassName('tweet-interact-more-menu-copy-user-id')[0]; const tweetInteractMoreMenuEmbed = tweet.getElementsByClassName('tweet-interact-more-menu-embed')[0]; const tweetInteractMoreMenuShare = tweet.getElementsByClassName('tweet-interact-more-menu-share')[0]; + const tweetInteractMoreMenuShareDMs = tweet.getElementsByClassName('tweet-interact-more-menu-share-dms')[0]; const tweetInteractMoreMenuNewtwitter = tweet.getElementsByClassName('tweet-interact-more-menu-newtwitter')[0]; const tweetInteractMoreMenuAnalytics = tweet.getElementsByClassName('tweet-interact-more-menu-analytics')[0]; const tweetInteractMoreMenuRefresh = tweet.getElementsByClassName('tweet-interact-more-menu-refresh')[0]; @@ -3298,6 +3300,14 @@ async function appendTweet(t, timelineContainer, options = {}) { if(tweetInteractMoreMenuShare) tweetInteractMoreMenuShare.addEventListener('click', () => { navigator.share({ url: `https://twitter.com/${t.user.screen_name}/status/${t.id_str}` }); }); + tweetInteractMoreMenuShareDMs.addEventListener('click', () => { + tweetUrlToShareInDMs = `https://twitter.com/${t.user.screen_name}/status/${t.id_str}`; + document.getElementById('messages').click(); + setTimeout(() => { + let title = document.querySelector('div.inbox h1.nice-header.larger'); + title.innerText = LOC.share_tweet_to.message; + }); + }); tweetInteractMoreMenuNewtwitter.addEventListener('click', () => { openInNewTab(`https://twitter.com/${t.user.screen_name}/status/${t.id_str}?newtwitter=true`); }); diff --git a/scripts/tweetviewer.js b/scripts/tweetviewer.js index 0bb9fe12..f225fb25 100644 --- a/scripts/tweetviewer.js +++ b/scripts/tweetviewer.js @@ -1068,6 +1068,7 @@ class TweetViewer { ${LOC.copy_link.message} ${LOC.embed_tweet.message} ${navigator.canShare ? `${LOC.share_tweet.message}` : ''} + ${LOC.share_tweet_in_dms.message} ${LOC.open_tweet_newtwitter.message} ${t.user.id_str === user.id_str ? /*html*/`
@@ -1397,6 +1398,7 @@ class TweetViewer { const tweetInteractMoreMenuLog = tweet.getElementsByClassName('tweet-interact-more-menu-log')[0]; const tweetInteractMoreMenuEmbed = tweet.getElementsByClassName('tweet-interact-more-menu-embed')[0]; const tweetInteractMoreMenuShare = tweet.getElementsByClassName('tweet-interact-more-menu-share')[0]; + const tweetInteractMoreMenuShareDMs = tweet.getElementsByClassName('tweet-interact-more-menu-share-dms')[0]; const tweetInteractMoreMenuNewtwitter = tweet.getElementsByClassName('tweet-interact-more-menu-newtwitter')[0]; const tweetInteractMoreMenuAnalytics = tweet.getElementsByClassName('tweet-interact-more-menu-analytics')[0]; const tweetInteractMoreMenuRefresh = tweet.getElementsByClassName('tweet-interact-more-menu-refresh')[0]; @@ -2272,6 +2274,14 @@ class TweetViewer { if(tweetInteractMoreMenuShare) tweetInteractMoreMenuShare.addEventListener('click', () => { navigator.share({ url: `https://twitter.com/${t.user.screen_name}/status/${t.id_str}` }); }); + tweetInteractMoreMenuShareDMs.addEventListener('click', () => { + tweetUrlToShareInDMs = `https://twitter.com/${t.user.screen_name}/status/${t.id_str}`; + document.getElementById('messages').click(); + setTimeout(() => { + let title = document.querySelector('div.inbox h1.nice-header.larger'); + title.innerText = LOC.share_tweet_to.message; + }); + }); tweetInteractMoreMenuNewtwitter.addEventListener('click', () => { openInNewTab(`https://twitter.com/${t.user.screen_name}/status/${t.id_str}?newtwitter=true`); });