// ==UserScript== // @name FMHY Base64 Rentry Decoder-Linkifier // @version 1.1 // @description Decode base64-encoded links in some pastebins and make URLs clickable // // @include /^https:\/\/rentry\.(?:co|org)\/fmhybase64(?:#.*)?/ // // @match https://pastes.fmhy.net/* // @match https://rentry.co/* // @match https://rentry.org/* // // @grant none // @icon https://www.google.com/s2/favicons?sz=64&domain=fmhy.pages.dev // @namespace https://greasyfork.org/users/980489 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Regular expression to match base64-encoded strings const base64Regex = /^[A-Za-z0-9+/]+={0,2}$/; // 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; } } // Regex pattern to match the specified URLs (case-insensitive) var FMHYmainBase64PageRegex = /^https:\/\/rentry\.(?:co|org)\/fmhybase64(?:#.*)?/i; // Check if the current URL matches the regex pattern var currentUrl = window.location.href; var isFMHYmainBase64PageMatched = FMHYmainBase64PageRegex.test(currentUrl); // Select appropriate tags based on the URL matching var elementsToCheck = isFMHYmainBase64PageMatched ? document.querySelectorAll('code') : document.querySelectorAll('code, p'); // Loop through each selected element elementsToCheck.forEach(function(element) { // Get the content of the element var content = element.textContent.trim(); // Check if the content matches the base64 regex if (base64Regex.test(content)) { // Decode the base64-encoded string var decodedString = decodeBase64(content); // 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 element.textContent = ''; // Clear the content of the element element.appendChild(link); // Append the link to the element } else { // Replace the content of the element with the decoded string element.textContent = decodedString; } } }); })();