mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-02 11:34:08 +02:00
Fix clicking on nested/complex links in notification.js not triggering the hooks
This commit is contained in:
parent
dd4c89b9dd
commit
a335aa037a
@ -1,10 +1,25 @@
|
|||||||
(function($TD){
|
(function($TD){
|
||||||
|
//
|
||||||
|
// Function: Bubbles up the parents until it hits an element with the specified tag (includes the first element), and returns true if the search was successful.
|
||||||
|
//
|
||||||
|
var bubbleParents = function(element, tag, callback){
|
||||||
|
do{
|
||||||
|
if (element.tagName == "A"){
|
||||||
|
callback(element);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}while((element = element.parentElement) != null);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Hook into links to bypass default open function.
|
// Block: Hook into links to bypass default open function.
|
||||||
//
|
//
|
||||||
document.body.addEventListener("click",function(e){
|
document.body.addEventListener("click",function(e){
|
||||||
if (e.target.tagName == "A"){
|
if (bubbleParents(e.target,"A",function(ele){
|
||||||
$TD.openBrowser(e.target.getAttribute("href"));
|
$TD.openBrowser(ele.getAttribute("href"));
|
||||||
|
})){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -13,13 +28,8 @@
|
|||||||
// Block: Allow bypassing of t.co in context menus.
|
// Block: Allow bypassing of t.co in context menus.
|
||||||
//
|
//
|
||||||
document.body.addEventListener("contextmenu",function(e){
|
document.body.addEventListener("contextmenu",function(e){
|
||||||
var element = e.target;
|
bubbleParents(e.target,"A",function(ele){
|
||||||
|
$TD.setLastRightClickedLink(element.getAttribute("data-full-url") || "");
|
||||||
do{
|
});
|
||||||
if (element.tagName == "A"){
|
|
||||||
$TD.setLastRightClickedLink(element.getAttribute("data-full-url") || "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}while((element = element.parentElement) != null);
|
|
||||||
});
|
});
|
||||||
})($TD);
|
})($TD);
|
Loading…
Reference in New Issue
Block a user