Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
open tech crunch links in new tabs
// ==UserScript==
// @name techcrunch open article in new tab
// @namespace
// @downloadURL
// @updateURL
// @version 1.2
// @description Open tech crunch articles in new tabs
// @author You
// @match **
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
// open all links in a new tab
var links = document.getElementsByTagName('a');
for (var j=0; j<links.length; j++) {
links[j].setAttribute('target', '_blank');
links[j].setAttribute('rel', 'nofollow noreferrer');
//but make the logo link open in the same tab
document.getElementsByClassName('logo-link')[0].setAttribute('target', '_self');
//and make pagination links open in the same tab
var pageLinks = document.getElementsByClassName("pagination")[0].getElementsByTagName("a");
for (var i=0; i<pageLinks.length; i++) {
pageLinks[i].setAttribute('target', '_self');
//and remove dumb articles that are about tech crunch or their events, which are not news
var r=0;
var nono=['disrupt ny', 'disrupt&nbsp;ny', 'disrupt sf', 'disrupt&nbsp;sf', 'disrupt ticket', 'disrupt london', 'disrupt new york','disrupt san francisco', 'disrupt&nbsp;ticket', 'techcrunch', 'join us at', 'join&nbsp;us&nbsp;at', 'gillmor gang', 'gillmor&nbsp;gang', 'include office hours', 'at&nbsp;disrupt', 'at disrupt'];
var b = document.getElementsByClassName("river-block");
for (var i=0; i<b.length; i++) {
var h=b[i].getElementsByTagName('h2')[0].getElementsByTagName('a')[0];
for (var j=0; j<nono.length; j++) {
if (h.innerHTML.toLowerCase().indexOf(nono[j]) > -1) {
console.log(r + ' items removed');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment