${req.url}// @name Network Interceptor // @description Intercept and inspect XHR and Fetch network requests on any webpage // @image https://raw.githubusercontent.com/H1D/network-interceptor-bookmarklet/main/usage_landscape_optimized.gif // @video https://raw.githubusercontent.com/H1D/network-interceptor-bookmarklet/main/usage.mp4 (function() { if (window.xhrInterceptorActive) { alert('XHR Interceptor is already active!'); return; } window.xhrInterceptorActive = true; const style = document.createElement('style'); style.textContent = ` #xhr-interceptor-overlay { position: fixed; top: 10px; right: 10px; width: 600px; max-height: 90vh; background: rgba(0, 0, 0, 0.95); color: #fff; font-family: monospace; font-size: 12px; z-index: 2147483647; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; } #xhr-interceptor-header { padding: 15px; background: #1a1a1a; border-bottom: 2px solid #333; display: flex; justify-content: space-between; align-items: center; cursor: move; } #xhr-interceptor-header h3 { margin: 0; font-size: 16px; color: #4CAF50; } #xhr-interceptor-controls { display: flex; gap: 10px; } #xhr-interceptor-controls button { background: #333; color: #fff; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 11px; } #xhr-interceptor-controls button:hover { background: #555; } #xhr-interceptor-content { overflow-y: auto; padding: 10px; flex: 1; } .xhr-request { background: #1a1a1a; margin: 10px 0; padding: 12px; border-radius: 6px; border-left: 4px solid #4CAF50; cursor: pointer; transition: background 0.2s; } .xhr-request:hover { background: #252525; } .xhr-request-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .xhr-method { padding: 2px 8px; border-radius: 3px; font-weight: bold; font-size: 11px; } .xhr-method.GET { background: #2196F3; color: #fff; } .xhr-method.POST { background: #4CAF50; color: #fff; } .xhr-method.PUT { background: #FF9800; color: #fff; } .xhr-method.DELETE { background: #f44336; color: #fff; } .xhr-method.PATCH { background: #9C27B0; color: #fff; } .xhr-url { color: #64B5F6; flex: 1; margin: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; } .xhr-status { padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: bold; } .xhr-status.success { background: #4CAF50; color: #fff; } .xhr-status.error { background: #f44336; color: #fff; } .xhr-status.pending { background: #FF9800; color: #fff; } .xhr-timing { color: #999; font-size: 10px; } .xhr-details { margin-top: 10px; padding-top: 10px; border-top: 1px solid #333; display: none; } .xhr-details.expanded { display: block; } .xhr-section { margin: 10px 0; } .xhr-section-title { color: #4CAF50; font-weight: bold; margin-bottom: 5px; font-size: 11px; } .xhr-section-content { background: #0a0a0a; padding: 8px; border-radius: 4px; overflow-x: auto; max-height: 200px; overflow-y: auto; font-size: 10px; line-height: 1.4; } .xhr-section-content pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; } `; document.head.appendChild(style); const overlay = document.createElement('div'); overlay.id = 'xhr-interceptor-overlay'; overlay.innerHTML = `
${req.url}${JSON.stringify(req.requestHeaders, null, 2)}${typeof req.payload === 'string' ? req.payload : JSON.stringify(req.payload, null, 2)}${req.responseHeaders}${typeof req.response === 'string' ? req.response.substring(0, 5000) : JSON.stringify(req.response, null, 2).substring(0, 5000)}${(typeof req.response === 'string' ? req.response.length : JSON.stringify(req.response).length) > 5000 ? ' ... (truncated)' : ''}