From 89e92dab59ca39eaf121de0e3db763de8e3b3631 Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Mon, 19 Feb 2018 17:31:28 +0100
Subject: [PATCH] Fix middle-clicking on links in desktop notifications not
 skipping them or stripping t.co

---
 Resources/Scripts/notification.js | 35 ++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/Resources/Scripts/notification.js b/Resources/Scripts/notification.js
index 7fd5a4d5..b4d89d23 100644
--- a/Resources/Scripts/notification.js
+++ b/Resources/Scripts/notification.js
@@ -14,22 +14,29 @@
   };
   
   //
-  // Block: Hook into links to bypass default open function and t.co.
+  // Block: Hook into links to bypass default open function and t.co, and handle skipping notification when opening links.
   //
-  addEventListener(links, "click", function(e){
-    let ele = e.currentTarget;
-    
-    $TD.openBrowser(ele.hasAttribute("data-full-url") ? ele.getAttribute("data-full-url") : ele.getAttribute("href"));
-    e.preventDefault();
-    
-    if ($TDX.skipOnLinkClick){
-      let parentClasses = ele.parentNode.classList;
-      
-      if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
-        $TD.loadNextNotification();
+  (function(){
+    const onLinkClick = function(e){
+      if (e.button === 0 || e.button === 1){
+        let ele = e.currentTarget;
+
+        $TD.openBrowser(ele.hasAttribute("data-full-url") ? ele.getAttribute("data-full-url") : ele.getAttribute("href"));
+        e.preventDefault();
+
+        if ($TDX.skipOnLinkClick){
+          let parentClasses = ele.parentNode.classList;
+
+          if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
+            $TD.loadNextNotification();
+          }
+        }
       }
-    }
-  });
+    };
+    
+    addEventListener(links, "click", onLinkClick);
+    addEventListener(links, "auxclick", onLinkClick);
+  })();
   
   //
   // Block: Allow bypassing of t.co in context menus.