Snahp base64 decoder

This script detects base64 encoded urls present in snahp pages and decodes them automatically without having to go to other websites :)

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Snahp base64 decoder
// @match        https://*.snahp.*/viewtopic.php*
// @match        https://fora.snahp.eu/viewtopic.php*
// @icon         https://cdn-icons-png.flaticon.com/512/2362/2362269.png
// @description  This script detects base64 encoded urls present in snahp pages and decodes them automatically without having to go to other websites :)
// @version      0.1.1
// @grant        none
// @namespace https://greasyfork.org/users/1581837
// ==/UserScript==

(function() {
    'use strict';

    console.log("Snahp URL Decoder: Script engaged");

    async function copy_text(e) {
        const text = e.target.innerText;
        try {
            await navigator.clipboard.writeText(text);
            console.log('Text copied to clipboard');
            const originalColor = e.target.style.color;
            e.target.style.color = '#4CAF50';
            setTimeout(() => {
                e.target.style.color = originalColor;
            }, 1000);
        } catch (err) {
            console.error('Failed to copy: ', err);
        }
    }

    function tryDecode(element) {
        const originalText = element.innerText.trim();
        if (!originalText) return;

        try {
            // Basic base64 validation (alphanumeric, +, /, and = padding)
            if (/^[a-zA-Z0-9+/]*={0,2}$/.test(originalText) && originalText.length > 4) {
                const decoded = atob(originalText);
                if (decoded && decoded.includes('://')) { // Simple check for URL-like content
                    element.innerText = decoded;
                    element.onclick = copy_text;
                    element.style.cursor = "pointer";
                    element.style.fontWeight = "bold";
                    element.style.color = "#007bff";
                    element.title = "Click to copy decoded URL";
                }
            }
        } catch (error) {
            // Not base64 or other error
        }
    }

    // Process code tags
    document.querySelectorAll("code").forEach(tryDecode);

    // Process dd tags (common in forum posts)
    document.querySelectorAll("dd").forEach(tryDecode);

})();