Greasy Fork is available in English.

magnet-target-blank

Open magnet links in a new tab

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         magnet-target-blank
// @namespace    github.com/kugland/magnet-target-blank
// @version      0.0.1
// @author       André Kugland <[email protected]>
// @description  Open magnet links in a new tab
// @license      MIT
// @homepage     https://github.com/kugland/magnet-target-blank
// @homepageURL  https://github.com/kugland/magnet-target-blank
// @match        *://*/*
// @grant        GM.openInTab
// ==/UserScript==

(function () {
  'use strict';

  const listener = (event) => {
    const target = event.target;
    if (target.tagName === "A") {
      const href = target.href;
      if (typeof href === "string" && href.startsWith("magnet:")) {
        event.preventDefault();
        event.stopPropagation();
        GM.openInTab(href);
      }
    }
  };
  document.addEventListener("click", listener, { capture: true });
  document.addEventListener("tap", listener, { capture: true });

})();