1 support issue
For additional help, check out the developer's support site.
- All
- Questions
- Suggestions
- Problems
Jahid Hasan
Sep 2, 2023
Please sir Fix background.js File Code
chrome.runtime.onMessage.addListener(function(message, sender, response) {
if (message.ipfsURL) {
const queryParam = sender.tab.url.split("?")[1];
const urlParams = new URLSearchParams(queryParam);
const ipfsValue = urlParams.get("q");
// Array of gateway URLs to choose from
const gatewayOptions = [
"https://ipfs.io/ipfs/",
"https://dweb.link/ipfs/"
];
// Randomly select a gateway URL from the array
const randomGateway = gatewayOptions[Math.floor(Math.random() * gatewayOptions.length)];
const ipfsCID = ipfsValue.slice(7);
const redirectURL = randomGateway + ipfsCID;
// redirect
chrome.tabs.update(sender.tab.id, {url: redirectURL})
// debug
console.log("IPFS native URL detected via google search.");
console.log("IPFS Native URL: " + ipfsValue);
console.log("IPFS CID: " + ipfsCID);
console.log("Redirect URL: " + sender.tab.url);
}
});
- Report illegal content
- Copy link