Facebook DevTools Enabler

Restores right-click, context menu, and enables Eruda/dev tools on Facebook

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Facebook DevTools Enabler
// @namespace    http://tampermonkey.net
// @version      1.1
// @description  Restores right-click, context menu, and enables Eruda/dev tools on Facebook
// @match        https://*.facebook.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // ==========================================
    // BLOCK RIGHT-CLICK PREVENTION
    // ==========================================
    
    // Store original addEventListener
    const originalAddEventListener = EventTarget.prototype.addEventListener;
    
    // Override addEventListener to block contextmenu prevention
    EventTarget.prototype.addEventListener = function(type, listener, options) {
        // Block contextmenu, selectstart, copy, cut, paste prevention
        const blockedEvents = ['contextmenu', 'selectstart', 'dragstart', 'copy', 'cut', 'paste'];
        
        if (blockedEvents.includes(type)) {
            console.log(`[DevTools Enabler] Blocked ${type} event listener`);
            return;
        }
        
        // Block keydown prevention for F12, Ctrl+Shift+I, etc.
        if (type === 'keydown' || type === 'keyup') {
            const wrappedListener = function(e) {
                // Allow dev tool shortcuts
                if (e.key === 'F12' || 
                    (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.key === 'J' || e.key === 'C')) ||
                    (e.ctrlKey && e.key === 'U')) {
                    return;
                }
                return listener.call(this, e);
            };
            return originalAddEventListener.call(this, type, wrappedListener, options);
        }
        
        return originalAddEventListener.call(this, type, listener, options);
    };

    // ==========================================
    // REMOVE EXISTING BLOCKERS
    // ==========================================
    
    // Remove oncontextmenu, onselectstart, etc from document and body
    const removeBlockers = () => {
        if (document.documentElement) {
            document.documentElement.oncontextmenu = null;
            document.documentElement.onselectstart = null;
            document.documentElement.ondragstart = null;
        }
        if (document.body) {
            document.body.oncontextmenu = null;
            document.body.onselectstart = null;
            document.body.ondragstart = null;
        }
    };

    // Run immediately and on DOM ready
    removeBlockers();
    document.addEventListener('DOMContentLoaded', removeBlockers);

    // ==========================================
    // INJECT ERUDA (if not already loaded)
    // ==========================================
    
    const injectEruda = () => {
        if (window.eruda) return; // Already loaded
        
        const script = document.createElement('script');
        script.src = 'https://cdn.jsdelivr.net/npm/eruda';
        script.onload = () => {
            window.eruda.init({
                tool: ['console', 'elements', 'network', 'resources', 'info'],
                autoScale: true,
                defaults: { displaySize: 50 }
            });
            console.log('[DevTools Enabler] Eruda console initialized');
        };
        document.head.appendChild(script);
    };

    // ==========================================
    // BYPASS SECURITY POLICIES
    // ==========================================
    
    // Remove Content Security Policy restrictions
    const meta = document.createElement('meta');
    meta.httpEquiv = 'Content-Security-Policy';
    meta.content = "default-src * 'unsafe-inline' 'unsafe-eval' data: blob:; script-src * 'unsafe-inline' 'unsafe-eval'; style-src * 'unsafe-inline';";
    
    if (document.head) {
        document.head.appendChild(meta);
    } else {
        document.addEventListener('DOMContentLoaded', () => {
            document.head.appendChild(meta);
        });
    }

    // ==========================================
    // UNBLOCK DEV TOOLS SHORTCUTS
    // ==========================================
    
    window.addEventListener('keydown', (e) => {
        // Don't block F12 or Ctrl+Shift+I/J/C
        if (e.key === 'F12' || 
            (e.ctrlKey && e.shiftKey && ['I','J','C'].includes(e.key))) {
            e.stopImmediatePropagation();
        }
    }, true);

    // ==========================================
    // INIT
    // ==========================================
    
    console.log("[DevTools Enabler] Facebook restrictions bypassed");
    
    // Inject Eruda after a short delay to ensure page is ready
    setTimeout(injectEruda, 1000);
    
    // Re-apply blockers removal periodically
    setInterval(removeBlockers, 2000);

})();