Open external links on ~ in new tabs

SleepyGary
2018-06-04T18:19:32Z

I was missing this feature from Reddit and saw others were as well so I thought I would share a user script I created to solve this issue until it's added (if it's added)

// ==UserScript==
// @name         Tildes.net: Open external links in new tab
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Opens external links on tildes.net in a new tab
// @author       SleepyGary
// @match        https://tildes.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.querySelectorAll('a').forEach(el => {
        if (!el.href.includes('tildes.net') && el.href !== '') {
            el.target = "_blank";
        }
    });
})();

Comments URL: https://tildes.net/~comp/1kp/open_external_links_on_in_new_tabs

Votes: 14

Comments: 5