Bypass CDP Detection

2025/3/23 14:17:37

当前为 2025-03-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bypass CDP Detection
  3. // @namespace http://fulicat.com
  4. // @author Jack.Chan (971546@qq.com)
  5. // @version 1.0.1
  6. // @run-at document-start
  7. // @match *://*/*
  8. // @match file:///*
  9. // @url https://greasyfork.org/zh-CN/scripts/530590-bypass-cdp-detection
  10. // @grant none
  11. // @description 2025/3/23 14:17:37
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15.  
  16.  
  17.  
  18.  
  19. ;(function() {
  20. var originalError = Error;
  21.  
  22. // Lock down the stack property on Error.prototype to prevent modification
  23. Object.defineProperty(Error.prototype, 'stack', {
  24. configurable: false,
  25. enumerable: true,
  26. writable: false,
  27. value: (function() {
  28. try {
  29. throw new originalError();
  30. } catch (e) {
  31. return e.stack;
  32. }
  33. })()
  34. });
  35.  
  36. // Proxy the Error constructor to prevent any instance-specific stack modifications
  37. window.Error = new Proxy(originalError, {
  38. construct(target, args) {
  39. var instance = new target(...args);
  40.  
  41. // Freeze the instance to prevent any modifications
  42. return Object.freeze(instance);
  43. }
  44.  
  45. });
  46.  
  47. // Override Object.defineProperty
  48. var originalObjectDefineProperty = Object.defineProperty;
  49. Object.defineProperty = function defineProperty(obj, prop, descriptor) {
  50. if (prop !== 'stack') {
  51. return originalObjectDefineProperty.apply(Object, arguments);
  52. } else {
  53. console.log('// CDP bypass [Object.defineProperty]', String.fromCharCode(10), 'obj:', obj, String.fromCharCode(10), 'prop:', prop, String.fromCharCode(10), 'descriptor:', descriptor, String.fromCharCode(10), String.fromCharCode(10), String.fromCharCode(10) );
  54. }
  55. return {};
  56. }
  57. Object.defineProperty.toString = function toString() {
  58. return originalObjectDefineProperty.toString();
  59. };
  60.  
  61. // alert('bypass_CDP_detection injected');
  62. })();