TwitCasting Link Fix

ツイキャスのサポートリストでアイコン・ユーザー名クリック時にプロフィールを表示せずにライブページを直接開く

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 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         TwitCasting Link Fix
// @namespace    http://tampermonkey.net/
// @version      1.02
// @description  ツイキャスのサポートリストでアイコン・ユーザー名クリック時にプロフィールを表示せずにライブページを直接開く
// @author       RIE_0924
// @homepage     https://github.com/rie0924/TwitCasting-Link-Fix
// @match        https://twitcasting.tv/*
// @icon         https://raw.githubusercontent.com/rie0924/TwitCasting-Link-Fix/main/twitcas_bigger_1.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // アイコン・ユーザー名をライブページへのリンクに変更
    function bindLiveLinks(parent = document) {
        parent.querySelectorAll('.tw-user-name-icon, .tw-supporter-user-name').forEach(a => {
            if (a.dataset.bound) return; // 二重バインド防止
            a.dataset.bound = 'true';
            a.addEventListener('click', e => {
                e.preventDefault();
                e.stopPropagation();
                const href = a.getAttribute('href');
                if (!href) return;
                setTimeout(() => window.open(href + '/live', '_blank'), 50);
            });
        });
    }

    // 初期バインド
    bindLiveLinks();

    // 動的追加要素にも対応
    const observer = new MutationObserver(mutations => {
        mutations.forEach(m => {
            m.addedNodes.forEach(node => {
                if (node.nodeType === 1) bindLiveLinks(node);
            });
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();