Bypass Multiple Screen Detection

Published on
4 mins read

Bypass Multiple Screen Detection with Tampermonkey Script

Install the Tampermonkey extension in your browser and create a new script with the following code:

// ==UserScript==
// @name         Override Screen Detection
// @namespace    http://tampermonkey.net/
// @version      2025-06-13
// @description  Override multiple screen detection
// @author       7dpk
// @match        https://subdomain.yousite.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=yoursite.com
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    console.log('Screen override script loaded');

    // Try 1: Immediate override if API exists
    function overrideScreenAPI() {
        if (window.getScreenDetails) {
            console.log('Found getScreenDetails, overriding...');
            const originalGetScreenDetails = window.getScreenDetails;

            window.getScreenDetails = async function() {
                console.log('getScreenDetails called, returning single screen');
                try {
                    const originalDetails = await originalGetScreenDetails.call(this);
                    console.log('Original details:', originalDetails);

                    const modifiedDetails = {
                        ...originalDetails,
                        screens: [originalDetails.screens[0]],
                        currentScreen: originalDetails.screens[0]
                    };
                    console.log('Modified details:', modifiedDetails);
                    return modifiedDetails;
                } catch (error) {
                    console.error('Error in getScreenDetails override:', error);
                    // Fallback to mock data
                    return {
                        screens: [{
                            availHeight: 1080,
                            availWidth: 1920,
                            colorDepth: 24,
                            height: 1080,
                            width: 1920,
                            pixelDepth: 24,
                            left: 0,
                            top: 0,
                            isPrimary: true,
                            isInternal: true
                        }],
                        currentScreen: {
                            availHeight: 1080,
                            availWidth: 1920,
                            colorDepth: 24,
                            height: 1080,
                            width: 1920,
                            pixelDepth: 24,
                            left: 0,
                            top: 0,
                            isPrimary: true,
                            isInternal: true
                        }
                    };
                }
            };
        }
    }

    // Try 2: Intercept when API gets defined
    let originalDescriptor = Object.getOwnPropertyDescriptor(window, 'getScreenDetails');

    Object.defineProperty(window, 'getScreenDetails', {
        configurable: true,
        enumerable: true,
        set: function(value) {
            console.log('getScreenDetails being set, intercepting...');

            const wrappedFunction = async function() {
                console.log('Wrapped getScreenDetails called');
                try {
                    const originalDetails = await value.call(this);
                    console.log('Original screen details:', originalDetails);

                    return {
                        ...originalDetails,
                        screens: [originalDetails.screens[0]],
                        currentScreen: originalDetails.screens[0]
                    };
                } catch (error) {
                    console.error('Error in wrapped getScreenDetails:', error);
                    return {
                        screens: [{
                            availHeight: 1080,
                            availWidth: 1920,
                            colorDepth: 24,
                            height: 1080,
                            width: 1920,
                            pixelDepth: 24,
                            left: 0,
                            top: 0,
                            isPrimary: true,
                            isInternal: true
                        }],
                        currentScreen: {
                            availHeight: 1080,
                            availWidth: 1920,
                            colorDepth: 24,
                            height: 1080,
                            width: 1920,
                            pixelDepth: 24,
                            left: 0,
                            top: 0,
                            isPrimary: true,
                            isInternal: true
                        }
                    };
                }
            };

            // Store the wrapped function
            this._getScreenDetails = wrappedFunction;
        },
        get: function() {
            return this._getScreenDetails || originalDescriptor?.value;
        }
    });

    // Try 3: Try to override immediately
    overrideScreenAPI();

    // Try 4: Try again when DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', overrideScreenAPI);
    } else {
        overrideScreenAPI();
    }

    // Try 5: Periodic check for the API
    let checkCount = 0;
    const checkInterval = setInterval(() => {
        checkCount++;
        console.log(`Checking for getScreenDetails (attempt ${checkCount})`);

        if (window.getScreenDetails && typeof window.getScreenDetails === 'function') {
            console.log('Found getScreenDetails via periodic check');
            overrideScreenAPI();
            clearInterval(checkInterval);
        }

        if (checkCount > 50) { // Stop after 5 seconds
            clearInterval(checkInterval);
        }
    }, 100);

})();

This script overrides the getScreenDetails function to return a single screen's details, effectively bypassing multiple screen detection. It includes several strategies to ensure the override works, including immediate override, interception of property setting, and periodic checks.