-
Notifications
You must be signed in to change notification settings - Fork 74
/
background.js
71 lines (68 loc) · 1.97 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var app = {};
// Looks like the specific Referrer header value: https://t.co/JV5396gd2O is blocked
// In order to bypass this, generate "random" header values
// Pick a random number between 1 and 2
// Convert to Base 36 (so it should be alphanumeric)
// Get first 10 characters after decimal
app.generateReferrer = function () {
var linkId = (1 + Math.random()).toString(36).substring(2, 12);
return `https://t.co/${linkId}`;
}
// Modify the referer to twitter
app.modifyHeaders = function (details) {
var newRef = app.generateReferrer();
var refExists = false;
for (var n in details.requestHeaders) {
refExists = details.requestHeaders[n].name.toLowerCase() == "referer";
if (refExists) {
details.requestHeaders[n].value = newRef;
break;
}
}
if (!refExists) {
details.requestHeaders.push({ name: "Referer", value: newRef });
}
return { requestHeaders: details.requestHeaders };
}
// Modify network requests
chrome.webRequest.onBeforeSendHeaders.addListener(
app.modifyHeaders,
{
urls: [
'*://*.medium.com/*',
'*://writingcooperative.com/*',
'*://psiloveyou.xyz/*',
'*://uxplanet.org/*',
'*://towardsdatascience.com/*',
'*://codeburst.io/*',
'*://*.gitconnected.com/*',
'*://itnext.io/*',
'*://entrepreneurshandbook.co/*',
'*://arcdigital.media/*',
'*://femsplain.com/*',
'*://fityourself.club/*',
'*://byrslf.co/*',
'*://blog.qz.com/*',
'*://bullshit.ist/*',
'*://*.pramp.com/*',
'*://uxdesign.cc/*',
'*://medium.muz.li/*',
'*://*.usejournal.com/*',
'*://timeline.com/*',
'*://substance.media/*',
'*://thebolditalic.com/*',
'*://thecreative.cafe/*',
'*://ceoplaybook.io/*',
'*://dayoneperspective.com/*',
'*://eand.co/*',
'*://extranewsfeed.com/*',
'*://democracyguardian.com/*',
'*://*.issuevoter.org/*',
]
},
[
'blocking',
'requestHeaders',
'extraHeaders'
]
);