diff --git a/public/content-script.js b/public/content-script.js index bd5622f..51fecbf 100644 --- a/public/content-script.js +++ b/public/content-script.js @@ -678,7 +678,6 @@ async function retrieveFileFromIndexedDB(fileId) { async function deleteQortalFilesFromIndexedDB() { try { - console.log("Opening IndexedDB for deleting files..."); const db = await openIndexedDB(); const transaction = db.transaction(["files"], "readwrite"); const objectStore = transaction.objectStore("files"); @@ -800,7 +799,6 @@ async function storeFilesInIndexedDB(obj) { const UIQortalRequests = ['GET_USER_ACCOUNT', 'DECRYPT_DATA', 'SEND_COIN', 'GET_LIST_ITEMS', 'ADD_LIST_ITEMS', 'DELETE_LIST_ITEM', 'VOTE_ON_POLL', 'CREATE_POLL', 'SEND_CHAT_MESSAGE', 'JOIN_GROUP', 'DEPLOY_AT', 'GET_USER_WALLET', 'GET_WALLET_BALANCE', 'GET_USER_WALLET_INFO', 'GET_CROSSCHAIN_SERVER_INFO', 'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE', 'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER', 'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY'] if (!window.hasAddedQortalListener) { - console.log("Listener added"); window.hasAddedQortalListener = true; //qortalRequests const listener = async (event) => { @@ -887,4 +885,25 @@ if (!window.hasAddedQortalListener) { } +window.addEventListener("message", (event) => { + // Ensure the message is from the same page + if (event.source !== window || !event.data || event.data.type !== "qortalExtensionRequests") return; + + // Extract the message detail + const { detail } = event.data; + + // Forward the message to the background script and listen for a response + + chrome?.runtime?.sendMessage({ action: "version" }, (response) => { + if (response.error) { + console.error("Error:", response.error); + } else { + // Include the requestId in the detail when dispatching the response + window.postMessage( + { type: "qortalExtensionResponses", detail: { requestId: detail.requestId, data: response } }, + "*" + ); + } + }); +}); diff --git a/public/disable-gateway-message.js b/public/disable-gateway-message.js index c395aff..361bc67 100644 --- a/public/disable-gateway-message.js +++ b/public/disable-gateway-message.js @@ -1,26 +1,26 @@ -(function() { - // Immediately disable qdnGatewayShowModal if it exists +// (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 +// // 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 - } +// 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); - }; +// // 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.'); - } +// 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 index 7cf89e4..1e81ed0 100644 --- a/public/disable-gateway-popup.js +++ b/public/disable-gateway-popup.js @@ -1,27 +1,28 @@ -(function() { - console.log('External script loaded to disable qdnGatewayShowModal'); + +// (function() { +// console.log('External script loaded to disable qdnGatewayShowModal'); - const timeoutDuration = 5000; // Set timeout duration to 5 seconds (5000ms) - let elapsedTime = 0; // Track the time that has passed +// const timeoutDuration = 5000; // Set timeout duration to 5 seconds (5000ms) +// let elapsedTime = 0; // Track the time that has passed - // Poll for qdnGatewayShowModal and disable it once it's defined - const checkQdnGatewayInterval = setInterval(() => { - elapsedTime += 100; // Increment elapsed time by the polling interval (100ms) +// // Poll for qdnGatewayShowModal and disable it once it's defined +// const checkQdnGatewayInterval = setInterval(() => { +// elapsedTime += 100; // Increment elapsed time by the polling interval (100ms) - if (typeof window.qdnGatewayShowModal === 'function') { - console.log('Disabling qdnGatewayShowModal'); +// if (typeof window.qdnGatewayShowModal === 'function') { +// console.log('Disabling qdnGatewayShowModal'); - // Disable qdnGatewayShowModal function - window.qdnGatewayShowModal = function(message) { - console.log('qdnGatewayShowModal function has been disabled.'); - }; +// // Disable qdnGatewayShowModal function +// window.qdnGatewayShowModal = function(message) { +// console.log('qdnGatewayShowModal function has been disabled.'); +// }; - // Stop checking once qdnGatewayShowModal has been disabled - clearInterval(checkQdnGatewayInterval); - } else if (elapsedTime >= timeoutDuration) { - console.log('Timeout reached, stopping polling for qdnGatewayShowModal.'); - clearInterval(checkQdnGatewayInterval); // Stop checking after 5 seconds - } - }, 100); // Check every 100ms +// // Stop checking once qdnGatewayShowModal has been disabled +// clearInterval(checkQdnGatewayInterval); +// } else if (elapsedTime >= timeoutDuration) { +// console.log('Timeout reached, stopping polling for qdnGatewayShowModal.'); +// clearInterval(checkQdnGatewayInterval); // Stop checking after 5 seconds +// } +// }, 100); // Check every 100ms -})(); +// })(); diff --git a/public/document_start.js b/public/document_start.js index 19c7adf..b105ed5 100644 --- a/public/document_start.js +++ b/public/document_start.js @@ -1,4 +1,3 @@ - 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 diff --git a/public/manifest.json b/public/manifest.json index 73c4626..82fb3cf 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -18,33 +18,14 @@ ], "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://*:* http://*:* wss://*:* ws://*:*;" }