Base64 Auto Decoder

Decode base64-encoded links

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);