Open Elements in Background Tab

將選定的元素在背景分頁或新分頁開啟

Stan na 01-11-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Open Elements in Background Tab
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  將選定的元素在背景分頁或新分頁開啟
// @author       You
// @match        https://tixcraft.com/ticket/area/*
// @grant        GM_openInTab
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 選擇所有符合條件的 `<a>` 元素
    const elements = document.querySelectorAll('.select_form_b > a');

    elements.forEach(element => {
        element.addEventListener('click', function(event) {
            // 檢查是否按下了 Ctrl 鍵
            if (event.ctrlKey) {
                // 阻止默認行為,防止在當前頁面跳轉
                event.preventDefault();

                // 使用 GM_openInTab 在背景分頁開啟
                GM_openInTab(element.href, { active: false });
            }
        });
    });
})();