diff --git a/public/disable-gateway-message.js b/public/disable-gateway-message.js new file mode 100644 index 0000000..c395aff --- /dev/null +++ b/public/disable-gateway-message.js @@ -0,0 +1,26 @@ +(function() { + // Immediately disable qdnGatewayShowModal if it exists + + + // Now, let's wrap the handleResponse function with the new condition + const originalHandleResponse = window.handleResponse; // Save the original handleResponse function + + if (typeof originalHandleResponse === 'function') { + // Create the wrapper function to enhance the original handleResponse + window.handleResponse = function(event, response) { + // Check if the response contains the specific error message + if (response && typeof response === 'string' && response.includes("Interactive features were requested")) { + console.log('Response contains "Interactive features were requested", skipping processing.'); + return; // Skip further processing + } + + // Call the original handleResponse for normal processing + originalHandleResponse(event, response); + }; + + console.log('handleResponse has been enhanced to skip specific error handling.'); + } else { + console.log('No handleResponse function found to enhance.'); + } + +})(); diff --git a/public/disable-gateway-popup.js b/public/disable-gateway-popup.js new file mode 100644 index 0000000..58ee0b3 --- /dev/null +++ b/public/disable-gateway-popup.js @@ -0,0 +1,21 @@ +(function() { + console.log('External script loaded to disable qdnGatewayShowModal'); + + // Poll for qdnGatewayShowModal and disable it once it's defined + const checkQdnGatewayInterval = setInterval(() => { + if (typeof window.qdnGatewayShowModal === 'function') { + console.log('Disabling qdnGatewayShowModal'); + + // Disable qdnGatewayShowModal function + window.qdnGatewayShowModal = function(message) { + console.log('qdnGatewayShowModal function has been disabled.'); + }; + + // Stop checking once qdnGatewayShowModal has been disabled + clearInterval(checkQdnGatewayInterval); + } else { + console.log('Waiting for qdnGatewayShowModal to be defined...'); + } + }, 100); // Check every 100ms + +})(); diff --git a/public/document_end.js b/public/document_end.js new file mode 100644 index 0000000..748d513 --- /dev/null +++ b/public/document_end.js @@ -0,0 +1,7 @@ + +const script2 = document.createElement('script'); +script2.src = chrome.runtime.getURL('disable-gateway-message.js'); // Reference the external script +document.documentElement.appendChild(script2); // Inject it into the page +script2.onload = function() { + script2.remove(); // Clean up after the script has been injected and run +}; \ No newline at end of file diff --git a/public/document_start.js b/public/document_start.js new file mode 100644 index 0000000..19c7adf --- /dev/null +++ b/public/document_start.js @@ -0,0 +1,7 @@ + +const script = document.createElement('script'); +script.src = chrome.runtime.getURL('disable-gateway-popup.js'); // Reference the external script +document.documentElement.appendChild(script); // Inject it into the page +script.onload = function() { + script.remove(); // Clean up after the script has been injected and run +}; \ No newline at end of file diff --git a/public/manifest.json b/public/manifest.json index 70c4ce3..5d88b27 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -18,11 +18,33 @@ ], "content_scripts": [ + { + "matches": [""], + "js": ["document_start.js"], + "run_at": "document_start" + }, { "matches": [""], "js": ["content-script.js"] + }, + + { + "matches": [""], + "js": ["document_end.js"], + "run_at": "document_end" } ], + "web_accessible_resources": [ + { + "resources": ["disable-gateway-popup.js"], + "matches": [""] + }, + { + "resources": ["disable-gateway-message.js"], + "matches": [""] + } + + ], "content_security_policy": { "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; connect-src 'self' https://api.qortal.org https://api2.qortal.org https://appnode.qortal.org https://apinode.qortalnodes.live https://apinode1.qortalnodes.live https://apinode2.qortalnodes.live https://apinode3.qortalnodes.live https://apinode4.qortalnodes.live https://ext-node.qortal.link wss://appnode.qortal.org wss://ext-node.qortal.link ws://127.0.0.1:12391 http://127.0.0.1:12391 https://ext-node.qortal.link; " }