mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-12 05:34:06 +02:00
parent
2a65e20fb9
commit
5648e9e806
Core/Handling
Resources
@ -8,6 +8,7 @@ class ContextMenuBrowser : ContextMenuBase{
|
||||
private const int MenuAbout = 26601;
|
||||
private const int MenuMute = 26602;
|
||||
private const int MenuCopyTweetUrl = 26603;
|
||||
private const int MenuCopyTweetEmbeddedUrl = 26604;
|
||||
|
||||
private readonly FormBrowser form;
|
||||
|
||||
@ -24,6 +25,11 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
|
||||
|
||||
if (!string.IsNullOrEmpty(TweetDeckBridge.LastHighlightedTweet)){
|
||||
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
||||
|
||||
if (!string.IsNullOrEmpty(TweetDeckBridge.LastHighlightedTweetEmbedded)){
|
||||
model.AddItem((CefMenuCommand)MenuCopyTweetEmbeddedUrl,"Copy quoted tweet address");
|
||||
}
|
||||
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
@ -71,6 +77,10 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
||||
case MenuCopyTweetUrl:
|
||||
Clipboard.SetText(TweetDeckBridge.LastHighlightedTweet,TextDataFormat.UnicodeText);
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetEmbeddedUrl:
|
||||
Clipboard.SetText(TweetDeckBridge.LastHighlightedTweetEmbedded,TextDataFormat.UnicodeText);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -7,6 +7,7 @@ class ContextMenuNotification : ContextMenuBase{
|
||||
private const int MenuSkipTweet = 26600;
|
||||
private const int MenuFreeze = 26601;
|
||||
private const int MenuCopyTweetUrl = 26602;
|
||||
private const int MenuCopyTweetEmbeddedUrl = 26603;
|
||||
|
||||
private readonly FormNotification form;
|
||||
private readonly bool enableCustomMenu;
|
||||
@ -27,6 +28,11 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
|
||||
|
||||
if (!string.IsNullOrEmpty(form.CurrentUrl)){
|
||||
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
||||
|
||||
if (!string.IsNullOrEmpty(TweetDeckBridge.NotificationTweetEmbedded)){
|
||||
model.AddItem((CefMenuCommand)MenuCopyTweetEmbeddedUrl,"Copy quoted tweet address");
|
||||
}
|
||||
|
||||
model.AddSeparator();
|
||||
}
|
||||
}
|
||||
@ -54,6 +60,10 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
||||
case MenuCopyTweetUrl:
|
||||
Clipboard.SetText(form.CurrentUrl,TextDataFormat.UnicodeText);
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetEmbeddedUrl:
|
||||
Clipboard.SetText(TweetDeckBridge.NotificationTweetEmbedded,TextDataFormat.UnicodeText);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -10,6 +10,8 @@ namespace TweetDck.Core.Handling{
|
||||
class TweetDeckBridge{
|
||||
public static string LastRightClickedLink = string.Empty;
|
||||
public static string LastHighlightedTweet = string.Empty;
|
||||
public static string LastHighlightedTweetEmbedded = string.Empty;
|
||||
public static string NotificationTweetEmbedded = string.Empty;
|
||||
public static string ClipboardImagePath = string.Empty;
|
||||
|
||||
private readonly FormBrowser form;
|
||||
@ -58,8 +60,15 @@ public void SetLastRightClickedLink(string link){
|
||||
form.InvokeSafe(() => LastRightClickedLink = link);
|
||||
}
|
||||
|
||||
public void SetLastHighlightedTweet(string link){
|
||||
form.InvokeSafe(() => LastHighlightedTweet = link);
|
||||
public void SetLastHighlightedTweet(string link, string embeddedLink){
|
||||
form.InvokeSafe(() => {
|
||||
LastHighlightedTweet = link;
|
||||
LastHighlightedTweetEmbedded = embeddedLink;
|
||||
});
|
||||
}
|
||||
|
||||
public void SetNotificationTweetEmbedded(string link){
|
||||
form.InvokeSafe(() => NotificationTweetEmbedded = link);
|
||||
}
|
||||
|
||||
public void OpenSettingsMenu(){
|
||||
|
@ -318,9 +318,9 @@
|
||||
(function(){
|
||||
var lastTweet = "";
|
||||
|
||||
var updateHighlightedTweet = function(link){
|
||||
var updateHighlightedTweet = function(link, embeddedLink){
|
||||
if (lastTweet != link){
|
||||
$TD.setLastHighlightedTweet(link);
|
||||
$TD.setLastHighlightedTweet(link,embeddedLink);
|
||||
lastTweet = link;
|
||||
}
|
||||
};
|
||||
@ -330,11 +330,13 @@
|
||||
highlightedTweetEle = $(this);
|
||||
|
||||
var link = $(this).find("time").first().children("a").first();
|
||||
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "");
|
||||
var embedded = $(this).find(".quoted-tweet[data-tweet-id]").first();
|
||||
|
||||
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "",embedded.length > 0 ? embedded.find(".account-link").first().attr("href")+"/status/"+embedded.attr("data-tweet-id") : "");
|
||||
}
|
||||
else if (e.type === "mouseleave"){
|
||||
highlightedTweetEle = null;
|
||||
updateHighlightedTweet("");
|
||||
updateHighlightedTweet("","");
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
@ -98,4 +98,20 @@
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Setup embedded tweet address for context menu
|
||||
//
|
||||
(function(){
|
||||
var embedded = document.getElementsByClassName("quoted-tweet");
|
||||
if (embedded.length === 0)return;
|
||||
|
||||
var tweetId = embedded[0].getAttribute("data-tweet-id");
|
||||
if (!tweetId)return;
|
||||
|
||||
var account = embedded[0].getElementsByClassName("account-link");
|
||||
if (account.length === 0)return;
|
||||
|
||||
$TD.setNotificationTweetEmbedded(account[0].getAttribute("href")+"/status/"+tweetId);
|
||||
})();
|
||||
})($TD);
|
Loading…
Reference in New Issue
Block a user