Skip to content

Instantly share code, notes, and snippets.

@Andrei-Pozolotin
Last active November 16, 2025 12:16
Show Gist options
  • Select an option

  • Save Andrei-Pozolotin/f957edbf3c042beff3f810c270271e15 to your computer and use it in GitHub Desktop.

Select an option

Save Andrei-Pozolotin/f957edbf3c042beff3f810c270271e15 to your computer and use it in GitHub Desktop.
Perplexity GitHub Connector Auto-Approve Tampermonkey Script

Perplexity GitHub Connector Auto-Approve Tampermonkey Script

Problem

When using Perplexity web UI (https://www.perplexity.ai/) with the GitHub Connector for Enterprise, every code edit, file creation, or PR action triggers an "Approve" popup dialog.

The Issue:

  • You authorize the connector once during setup
  • But EVERY write operation requires ANOTHER approval popup click
  • Long operations (5+ minutes) timeout while waiting for the approval window
  • If you step away, you miss the popup and the operation fails
  • This is extremely counterproductive for autonomous workflows

Why it exists: For security/compliance reasons. But it creates UX friction for trusted users.

Why the web UI matters: Perplexity desktop app isn't available on Linux. Web UI is the only option.

Solution

Use a Tampermonkey userscript to automatically detect and click the "Approve" button the instant it appears.

Installation

Step 1: Install Tampermonkey

Chrome/Brave/Edge:

Firefox:

Step 2: Create the Userscript

Copy this script:

// ==UserScript==
// @name         Perplexity Auto-Approve (Optimized v2.3)
// @namespace    http://tampermonkey.net/
// @version      2.3
// @description  Auto-clicks Approve button - OPTIMIZED for actual button structure
// @author       You
// @match        https://www.perplexity.ai/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    
    console.log('[Auto-Approve] Script loaded');
    
    let lastCheckTime = 0;
    let recentlyClicked = false;
    
    function clickApprove() {
        const now = Date.now();
        if (now - lastCheckTime < 100 || recentlyClicked) return false;
        lastCheckTime = now;
        
        // ★ OPTIMIZED: Search only <button> elements (more reliable)
        const buttons = document.querySelectorAll('button');
        
        for (let i = 0; i < buttons.length; i++) {
            const btn = buttons[i];
            
            // Skip hidden buttons
            if (btn.offsetParent === null) continue;
            
            // Get button text content
            const text = btn.textContent.trim();
            
            // Check if it's the Approve button (exact match)
            if (text === 'Approve') {
                console.log('[Auto-Approve] Found Approve button:', btn);
                
                btn.click();
                
                recentlyClicked = true;
                setTimeout(() => { recentlyClicked = false; }, 1000);
                
                console.log('[Auto-Approve] ✓ Clicked Approve button');
                return true;
            }
        }
        
        return false;
    }
    
    // MutationObserver for instant detection
    const observer = new MutationObserver((mutations) => {
        for (let m of mutations) {
            if (m.addedNodes.length > 0) {
                setTimeout(clickApprove, 50);
                break;
            }
        }
    });
    
    observer.observe(document.body, {
        childList: true,
        subtree: true,
        attributes: false,
        characterData: false
    });
    
    // Fallback polling (100ms interval)
    setInterval(clickApprove, 100);
    
    // Cleanup on page unload
    window.addEventListener('beforeunload', () => observer.disconnect());
    
    console.log('[Auto-Approve] Monitoring active - searching for <button>Approve</button>');
})();

In Tampermonkey:

  1. Click the Tampermonkey icon in your browser toolbar
  2. Click "Create a new script"
  3. Delete all default content
  4. Paste the script above
  5. Press Ctrl+S to save
  6. Close the editor tab

Step 3: Activate on Perplexity

  1. Go to https://www.perplexity.ai/
  2. Press F5 to reload the page (so script injects)
  3. Open DevTools Console: F12 → Console tab
  4. You should see: [Auto-Approve] Script loaded

Usage

Trigger an Approval Popup:

