Search Decode

Decodes Base64 search queries into URLs or text.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Search Decode
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Decodes Base64 search queries into URLs or text.
// @author       bewf, KHROTU
// @match        https://www.google.com/search*
// @match        https://www.bing.com/search*
// @match        https://duckduckgo.com/*
// @match        https://search.brave.com/search*
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const enabled = GM_getValue('sd_enabled', true);
    const mode = GM_getValue('sd_mode', 'url_only');
    GM_registerMenuCommand(enabled ? 'Search Decode: Enabled' : 'Search Decode: Disabled', () => { GM_setValue('sd_enabled', !enabled); location.reload(); });
    GM_registerMenuCommand(mode === 'url_only' ? 'Search Decode: URL Only' : 'Search Decode: URL + Text', () => { GM_setValue('sd_mode', mode === 'url_only' ? 'all' : 'url_only'); location.reload(); });
    if (!enabled) return;
    const q = new URL(location.href).searchParams.get('q');
    if (!q) return;
    let decoded;
    try { decoded = decodeURIComponent(escape(atob(q))).trim(); } catch { return; }
    if (!decoded) return;
    const isUrl = /^(https?:\/\/|www\.|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})/.test(decoded);
    if (mode === 'url_only') {
        if (isUrl) location.replace(decoded.startsWith('http') ? decoded : 'https://' + decoded);
    } else {
        if (isUrl) location.replace(decoded.startsWith('http') ? decoded : 'https://' + decoded);
        else {
            const href = location.href, encoded = encodeURIComponent(decoded);
            if (href.includes('duckduckgo.com')) location.replace('https://duckduckgo.com/?q=' + encoded);
            else if (href.includes('bing.com')) location.replace('https://www.bing.com/search?q=' + encoded);
            else if (href.includes('brave.com')) location.replace('https://search.brave.com/search?q=' + encoded);
            else location.replace('https://www.google.com/search?q=' + encoded);
        }
    }
})();