-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
19 lines (15 loc) · 858 Bytes
/
background.js
File metadata and controls
19 lines (15 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// User agent string to send. Keep updated with the latest chrome user agent
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36';
// The user agent only needs to be spoofed for the checkpoint page
const urls = ['https://www.facebook.com/checkpoint/*'];
const options = ['blocking', 'requestHeaders'];
// Listener that replaces the user agent
function setUserAgentOnLogin(e) {
const userAgentHeader = e.requestHeaders.find((header) => header.name.toLowerCase() === 'user-agent');
userAgentHeader.value = userAgent;
console.debug('Updated user agent');
return { requestHeaders: e.requestHeaders };
}
// Set up the listener
const onBeforeSendHeaders = browser.webRequest.onBeforeSendHeaders;
onBeforeSendHeaders.addListener(setUserAgentOnLogin, { urls }, options);