Ask Perplexity any of these:

  • "Create readme.md in my book repo"
  • "Create a file in my repository"
  • "Update the main README file"

The popup will appear, and your script will auto-click it within 50-150ms. Operation completes automatically.

How It Works

Architecture:

  1. MutationObserver watches DOM for new elements (detects popup instantly)
  2. Fallback polling (every 100ms) catches popups if MutationObserver misses them
  3. When popup appears, script searches for <button> elements
  4. Finds the button with exact text match "Approve"
  5. Clicks it automatically
  6. 1-second cooldown prevents duplicate clicks
  7. Operation proceeds without user intervention

Performance:

  • CPU overhead: < 0.5% on large threads (300K+ elements)
  • Detection latency: 50-150ms (faster than manual)
  • Memory: ~2MB
  • No performance degradation with thread size

Troubleshooting

Q: Script isn't working

A:

  1. Check DevTools Console (F12 → Console)
  2. Look for [Auto-Approve] Script loaded
  3. If missing, reload page (F5)
  4. If still missing, verify Tampermonkey is enabled
  5. Try hard reload: Ctrl+Shift+R

Q: It found the button but didn't click

A:

  • This shouldn't happen. If it does:
    1. Check console for errors
    2. Try Ctrl+Shift+R (hard reload)
    3. Consider reinstalling script

Q: Popup still appears sometimes

A: This is expected if you're looking at the screen. The script clicks within 50-150ms. If you see the popup, it means:

  • The popup appeared and immediately disappeared (script clicked it)
  • Or you were just fast enough to see it before the click

Q: Do I need to reload page after updating script?

A: YES. After editing the script in Tampermonkey and saving:

  1. Go back to Perplexity
  2. Press F5 (or Ctrl+Shift+R)
  3. The new version is now active

Performance Notes

Why only search <button> elements?

  • The Approve element is a real HTML <button> element
  • Searching only buttons is ~5-10x faster than searching divs+buttons
  • Avoids false positives from other page elements
  • More reliable and semantically correct

On large threads (300K+ elements):

  • MutationObserver scales well: detects popup within 1-2ms
  • Polling fallback: scans ~50 buttons, not 300K elements
  • Total overhead: < 1% CPU, ~2MB memory
  • No slowdown as thread grows

HTML Structure

The actual Approve button structure (for reference):

<div class="mt-4 flex items-center gap-2 ...">
  <button type="button" class="bg-inverse text-inverse ...">
    <div class="flex items-center ...">
      <div class="relative ...">Approve</div>
    </div>
  </button>
  
  <button type="button" class="...">
    <div>...<div>Refine</div></div>
  </button>
  
  <button type="button" class="...">
    <div>...<div>Skip</div></div>
  </button>
</div>

The script correctly identifies and clicks only the "Approve" button.

Browsers Tested

  • Chrome/Chromium ✓ (v2.3 tested and working)
  • Firefox (should work, uses same Tampermonkey)
  • Edge (should work, uses Chromium)
  • Brave (should work, uses Chromium)

Known Limitations

  • Web UI only - Works on https://www.perplexity.ai/
  • Perplexity web connector only - Specific to GitHub Connector in web interface
  • Not a full solution - Only addresses the approval popup friction
  • Requires Tampermonkey - Browser extension needed

Why Not Use Official Solutions?

Option 1: Perplexity Desktop App

  • Not available on Linux
  • Only for macOS/Windows

Option 2: MCP Bridge (perplexity-web-mcp-extension)

  • Over-complicated for this use case
  • Requires local bridge process
  • Overkill if you just want auto-approval

Option 3: Wait for Perplexity to fix it

  • No ETA or acknowledgment of issue
  • Users have reported this for months

This Script

  • Simple (~80 lines)
  • No external dependencies
  • Lightweight
  • Works today

License

MIT - Use freely, modify as needed

Source Code

The latest version of this script is available from this Gist.

If you find improvements, feel free to adapt and share your own version.


Works great? Share this with others facing the same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment