// The target match pattern
let targetPage = "*://*.google.ca/*";
// Log cookies sent with this request
function logCookies(e) {
for (const header of e.requestHeaders) {
if (header.name === "Cookie") {
console.log(header.value);
}
}
}
// Listen for onSendHeaders, and pass
// "requestHeaders" so we get the headers
browser.webRequest.onSendHeaders.addListener(
logCookies,
{ urls: [targetPage] },
["requestHeaders"],
);webRequest.onSendHeaders / notebook
webRequest.onSendHeaders
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.