🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Open Elements in Background Tab

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Open Elements in Background Tab
// @namespace    http://tampermonkey.net/
// @version      0.8
// @description  將選定的元素在背景分頁或新分頁開啟
// @author       You
// @match        https://tixcraft.com/ticket/area/*
// @grant        GM_openInTab
// @grant        GM_getValue
// @grant        GM_setValue
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 從頁面腳本中提取 areaUrlList
    function extractAreaUrlList() {
        const scripts = document.getElementsByTagName('script');
        let urlList = {};

        for (const script of scripts) {
            if (script.textContent.includes('var areaUrlList =')) {
                try {
                    const match = script.textContent.match(/var areaUrlList = (\{[^;]+\});/);
                    if (match && match[1]) {
                        urlList = JSON.parse(match[1]);
                        console.log('Successfully extracted areaUrlList:', urlList);
                    }
                } catch (e) {
                    console.error('Error parsing areaUrlList:', e);
                }
            }
        }
        return urlList;
    }

    // 開啟所有連結
    function openAllUrls(urlList) {
        const urls = Object.values(urlList);
        console.log(`Opening ${urls.length} tabs...`);

        // 為了避免被瀏覽器阻擋,添加小延遲
        urls.forEach((url, index) => {
            setTimeout(() => {
                GM_openInTab(url, { active: false });

                // 在最後一個 URL 開啟後輸出完成訊息
                if (index === urls.length - 1) {
                    console.log('All tabs have been opened!');
                }
            }, index * 100); // 每個標籤頁延遲 100ms
        });
    }

    function init() {
        const urlList = extractAreaUrlList();

        // 檢查是否有區域可以開啟
        if (Object.keys(urlList).length > 0) {
            console.log('Found areas, opening tabs...');
            // 自動開啟所有連結
            openAllUrls(urlList);
        } else {
            console.log('No areas found to open');
        }
    }

    // 等待一小段時間確保頁面完全載入
    setTimeout(() => {
        if (document.readyState === 'complete') {
            init();
        } else {
            window.addEventListener('load', init);
        }
    }, 100); // 等待 500ms 再執行
})();