Last active
August 29, 2015 14:08
-
-
Save interfect/f734996559708180ecc4 to your computer and use it in GitHub Desktop.
Reddit Open In Same 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 Reddit open in same tab | |
// @namespace roist | |
// @description Makes links on reddit.com open in the same tab by default, even if not logged in. | |
// @include http://*.reddit.com/* | |
// @include https://*.reddit.com/* | |
// @version 1 | |
// @author Interfect | |
// @copyright 2014 Interfect | |
// @grant none | |
// ==/UserScript== | |
document.body.addEventListener('click', function(e){ | |
var element = e.target; | |
if(element.tagName == "A" && element.hasAttribute("target") && element.getAttribute("target") == "_blank") { | |
// This is a link that wants to open in a new tab. Tell it to use the same frame instead. | |
element.setAttribute("target", "_self"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment