Project

General

Profile

« Previous | Next » 

Revision 3303d7d7

Added by koszko about 2 years ago

filter HTTP request headers to remove Hachette cookies in case they slip through

View differences:

background/main.js
17 17
 * IMPORT gen_nonce
18 18
 * IMPORT inject_csp_headers
19 19
 * IMPORT apply_stream_filter
20
 * IMPORT filter_cookie_headers
20 21
 * IMPORT is_chrome
21 22
 * IMPORTS_END
22 23
 */
......
81 82
    return {responseHeaders: headers};
82 83
}
83 84

  
85
function on_before_send_headers(details)
86
{
87
    let headers = details.requestHeaders;
88
    headers = filter_cookie_headers(headers);
89
    return {requestHeaders: headers};
90
}
91

  
92
const all_types = [
93
    "main_frame", "sub_frame", "stylesheet", "script", "image", "font",
94
    "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket",
95
    "other", "main_frame", "sub_frame"
96
];
97

  
84 98
async function start_webRequest_operations()
85 99
{
86 100
    storage = await get_storage();
87 101

  
88
    const extra_opts = ["blocking", "responseHeaders"];
102
    const extra_opts = ["blocking"];
89 103
    if (is_chrome)
90 104
	extra_opts.push("extraHeaders");
91 105

  
92 106
    browser.webRequest.onHeadersReceived.addListener(
93 107
	on_headers_received,
94 108
	{urls: ["<all_urls>"], types: ["main_frame", "sub_frame"]},
95
	extra_opts
109
	extra_opts.concat("responseHeaders")
110
    );
111

  
112
    browser.webRequest.onBeforeSendHeaders.addListener(
113
	on_before_send_headers,
114
	{urls: ["<all_urls>"], types: all_types},
115
	extra_opts.concat("requestHeaders")
96 116
    );
97 117
}
98 118

  

Also available in: Unified diff