allow ext to work with gateways

This commit is contained in:
PhilReact 2024-10-16 19:57:19 +03:00
parent ca00025c86
commit f1e2192096
5 changed files with 83 additions and 0 deletions

View File

@ -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.');
}
})();

View File

@ -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
})();

7
public/document_end.js Normal file
View File

@ -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
};

7
public/document_start.js Normal file
View File

@ -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
};

View File

@ -18,11 +18,33 @@
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["document_start.js"],
"run_at": "document_start"
},
{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
},
{
"matches": ["<all_urls>"],
"js": ["document_end.js"],
"run_at": "document_end"
}
],
"web_accessible_resources": [
{
"resources": ["disable-gateway-popup.js"],
"matches": ["<all_urls>"]
},
{
"resources": ["disable-gateway-message.js"],
"matches": ["<all_urls>"]
}
],
"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; "
}