Open Links in New Tab for Newtoki

Open all URLs within a specific div in a new tab for Newtoki when the backtick (`) key is pressed

当前为 2024-12-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Open Links in New Tab for Newtoki
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Open all URLs within a specific div in a new tab for Newtoki when the backtick (`) key is pressed
// @author       Your Name
// @match        *://*newtoki*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    /**
     * 설정: 동작할 클래스 이름 정의
     * - `targetUIClass`: 링크가 포함된 div의 클래스 이름
     */
    const targetUIClass = 'list-body'; // 대상 div 클래스 이름

    // 키 입력 이벤트 리스너 추가
    document.addEventListener('keydown', (event) => {
        // `` 키가 눌렸는지 확인
        if (event.key === '`') {
            // 대상 div 검색
            const targetDiv = document.querySelector(`.${targetUIClass}`);
            if (!targetDiv) {
                alert('대상 div를 찾을 수 없습니다.');
                return;
            }

            // div 내의 모든 링크를 가져오기
            const links = targetDiv.querySelectorAll('a[href]');
            if (links.length === 0) {
                alert('열 URL이 없습니다.');
                return;
            }

            // 각 링크를 새 창에서 열기
            links.forEach(link => {
                const url = link.href;
                if (url) window.open(url, '_blank');
            });

            alert(`${links.length}개의 링크가 새 창에서 열렸습니다.`);
        }
    });
})();