Open Elements in Background Tab

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

当前为 2024-11-01 提交的版本,查看 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址