FMHY Base64 Rentry Decoder-Linkifier

Decode base64-encoded the FMHY Rentry page and make URLs clickable

目前为 2024-01-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         FMHY Base64 Rentry Decoder-Linkifier
// @version      1.0
// @description  Decode base64-encoded the FMHY Rentry page and make URLs clickable
// @match        https://rentry.co/fmhybase64*
// @match        https://rentry.co/FMHYBase64*
// @match        https://rentry.org/fmhybase64*
// @match        https://rentry.org/FMHYBase64*
// @grant        none
// @namespace https://gf.qytechs.cn/users/980489
// ==/UserScript==


(function() {
    'use strict';

    // Function to decode base64 string
    function decodeBase64(encodedString) {
        return atob(encodedString);
    }

    // Function to check if a string is a URL
    function isURL(string) {
        try {
            new URL(string);
            return true;
        } catch (_) {
            return false;
        }
    }

    // Select all <code> elements
    var codeElements = document.querySelectorAll('code');

    // Loop through each <code> element
    codeElements.forEach(function(codeElement) {
        // Get the content of the <code> element
        var encodedString = codeElement.textContent.trim();

        // Decode the base64-encoded string
        var decodedString = decodeBase64(encodedString);

        // If the decoded string is a URL, create a clickable link
        if (isURL(decodedString)) {
            var link = document.createElement('a');
            link.href = decodedString;
            link.textContent = decodedString;
            link.target = '_blank'; // Open link in a new tab
            codeElement.textContent = ''; // Clear the content of <code> element
            codeElement.appendChild(link); // Append the link to the <code> element
        } else {
            // Replace the content of the <code> element with the decoded string
            codeElement.textContent = decodedString;
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址