Last active
July 19, 2019 13:52
-
-
Save chadlavi/1ba0870db91bf2d9f5ba292289186c56 to your computer and use it in GitHub Desktop.
open external links in new tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name links new tab | |
// @namespace https://gist.github.com/chadlavi/1ba0870db91bf2d9f5ba292289186c56 | |
// @dowloadURL https://gist.github.com/chadlavi/1ba0870db91bf2d9f5ba292289186c56/raw/fp-links-new-tab.user.js | |
// @updateURL https://gist.github.com/chadlavi/1ba0870db91bf2d9f5ba292289186c56/raw/fp-links-new-tab.user.js | |
// @version 2.0 | |
// @description always open external links in a new tab | |
// @copyright 2019, Chad Lavimoniere | |
// ==/UserScript== | |
const externalLinks = () => { | |
for(var c = document.getElementsByTagName("a"), a = 0; a < c.length; a++) { | |
let b = c[a] | |
b.getAttribute('href') && b.hostname !== location.hostname && (b.target = '_blank') | |
} | |
} | |
externalLinks() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment