From d6a14edcdf4fad520e568f53f5e80ca492e9a671 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Thu, 7 Mar 2019 17:41:58 +0100 Subject: [PATCH] wip --- Core/Notification/FormNotificationBase.cs | 2 +- Resources/Scripts/code.js | 43 +++++++++++++---------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Core/Notification/FormNotificationBase.cs b/Core/Notification/FormNotificationBase.cs index cc3275fa..97912c7e 100644 --- a/Core/Notification/FormNotificationBase.cs +++ b/Core/Notification/FormNotificationBase.cs @@ -33,7 +33,7 @@ protected virtual Point PrimaryLocation{ screen = Screen.AllScreens[Config.NotificationDisplay-1]; } else{ - screen = Screen.FromControl(owner); + screen = Screen.FromControl(owner); // TODO may be disposed? } int edgeDist = Config.NotificationEdgeDistance; diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index e157ef68..6d1a6915 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -560,7 +560,7 @@ execSafe(function setupShortenerBypass(){ $(document.body).delegate("a[data-full-url]", "click auxclick", function(e){ if (e.button === 0 || e.button === 1){ // event.which seems to be borked in auxclick - $TD.openBrowser($(this).attr("data-full-url")); + $TD.openBrowser($(this).attr("data-full-url")); // TODO detect rel="tweet"? e.preventDefault(); } }); @@ -755,28 +755,35 @@ return chirp.getMedia().filter(item => !item.isAnimatedGif).map(item => item.entity.media_url_https+":small").join(";"); }; + const updateContextInfo = function(chirp){ + let quote = chirp.quotedTweet; + + if (chirp.chirpType === TD.services.ChirpBase.TWEET){ + let tweetUrl = chirp.getChirpURL(); + let quoteUrl = quote && quote.getChirpURL(); + + let chirpAuthors = quote ? [ chirp.getMainUser().screenName, quote.getMainUser().screenName ].join(";") : chirp.getMainUser().screenName; + let chirpImages = chirp.hasImage() ? processMedia(chirp) : quote && quote.hasImage() ? processMedia(quote) : ""; + + $TD.setRightClickedChirp(tweetUrl || "", quoteUrl || "", chirpAuthors, chirpImages); + } + else if (chirp instanceof TD.services.TwitterActionFollow){ + $TD.setRightClickedLink("link", chirp.following.getProfileURL()); + } + }; + app.delegate("section.js-column", { contextmenu: function(){ let hovered = getHoveredTweet(); - return if !hovered; - - let tweet = hovered.obj; - let quote = tweet.quotedTweet; - - if (tweet.chirpType === TD.services.ChirpBase.TWEET){ - let tweetUrl = tweet.getChirpURL(); - let quoteUrl = quote && quote.getChirpURL(); - - let chirpAuthors = quote ? [ tweet.getMainUser().screenName, quote.getMainUser().screenName ].join(";") : tweet.getMainUser().screenName; - let chirpImages = tweet.hasImage() ? processMedia(tweet) : quote && quote.hasImage() ? processMedia(quote) : ""; - - $TD.setRightClickedChirp(tweetUrl || "", quoteUrl || "", chirpAuthors, chirpImages); - } - else if (tweet instanceof TD.services.TwitterActionFollow){ - $TD.setRightClickedLink("link", tweet.following.getProfileURL()); - } + hovered && updateContextInfo(hovered.obj); } }); + + if (ensurePropertyExists(TD, "services", "TwitterStatus", "prototype", "renderInMediaGallery")){ + TD.services.TwitterStatus.prototype.renderInMediaGallery = appendToFunction(TD.services.TwitterStatus.prototype.renderInMediaGallery, function(){ + updateContextInfo(this); + }); + } }); //