aboutsummaryrefslogtreecommitdiff
path: root/docs/js/open-in-new-tab.js
blob: 643cf514922b8a257e0605ecb0659011df185eee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function (){
    const IGNORED_PATHS = []

    for (const ignoredPath of IGNORED_PATHS) {
        if (window.location.pathname.match(`(\/${ignoredPath}[\/?].*)`)) {
            return;
        }
    }

    let links = document.getElementsByTagName("a");

    for (const link of links) {
        if (link.hostname !== window.location.hostname) {
            link.target = "_blank";
        }
    }

    console.debug(`[Open in New Tab] Changed external links to open in new tab.`);
})();