Chrome Stats Redirector

Adds a menu to jump to chrome-stats.com for the current extension

As of 30. 11. 2025. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Chrome Stats Redirector
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a menu to jump to chrome-stats.com for the current extension
// @author       aspen138
// @match        https://*/*
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab
// @license      MIT
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADdgAAA3YBfdWCzAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAVaSURBVGiB7ZhdbBRVFMd/d2Y/6gJLl0JbuyvQlg81IGpM0KiYaOKDL4JGiA/ExAfjR4jB+EV8VhM0IlAFjInig4kBfDDERI0lKIiiVR/QAqUtkm5rt93ttrSyuzM714d2tvsxs522Q5smPclm55577jn//73n3nNnhJSSuSzKbAOYrswTmG2Z8wQ85kNPT4/tbnZ7o7vhLxwOC8gjIISwDVLcNxVx258plik0l45WT7FiquCllOi67shWVVXXViFHYDqzLoQ4J4R4d/ny5Yed2Eej0aeEEC9LKddNOeiYuHIKVVRU7K6trXUEHiAcDh/2+Xy73YjtCgFFUSa9fFMZY+nHDSepVOq1eDy+3al9PB7fnslkXnUjtjBzv1wdcCoT7SOz340NXFdXV1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R1cv4krQC0g8KxsBuNgrLIGb4AvaY//mmKy/0QZ8YVvJJp0TiKUHS3Rm2mgC3t9QCYC3fjSHO/usgRcX53ybjrFbguFvKA/e/JqnT7ACmqb9URhcFvzy5ZfaAKfqAhaBJyzOpYpynTbXCF3XW0oIGIZxwHyurghaDhwPINl3W4hrl0cLUv0ye+AlxXVMUb9sDECm3RF46Rk/QvOx5upATU3Np9FoVPF6vc8s9Sy68x8jVvbNKBpQOTrwL0/rOvVVILPj2Wg5qkjZUGWgaRLfcDtSN8rYjjZ0NUg6nW7Rdf1QJBL5zOwVM/kJ5HrI/Iet2ZZ5ArMt/wPqstzYeSUXpQAAAABJRU5ErkJggg==
// ==/UserScript==

(function() {
    'use strict';

    // Extract extension ID from a URL or string
    function extractExtensionId(input) {
        if (!input) return null;

        input = input.trim();

        // If it's already a 32-char lowercase string, return it
        if (/^[a-z]{32}$/.test(input)) {
            return input;
        }

        // Try to extract from URL or any string containing the ID
        const match = input.match(/[a-z]{32}/);
        return match ? match[0] : null;
    }

    // Try to get extension ID from referrer (Chrome Web Store iframe context)
    function getExtensionIdFromContext() {
        if (document.referrer && document.referrer.includes('chromewebstore.google.com')) {
            return extractExtensionId(document.referrer);
        }
        return null;
    }

    // Open chrome-stats page
    function openChromeStats(extensionId) {
        const statsUrl = 'https://chrome-stats.com/d/' + extensionId;
        console.log('[ChromeStats] Opening:', statsUrl);
        GM_openInTab(statsUrl, { active: true });
    }

    // Prompt user for extension ID
    function promptForExtensionId() {
        // Try to get from context first
        const contextId = getExtensionIdFromContext();
        const defaultValue = contextId || '';

        const input = prompt(
            'Enter Chrome extension ID or Chrome Web Store URL:\n\n' +
            'Examples:\n' +
            '• gcalenpjmijncebpfijmoaglllgpjagf\n' +
            '• https://chromewebstore.google.com/detail/xxx/gcalenpjmijncebpfijmoaglllgpjagf',
            defaultValue
        );

        if (!input) {
            return; // User cancelled
        }

        const extensionId = extractExtensionId(input);

        if (extensionId) {
            openChromeStats(extensionId);
        } else {
            alert(
                'Invalid input!\n\n' +
                'Could not find a valid extension ID.\n' +
                'Extension IDs are 32 lowercase letters (a-z).'
            );
        }
    }

    // Register menu command - always available
    GM_registerMenuCommand('📊 Open Chrome Stats', promptForExtensionId);

})();