mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 21:15:49 +02:00
Bypass t.co links in context menu and hide url options for # links
This commit is contained in:
parent
c5b3bc1a0b
commit
2a1dc8beab
@ -14,7 +14,7 @@ abstract class ContextMenuBase : IContextMenuHandler{
|
||||
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
||||
RemoveSeparatorIfLast(model);
|
||||
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link)){
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#")){
|
||||
model.AddItem((CefMenuCommand)MenuOpenUrlInBrowser,"Open in browser");
|
||||
model.AddItem((CefMenuCommand)MenuCopyUrl,"Copy link address");
|
||||
model.AddSeparator();
|
||||
@ -35,7 +35,7 @@ public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser br
|
||||
break;
|
||||
|
||||
case MenuCopyUrl:
|
||||
Clipboard.SetText(parameters.UnfilteredLinkUrl,TextDataFormat.UnicodeText);
|
||||
Clipboard.SetText(string.IsNullOrEmpty(TweetDeckBridge.LastRightClickedLink) ? parameters.UnfilteredLinkUrl : TweetDeckBridge.LastRightClickedLink,TextDataFormat.UnicodeText);
|
||||
break;
|
||||
|
||||
case MenuOpenImageInBrowser:
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
class TweetDeckBridge{
|
||||
public static string LastRightClickedLink = string.Empty;
|
||||
|
||||
private readonly FormBrowser form;
|
||||
|
||||
public string BrandName{
|
||||
@ -44,6 +46,12 @@ public void LoadNotificationHeadContents(string headContents){
|
||||
});
|
||||
}
|
||||
|
||||
public void SetLastRightClickedLink(string link){
|
||||
form.InvokeSafe(() => {
|
||||
LastRightClickedLink = link;
|
||||
});
|
||||
}
|
||||
|
||||
public void OpenSettingsMenu(){
|
||||
form.InvokeSafe(() => {
|
||||
form.OpenSettings();
|
||||
|
@ -178,7 +178,7 @@
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Expand shortened links.
|
||||
// Block: Expand shortened links on hover.
|
||||
//
|
||||
(function(){
|
||||
var cutStart = function(str, search){
|
||||
@ -188,7 +188,7 @@
|
||||
$(document.body).delegate("a[data-full-url]","mouseenter mouseleave",function(e){
|
||||
var me = $(this);
|
||||
|
||||
if (e.type == "mouseenter"){
|
||||
if (e.type === "mouseenter"){
|
||||
var text = me.text();
|
||||
|
||||
if (text.charCodeAt(text.length-1) !== 8230){ // horizontal ellipsis
|
||||
@ -204,7 +204,7 @@
|
||||
me.attr("td-prev-text",text);
|
||||
me.text(expanded);
|
||||
}
|
||||
else{
|
||||
else if (e.type === "mouseleave"){
|
||||
var prevText = me.attr("td-prev-text");
|
||||
|
||||
if (prevText){
|
||||
@ -214,6 +214,13 @@
|
||||
});
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Allow bypassing of t.co in context menus.
|
||||
//
|
||||
$(document.body).delegate("a","contextmenu",function(){
|
||||
$TD.setLastRightClickedLink($(this).attr("data-full-url") || "");
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Hook into mp4 video element clicking
|
||||
//
|
||||
|
@ -1,6 +1,6 @@
|
||||
(function($TD){
|
||||
//
|
||||
// Block: Hook into links to bypass default open function
|
||||
// Block: Hook into links to bypass default open function.
|
||||
//
|
||||
document.body.addEventListener("click",function(e){
|
||||
if (e.target.tagName == "A"){
|
||||
@ -8,4 +8,18 @@
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Allow bypassing of t.co in context menus.
|
||||
//
|
||||
document.body.addEventListener("contextmenu",function(e){
|
||||
var element = e.target;
|
||||
|
||||
do{
|
||||
if (element.tagName == "A"){
|
||||
$TD.setLastRightClickedLink(element.getAttribute("data-full-url") || "");
|
||||
break;
|
||||
}
|
||||
}while((element = element.parentElement) != null);
|
||||
});
|
||||
})($TD);
|
Loading…
Reference in New Issue
Block a user