Auto-Login Script for SonarCloud with GitHub Authentication
Page content
Overview
This Tampermonkey script automatically handles the SonarCloud login process when you encounter authentication errors. It detects error pages and automatically initiates GitHub login, making the authentication process seamless.
Script
Create a new Tampermonkey script and paste the following code:
How it Works
The script performs the following tasks:
Error Page Detection
- Waits for the error message “The requested project does not exist, or you have not authenticated with SonarQube Cloud”
- Automatically clicks the “Login” button when found
Login Page Handling
- Detects when redirected to the login page
- Automatically clicks the configured social authentication button (GitHub by default)
Utilities
waitUntil
: A utility function that waits for specific conditions to be metfindAndClick
: Finds and clicks elements using XPath selectors- Built-in timeout mechanism to prevent infinite loops
Installation
- Install the Tampermonkey browser extension
- Create a new script
- Copy and paste the provided code
- Save the script
Configuration
The script includes two main configurable settings:
Timeout Configuration:
const TIMEOUT_CONFIG = { maxRetries: 20, // Maximum number of retry attempts interval: 500 // Check interval in milliseconds };
Social Identity Provider:
const SOCIAL_IDENTITY_PROVIDER = 'GitHub'; // Change this to use different providers
Notes
- Works with SonarCloud instances that use social authentication (GitHub by default)
- Automatically handles both error pages and login redirects
- Uses XPath selectors for reliable element detection
- Includes logging for easy debugging