Last active
February 11, 2024 20:57
-
-
Save B1-Bloom/1de0774d439601c2af1faa610c490f84 to your computer and use it in GitHub Desktop.
DCB.64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Auto Decoder for all sites | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Decode Base64 encoded links for all sites | |
// @author Coder | |
// @match *://**/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
const base64Regex = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{20,})$/g | |
// Must set an interval, otherwise the content that is lazy loaded (e.g. loaded on scrolling) will not get decoded | |
setInterval(() => { | |
const pTags = document.querySelectorAll('p') | |
pTags.forEach(pTag => { | |
// Split the string into an array and check each element for a base64 encoded string | |
const pTagText = pTag.innerText.split(/\s+/); | |
pTagText.forEach(text => { | |
if (base64Regex.test(text)) { | |
// If the string is a base64 encoded string, decode it and replace the p tag with the decoded string | |
pTag.innerText = pTag.innerText.replace(text, atob(text)); | |
const txt = pTag.innerText.split("\n"); | |
const links = []; | |
txt.forEach(link => { | |
links.push("<a href='" + link + "'>" + link + "</a>"); | |
}); | |
pTag.outerHTML = links.join("\n"); | |
} | |
}); | |
}) | |
}, 500) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment