mirror of
				https://github.com/chylex/TweetDuck.git
				synced 2025-10-31 00:17:14 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			976 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			976 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| (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.
 | |
|   //
 | |
|   document.body.addEventListener("click",function(e){
 | |
|     if (bubbleParents(e.target,"A",function(ele){
 | |
|       $TD.openBrowser(ele.getAttribute("href"));
 | |
|     })){
 | |
|       e.preventDefault();
 | |
|     }
 | |
|   });
 | |
|   
 | |
|   //
 | |
|   // Block: Allow bypassing of t.co in context menus.
 | |
|   //
 | |
|   document.body.addEventListener("contextmenu",function(e){
 | |
|     bubbleParents(e.target,"A",function(ele){
 | |
|       $TD.setLastRightClickedLink(element.getAttribute("data-full-url") || "");
 | |
|     });
 | |
|   });
 | |
| })($TD); |