Bypass CDP Detection

2025/3/23 14:17:37

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Bypass CDP Detection
// @namespace   http://fulicat.com
// @author      Jack.Chan ([email protected])
// @version     1.0.2
// @run-at      document-start
// @match       *://*/*
// @match       file:///*
// @url         https://greasyfork.org/zh-CN/scripts/530590-bypass-cdp-detection
// @grant       none
// @description 2025/3/23 14:17:37
// @license MIT
// ==/UserScript==





;(function() {

	var originalError = Error;

	// Lock down the stack property on Error.prototype to prevent modification
	Object.defineProperty(Error.prototype, 'stack', {
		configurable: false,
		enumerable: true,
		writable: false,
		value: (function() {
			try {
				throw new originalError();
			} catch (e) {
				return e.stack;
			}
		})()
	});

	// Proxy the Error constructor to prevent any instance-specific stack modifications
	window.Error = new Proxy(originalError, {
		construct(target, args) {
			return originalError(...args);
			try {
				var instance = new target(...args);
				// Freeze the instance to prevent any modifications
				return Object.freeze(instance);
			} catch(ex) {
				console.log('// [bypass_CDP_Detection] ex:', ex);
			}
			return originalError(...args);
		}
	});


	// Override Object.defineProperty
  	var stackLookupCount = 0;
	var originalObjectDefineProperty = Object.defineProperty;
	Object.defineProperty = function defineProperty(obj, prop, descriptor) {
		if (prop === 'stack') {
			if (stackLookupCount < 10) {
				console.log('// [bypass_CDP_Detection] Object.defineProperty', stackLookupCount, String.fromCharCode(10), 'obj:', obj, String.fromCharCode(10), 'prop:', prop, String.fromCharCode(10), 'descriptor:', descriptor, String.fromCharCode(10), String.fromCharCode(10), String.fromCharCode(10) );
			} else {
				console.log('// [bypass_CDP_Detection] Object.defineProperty', 'too many times');
			}
			stackLookupCount++;
			return {};
		}
		return originalObjectDefineProperty.apply(Object, arguments);
	}
	Object.defineProperty.toString = function toString() {
		return originalObjectDefineProperty.toString();
	};


	// bypass https://kaliiiiiiiiii.github.io/brotector/
	const context = console.context;
	console.context = function() {
		return {
			...console,
			clear(){},
			log(){},
			debug(){},
		}
	};
	console.context.toString = function() {
		return context.toString();
	}


	// alert('bypass_CDP_detection injected');
})();