Base64 Auto Decoder

Decode base64-encoded links

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Base64 Auto Decoder
// @namespace   Wiki-Index
// @match       *://wiki-index.pages.dev/*
// @grant       none
// @version     1.0
// @description Decode base64-encoded links
// ==/UserScript==

setTimeout(() => {
  'use strict';
  const base64Regex = /^[A-Za-z0-9+/]+=*$/;
  const isURL = (str) => /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(str);
  const decodeAndDisplay = (element) => {
    const content = element.textContent.trim();
    if (base64Regex.test(content)) {
      const decodedString = atob(content).trim();
      if (isURL(decodedString)) {
        element.innerHTML = `<a href="${decodedString}" target="_self">${decodedString}</a>`;
      }
    }
  };
  const observer = new IntersectionObserver((entries, observer) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        decodeAndDisplay(entry.target);
        observer.unobserve(entry.target);
      }
    });
  });
  document.querySelectorAll('code, p').forEach(element => {
    observer.observe(element);
  });
}, 5000);