Open Elements in Background Tab

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

La data de 01-11-2024. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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 });
            }
        });
    });
})();