From 8b8f5f547361b8e694e22d366798337cee587127 Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Tue, 5 Sep 2017 22:32:11 +0200
Subject: [PATCH] Fix login page links opening in the app instead of external
 browser

---
 Resources/Scripts/twitter.js | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Resources/Scripts/twitter.js b/Resources/Scripts/twitter.js
index 12372927..267d7c92 100644
--- a/Resources/Scripts/twitter.js
+++ b/Resources/Scripts/twitter.js
@@ -39,4 +39,25 @@
   };
   
   setTimeout(injectCSS, 1);
+  
+  //
+  // Block: Make login page links external.
+  //
+  if (location.pathname === "/login"){
+    document.addEventListener("DOMContentLoaded", function(){
+      let openLinkExternally = function(e){
+        let href = e.currentTarget.getAttribute("href");
+        $TD.openBrowser(href[0] === '/' ? location.origin+href : href);
+
+        e.preventDefault();
+        e.stopPropagation();
+      };
+
+      let links = document.getElementsByTagName("A");
+
+      for(let index = 0; index < links.length; index++){
+        links[index].addEventListener("click", openLinkExternally);
+      }
+    });
+  }
 })();