Skip to content

Instantly share code, notes, and snippets.

@ochronus
Created April 2, 2016 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochronus/88c59ab8eff806a062ce74c64feca99a to your computer and use it in GitHub Desktop.
Save ochronus/88c59ab8eff806a062ce74c64feca99a to your computer and use it in GitHub Desktop.
$("a").each(function() {
var $elem = $(this);
var url = $elem.attr("href");
if (url.indexOf("https://news.ycombinator.com") === 0 || url.indexOf("http") === -1) {
return;
}
if ($elem.attr("target") === undefined) {
$elem.attr("target", "_blank");
console.log($elem.attr("href"), $elem.attr("target"));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment