GeminiBot commited on
Commit ·
0fbfbaf
1
Parent(s): a118953
Aggressive fix for iframe contentDocument null error
Browse files27 unmodified lines282930313233343536373839404127 unmodified lineswindow.chrome = { runtime: {} };// Fix for 'Cannot read properties of null (reading 'contentDocument')'// Some challenge scripts create an iframe and immediately access contentDocumentconst originalCreateElement = window.document.createElement;window.document.createElement = function(tagName: string) {const element = originalCreateElement.call(this, tagName);if (tagName.toLowerCase() === 'iframe') {try {Object.defineProperty(element, 'contentDocument', {get: () => window.document, // Return main document as fallback or a dummyconfigurable: true});Object.defineProperty(element, 'contentWindow', {27 unmodified lines282930313233343536373839404142434445464748495051525327 unmodified lineswindow.chrome = { runtime: {} };// Fix for 'Cannot read properties of null (reading 'contentDocument')'// Aggressive Patch: Modify the prototype directlyObject.defineProperty(window.HTMLIFrameElement.prototype, 'contentDocument', {get: function() { return window.document; },configurable: true});Object.defineProperty(window.HTMLIFrameElement.prototype, 'contentWindow', {get: function() { return window; },configurable: true});// Also keep the createElement hook just in caseconst originalCreateElement = window.document.createElement;window.document.createElement = function(tagName: string) {const element = originalCreateElement.call(this, tagName);if (tagName.toLowerCase() === 'iframe') {try {// Ensure properties are set on the instance as wellObject.defineProperty(element, 'contentDocument', {get: () => window.document,configurable: true});Object.defineProperty(element, 'contentWindow', {
src/duckai.ts+14-2