freshroute-server
Version:
Local development server for FreshRoute extension with API mocking and extended functionality
1 lines โข 8.24 kB
HTML
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Header Debug Test</title><style>body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;max-width:800px;margin:20px auto;padding:20px;line-height:1.6}.debug-section{background:#f5f5f5;padding:15px;margin:15px 0;border-radius:5px}.result{background:#e8f5e8;border:1px solid #4caf50;padding:10px;margin:10px 0;border-radius:3px}.error{background:#ffeaea;border:1px solid #f44336}button{background:#2196f3;color:#fff;border:none;padding:10px 20px;border-radius:3px;cursor:pointer;margin:5px}button:hover{background:#1976d2}pre{background:#282c34;color:#abb2bf;padding:15px;border-radius:5px;overflow-x:auto;font-size:12px}</style></head><body><h1>๐ ๏ธ Header Modification Debug Tool</h1><div class="debug-section"><h3>Extension Debug</h3><button onclick="debugHeaderRules()">Debug Header Rules</button> <button onclick="getCurrentRules()">Get Current Rules</button> <button onclick="testRequest()">Test Request</button><div id="debugResult"></div></div><div class="debug-section"><h3>Test Request</h3><input type="url" id="testUrl" placeholder="Enter URL to test" value="https://infinity-share.freshinfinitysquad.com/api/test" style="width:400px;padding:8px"> <button onclick="makeTestRequest()">Make Request</button> <button onclick="testResponseHeaders()">Test Response Headers</button><div id="requestResult"></div></div><div class="debug-section"><h3>Response Header Test</h3><p>Test if response headers are being modified by the extension:</p><button onclick="testSpecificHeaders()">Test Custom Headers</button> <button onclick="testCacheControl()">Test Cache-Control</button> <button onclick="checkExtensionHeaders()">Check Extension Headers</button> <button onclick="showConsoleInstructions()">Show Console Instructions</button><div id="responseHeaderResult"></div></div><div class="debug-section"><h3>Network Monitor</h3><button onclick="startNetworkMonitor()">Start Monitor</button> <button onclick="stopNetworkMonitor()">Stop Monitor</button><div id="networkLog"></div></div><script>let networkMonitor=null;async function debugHeaderRules(){try{displayResult("debugResult",await chrome.runtime.sendMessage({action:"debugHeaders"}))}catch(e){displayError("debugResult","Error debugging headers: "+e.message)}}async function getCurrentRules(){try{displayResult("debugResult",await chrome.runtime.sendMessage({action:"getCurrentRules"}))}catch(e){displayError("debugResult","Error getting rules: "+e.message)}}async function makeTestRequest(){const e=document.getElementById("testUrl").value;if(e)try{const t=await fetch(e,{method:"GET",mode:"cors",credentials:"include"}),s={status:t.status,statusText:t.statusText,headers:{},url:t.url};for(const[e,o]of t.headers.entries())s.headers[e]=o;displayResult("requestResult",s)}catch(e){displayError("requestResult","Request failed: "+e.message)}else displayError("requestResult","Please enter a URL")}async function testResponseHeaders(){const e=document.getElementById("testUrl").value||"https://infinity-share.freshinfinitysquad.com/api/test";try{console.log("๐งช Testing response headers for:",e);const t=await fetch(e,{method:"HEAD",mode:"cors",credentials:"include"}),s={},o={};for(const[e,n]of t.headers.entries())s[e]=n,(e.toLowerCase().startsWith("x-extension")||e.toLowerCase().startsWith("x-debug")||"cache-control"===e.toLowerCase())&&(o[e]=n);displayResult("responseHeaderResult",{url:t.url,status:t.status,allHeaders:s,extensionModifiedHeaders:o,headerCount:Object.keys(s).length,extensionHeaderCount:Object.keys(o).length})}catch(e){displayError("responseHeaderResult","Response header test failed: "+e.message)}}async function testSpecificHeaders(){const e=["https://infinity-share.freshinfinitysquad.com/api/test","https://infinity-share.freshinfinitysquad.com/support/v1/test",window.location.href],t=[];for(const s of e)try{const e=await fetch(s,{method:"HEAD",mode:"cors"}),o={};for(const[t,s]of e.headers.entries())(t.toLowerCase().includes("extension")||t.toLowerCase().includes("debug")||"cache-control"===t.toLowerCase())&&(o[t]=s);t.push({url:s,status:e.status,extensionHeaders:o,hasExtensionHeaders:Object.keys(o).length>0})}catch(e){t.push({url:s,error:e.message,hasExtensionHeaders:!1})}displayResult("responseHeaderResult",{testResults:t})}async function testCacheControl(){const e=document.getElementById("testUrl").value||window.location.href;try{const t=await fetch(e,{method:"HEAD"}),s=t.headers.get("Cache-Control"),o={url:t.url,cacheControl:s,isModified:"no-cache, no-store, must-revalidate"===s,allCacheHeaders:{}};for(const[e,s]of t.headers.entries())(e.toLowerCase().includes("cache")||e.toLowerCase().includes("etag")||e.toLowerCase().includes("expires"))&&(o.allCacheHeaders[e]=s);displayResult("responseHeaderResult",o)}catch(e){displayError("responseHeaderResult","Cache-Control test failed: "+e.message)}}async function checkExtensionHeaders(){if("function"==typeof window.debugExtensionHeaders){console.log("๐ Running extension header debug...");displayResult("responseHeaderResult",{message:"Extension debug function executed - check console for detailed output",contentScriptActive:!0,debugResult:await window.debugExtensionHeaders()})}else if("function"==typeof window.testExtensionHeaders){console.log("๐ Running extension header test...");displayResult("responseHeaderResult",{message:"Extension test function executed",contentScriptActive:!0,testResult:await window.testExtensionHeaders()})}else{displayResult("responseHeaderResult",{message:"Content script debug functions not found",contentScriptActive:null!==document.querySelector('style[id="url-rewriter-styles"]'),suggestion:"Content script may not be loaded yet. Try reloading the page.",troubleshooting:["Check if extension is enabled","Verify content script is loaded (look for console message)","Check if CSP is blocking script injection","Try manual testing in console: debugExtensionHeaders()"]})}}function showConsoleInstructions(){console.log("๐ ๏ธ Manual Header Testing Instructions:"),console.log(""),console.log("1. Run these commands in the console:"),console.log(" debugExtensionHeaders() // Detailed analysis"),console.log(" testExtensionHeaders() // Quick test"),console.log(' testExtensionHeaders("https://your-domain.com/api/test") // Test specific URL'),console.log(""),console.log("2. Check Network tab in DevTools for:"),console.log(" - X-Extension-Modified header"),console.log(" - X-Debug-Info header"),console.log(" - Modified Cache-Control header"),console.log(""),console.log("3. If functions are not available:"),console.log(" - Reload the page"),console.log(" - Check if extension is enabled"),console.log(' - Look for "๐ URL Rewriter Content Script loaded" in console'),displayResult("responseHeaderResult",{message:"Console testing instructions logged - check console",instructions:"Manual testing commands available in console"})}function testRequest(){const e=["https://infinity-share.freshinfinitysquad.com/api/test","https://infinity-share.freshinfinitysquad.com/support/v1/test","http://localhost.freshservice-dev.com:3000/api/test"];console.log("๐งช Testing URLs that should trigger header modification:"),e.forEach((e=>{console.log(`Testing: ${e}`),fetch(e,{mode:"no-cors"}).catch((t=>{console.log(`Expected CORS error for ${e}:`,t.message)}))})),displayResult("debugResult",{message:"Test requests sent (check console and network tab)",testedUrls:e})}function startNetworkMonitor(){console.log("๐ Network monitoring started - check DevTools Network tab"),displayResult("networkLog",{message:"Network monitoring started - check DevTools Network tab"})}function stopNetworkMonitor(){console.log("๐ Network monitoring stopped"),displayResult("networkLog",{message:"Network monitoring stopped"})}function displayResult(e,t){document.getElementById(e).innerHTML='<div class="result"><pre>'+JSON.stringify(t,null,2)+"</pre></div>"}function displayError(e,t){document.getElementById(e).innerHTML='<div class="result error">'+t+"</div>"}document.addEventListener("DOMContentLoaded",(()=>{setTimeout(debugHeaderRules,1e3)}))</script></body></html>