|
3 | 3 | * parameter. We'll search the query string portion of the URL for this
|
4 | 4 | * pattern to determine if there's any stripping work to do.
|
5 | 5 | */
|
6 |
| -var searchPattern = new RegExp('utm_|clid|_hs|icid|igshid|mc_|mkt_tok|yclid|_openstat|wicked', 'i'); |
| 6 | +const searchPattern = new RegExp('utm_|clid|_hs|icid|igshid|mc_|mkt_tok|yclid|_openstat|wicked|otc|oly_', 'i'); |
7 | 7 |
|
8 | 8 | /*
|
9 | 9 | * Pattern matching the query string parameters (key=value) that will be
|
10 | 10 | * stripped from the final URL.
|
11 | 11 | */
|
12 |
| -var replacePattern = new RegExp( |
| 12 | +const replacePattern = new RegExp( |
13 | 13 | '([?&]' +
|
14 |
| - '(icid|mkt_tok|(g|fb)clid|igshid|_hs(enc|mi)|mc_[ce]id|utm_(source|medium|term|campaign|content|cid|reader|referrer|name|social|social-type)|yclid|_openstat|wickedid)' + |
| 14 | + '(icid|mkt_tok|(g|fb)clid|igshid|_hs(enc|mi)|mc_[ce]id|utm_(source|medium|term|campaign|content|cid|reader|referrer|name|social|social-type)|yclid|_openstat|wickedid|otc|oly_(anon|enc)_id)' + |
15 | 15 | '=[^&#]*)',
|
16 | 16 | 'ig');
|
17 | 17 |
|
18 |
| -chrome.webRequest.onBeforeRequest.addListener(function(details) { |
19 |
| - var url = details.url; |
20 |
| - var queryStringIndex = url.indexOf('?'); |
| 18 | +chrome.webRequest.onBeforeRequest.addListener((details) => { |
| 19 | + const url = details.url; |
| 20 | + const queryStringIndex = url.indexOf('?'); |
21 | 21 | if (url.search(searchPattern) > queryStringIndex) {
|
22 |
| - var stripped = url.replace(replacePattern, ''); |
| 22 | + let stripped = url.replace(replacePattern, ''); |
23 | 23 | if (stripped.charAt(queryStringIndex) === '&') {
|
24 |
| - stripped = stripped.substr(0, queryStringIndex) + '?' + |
25 |
| - stripped.substr(queryStringIndex + 1) |
| 24 | + stripped = `${stripped.substr(0, queryStringIndex)}?${stripped.substr(queryStringIndex + 1)}`; |
26 | 25 | }
|
27 | 26 | if (stripped != url) {
|
28 | 27 | return {redirectUrl: stripped};
|
|
0 commit comments