lolcast_redirect

직링 리디렉션기능

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         lolcast_redirect
// @namespace    lolcast_redirect
// @version      0.2
// @description  직링 리디렉션기능
// @author       You
// @match        https://insagirl-toto.appspot.com/chatting/lgic/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to change the href of YouTube links
    var changeLinks = function() {
        var anchors = document.getElementsByTagName('a');

        for (var i = 0; i < anchors.length; i++) {
            var anchor = anchors[i];

            if (anchor.href.includes('https://youtu.be/')) {
                var videoId = anchor.href.split('https://youtu.be/')[1];
                anchor.href = 'https://lolcast.kr/#/player/youtube/' + videoId;
            } else if (anchor.href.includes('https://www.youtube.com/watch?v=')) {
                var videoId = anchor.href.split('https://www.youtube.com/watch?v=')[1];
                // Remove any additional parameters after '&'
                videoId = videoId.split('&')[0];
                anchor.href = 'https://lolcast.kr/#/player/youtube/' + videoId;
            }
        }
    };

    // Create a MutationObserver to watch for changes in the DOM
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
                changeLinks();
            }
        });
    });

    // Start observing the document with the configured parameters
    observer.observe(document.body, { childList: true, subtree: true });
})();