-
Notifications
You must be signed in to change notification settings - Fork 5
/
background.js
34 lines (29 loc) · 990 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function removeSafelink(requestDetails) {
var originalURL = getParameterByName('url', requestDetails.url);
console.debug('Blocked a "Microsoft Safe Link" redirect.')
return {
redirectUrl: originalURL
};
}
browser.webRequest.onBeforeRequest.addListener(
removeSafelink,
{
urls: [
"https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html*",
"https://safelinks.protection.outlook.com/*",
"https://*.safelinks.protection.outlook.com/*",
"https://outlook.office.com/mail/safelink.html*",
"https://*.safelinks.protection.office365.us/*",
]
},
['blocking']
);
// Source: https://stackoverflow.com/a/901144
function getParameterByName(name, url) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}