No feature flags available. Try opening the settings menu to populate flags.
'}// ==UserScript== // @name Grok Feature Flags OLD DEPRICATED // @namespace http://tampermonkey.net/ // @version 1.0 // @description Toggle feature flags on grok.com to test out new features // @author Blankspeaker // @match https://grok.com/* // @grant none // @license GNU GPLv3 // @downloadURL https://update.greasyfork.icu/scripts/536218/Grok%20Feature%20Flags%20OLD%20DEPRICATED.user.js // @updateURL https://update.greasyfork.icu/scripts/536218/Grok%20Feature%20Flags%20OLD%20DEPRICATED.meta.js // ==/UserScript== (async function() { 'use strict'; try { // Function to find and fetch the JavaScript file containing local_feature_flags async function findFlagsFile() { const scripts = Array.from(document.getElementsByTagName('script')).map(script => script.src).filter(src => src); for (const src of scripts) { if (src.includes('.js') && !src.includes('polyfill')) { try { const response = await fetch(src); const text = await response.text(); if (text.includes('"local_feature_flags"')) { console.log("Found flags file:", src); return { src, text }; } } catch (error) { console.warn("Failed to fetch script:", src, error); } } } console.error("No JavaScript file found containing local_feature_flags."); return null; } // Function to scrape flags from the JavaScript file function scrapeFlags(fileContent) { // Match flag definitions like SHOW_FAVORITE_BUTTON: e("show_favorite_button") const regex = /\b([A-Z_]+)\s*:\s*e\s*\(\s*"([a-z_]+)"\s*\)/g; const flags = {}; let match; while ((match = regex.exec(fileContent)) !== null) { const upperKey = match[1]; // e.g., SHOW_FAVORITE_BUTTON const lowerKey = match[2]; // e.g., show_favorite_button flags[lowerKey] = false; flags[upperKey] = false; } // Handle non-boolean flags (preserve if present) const nonBooleanRegex = /\b([A-Z_]+)\s*:\s*t\s*\(\s*"([a-z_]+)"\s*\)/g; while ((match = nonBooleanRegex.exec(fileContent)) !== null) { const upperKey = match[1]; const lowerKey = match[2]; // Only include if already in localStorage (to avoid UI issues) if (currentFlags[upperKey] !== undefined) flags[upperKey] = currentFlags[upperKey]; if (currentFlags[lowerKey] !== undefined) flags[lowerKey] = currentFlags[lowerKey]; } return flags; } // Check localStorage availability (for incognito mode) let localStorageAvailable = true; try { localStorage.setItem("test", "test"); localStorage.removeItem("test"); } catch (error) { localStorageAvailable = false; console.warn("localStorage is restricted (e.g., incognito mode):", error); } // Read current flags from localStorage let rawFlags = localStorageAvailable ? localStorage.getItem("local_feature_flags") : null; console.log("Raw local_feature_flags:", rawFlags); let currentFlags = rawFlags ? JSON.parse(rawFlags) : {}; // If localStorage is empty or unavailable, scrape flags from source if (Object.keys(currentFlags).length === 0) { console.log("No flags in localStorage. Attempting to scrape from source..."); const flagsFile = await findFlagsFile(); if (flagsFile) { const scrapedFlags = scrapeFlags(flagsFile.text); if (Object.keys(scrapedFlags).length > 0) { currentFlags = { ...scrapedFlags }; if (localStorageAvailable) { localStorage.setItem("local_feature_flags", JSON.stringify(currentFlags)); console.log("Scraped and initialized flags:", Object.keys(currentFlags)); } else { console.warn("Using scraped flags in memory due to localStorage restrictions."); } } else { console.error("No flags scraped from source."); } } else { console.error("Unable to initialize flags: No source file found."); } } // Group flags by uppercase name to avoid duplicate display let flagGroups = {}; Object.keys(currentFlags).forEach(flag => { const normalized = flag.toUpperCase(); if (!flagGroups[normalized]) { flagGroups[normalized] = []; } flagGroups[normalized].push(flag); }); let displayFlags = Object.keys(flagGroups); // Log flag counts console.log("Total flags:", Object.keys(currentFlags).length, "Unique flags (after normalization):", displayFlags.length); // Create UI element for flag picker let ui = document.createElement("div"); ui.id = "feature-flags-ui"; ui.style.display = "none"; // Initially hidden ui.innerHTML = `
No feature flags available. Try opening the settings menu to populate flags.
'}