Skip to content

Instantly share code, notes, and snippets.

@y4rr
Last active September 15, 2019 02:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y4rr/03c6b13b70db1129f48cead3aae51397 to your computer and use it in GitHub Desktop.
Save y4rr/03c6b13b70db1129f48cead3aae51397 to your computer and use it in GitHub Desktop.
Link Target blank removal userscript - don't open links in new tabs
// ==UserScript==
// @name No New Tabs
// @match *
// @grant none
// ==/UserScript==
(function() {
document.querySelectorAll('a[target]').forEach((link) => {
link.setAttribute('target', '_self');
link.setAttribute('rel', 'noopener noreferrer');
});
document.querySelectorAll('base[target]').forEach((base) => {
base.setAttribute('target', '_self');
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment