Skip to content

Instantly share code, notes, and snippets.

@JosXa
Created May 11, 2016 23:08
Show Gist options
  • Save JosXa/b0b3fe41649750990079983c2b54da8c to your computer and use it in GitHub Desktop.
Save JosXa/b0b3fe41649750990079983c2b54da8c to your computer and use it in GitHub Desktop.
Userscript forcing all websites to open links in the same tab. Useful for google, which seems to open a new tab every time you click a link.
// ==UserScript==
// @name Open links in same tab
// @namespace
// @version 1.0
// @description Description
// @require http://code.jquery.com/jquery-latest.js
// @include *
// ==/UserScript==
$(document).ready(function(){
var a = document.getElementsByTagName("a");
for (i=0;i<a.length;i++) {
if (a[i].target="_blank") {
a[i].target="_self"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment