Open All Links in New Windows

Opens all links in new windows.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Open All Links in New Windows
// @name:zh-CN  所有链接在新窗口打开
// @namespace   http://tampermonkey.net/
// @version     1.3
// @description Opens all links in new windows.
// @description:zh-CN 所有链接都在新窗口打开
// @author      Yun sun
// @match       *://*/*
// @grant       none
// @license     MIT
// @icon        https://img.icons8.com/?size=64&id=68406&format=png&color=000000  // Paste 64x64 icon URL here
// @run-at      document-start
// ==/UserScript==

(function() {
    'use strict';

    function handleClick(event) {
        if (event.ctrlKey || event.metaKey) return;

        const anchor = event.target.closest('a');
        if (!anchor || !anchor.href) return;

        if (anchor.getAttribute('href').startsWith('javascript:')) return;

        event.preventDefault();
        event.stopPropagation();

        window.open(anchor.href, '_blank');
    }

    document.addEventListener('click', handleClick, true);
})();