Unmask arca.live Links

Unmask oo.pe redirection on arca.live.

// ==UserScript==
// @name         Unmask arca.live Links
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Unmask oo.pe redirection on arca.live.
//               Bypasses oo.pe redirection. Developer of this userscript does not take responsibility for its use. Use at your own risk.
// @author       tempnickㅇㅇ
// @match        https://arca.live/*
// @grant        none
// @license      MIT
// @run-at       document-start
// @note         Language: Korean
// ==/UserScript==


(function() {
    'use strict';

    const unmaskAndCleanLinks = () => {
        document.querySelectorAll('a[href*="oo.pe"]').forEach(link => {
            // Modify the href attribute
            // Extract the original URL based on the specific format
            const originalUrl = link.href;
            const slicedUrl = originalUrl.split('/');
            console.log(slicedUrl);
            const endOfRedirection = slicedUrl.indexOf('oo.pe');

            // Adjusting the slice method to work correctly in JavaScript
            const remadeUrlArray = slicedUrl.slice(endOfRedirection + 1);

            // Join the array back into a string
            const remadeUrl = remadeUrlArray.join('/');
            link.href = remadeUrl;

            link.removeAttribute('class');
            // Or, if you want to remove only the 'external' value from the 'rel' attribute, use:
            link.rel = link.rel.split(' ').filter(val => val !== 'external').join(' ');
        });
    };

    // Run immediately and on dynamic content
    unmaskAndCleanLinks();
})();