// background.js // Function to block specific requests function blockRequest(details) { // Check if the request URL matches the file you want to block if (details.url.includes("title_manager.js")) { console.log("Blocking request for:", details.url); return { cancel: true }; // Cancel the request } } // Check if the browser is Firefox or Chrome const isFirefox = typeof browser !== "undefined"; // background.js // Listen for web requests chrome.webRequest.onBeforeRequest.addListener( function(details) { // Check if the URL matches the pattern const urlPattern = /^miip:\/\/CID\/.*\.bmp\?width=48&height=48&bgR=\d{1,3}&bgG=\d{1,3}&bgB=\d{1,3}$/; if (urlPattern.test(details.url)) { // Redirect to the image stored in the extension return { redirectUrl: chrome.runtime.getURL("images/mii.bmp") }; } }, { urls: [ "https://oss-auth.blinklab.com/*", "https://oss-auth.thecheese.io/*", "https://oss-auth.shop.wii.com/*", "http://wiimart:8080/oss/serv/*", "https://wiimart:8080/oss/serv/*" ]}, // You can restrict this to specific URLs if needed ["blocking"] ); let logs = []; chrome.webRequest.onBeforeRequest.addListener( (details) => { const url = new URL(details.url); if (url.pathname === '/_extension_storage') { const params = new URLSearchParams(url.search); // GET Requests if (params.has('get')) { const key = params.get('get'); return new Promise(resolve => { chrome.storage.local.get(key, result => { if (key === 'logs') { resolve({ redirectUrl: `data:application/json,${JSON.stringify({ value: logs })}` }); } else { resolve({ redirectUrl: `data:application/json,${JSON.stringify({ value: result[key] })}` }); } }); }); } // SET Requests if (params.has('set_key')) { const key = params.get('set_key'); const value = params.get('set_value'); if (key === 'slogs') { logs.push(`[SET] ${new Date().toISOString()}: ${value}`); chrome.storage.local.set({ logs }); } else { chrome.storage.local.set({ [key]: value }); } return { cancel: true }; } // CLEAR Logs if (params.has('clogs')) { logs = []; chrome.storage.local.set({ logs: [] }); return { cancel: true }; } } }, { urls: ["*://*/_extension_storage*"] }, ["blocking"] );