Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added medium URL #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 43 additions & 46 deletions chrome/background.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,68 @@
var app = {};
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}`;
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;
var newRef = app.generateReferrer()
var refExists = false
for (var n in details.requestHeaders) {
refExists = details.requestHeaders[n].name.toLowerCase() == "referer";
refExists = details.requestHeaders[n].name.toLowerCase() == "referer"
if (refExists) {
details.requestHeaders[n].value = newRef;
break;
details.requestHeaders[n].value = newRef
break
}
}
if (!refExists) {
details.requestHeaders.push({ name: "Referer", value: newRef });
details.requestHeaders.push({ name: "Referer", value: newRef })
}
return { requestHeaders: details.requestHeaders };
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/*',
]
"*://*.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/*",
"*://towardsdatascience.com/*",
"*://eand.co/*",
"*://extranewsfeed.com/*",
"*://democracyguardian.com/*",
"*://*.issuevoter.org/*",
],
},
[
'blocking',
'requestHeaders',
'extraHeaders'
]
);
["blocking", "requestHeaders", "extraHeaders"]
)
88 changes: 43 additions & 45 deletions firefox/background.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,68 @@
var app = {};
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}`;
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;
var newRef = app.generateReferrer()
var refExists = false
for (var n in details.requestHeaders) {
refExists = details.requestHeaders[n].name.toLowerCase() == "referer";
refExists = details.requestHeaders[n].name.toLowerCase() == "referer"
if (refExists) {
details.requestHeaders[n].value = newRef;
break;
details.requestHeaders[n].value = newRef
break
}
}
if (!refExists) {
details.requestHeaders.push({ name: "Referer", value: newRef });
details.requestHeaders.push({ name: "Referer", value: newRef })
}
return { requestHeaders: details.requestHeaders };
return { requestHeaders: details.requestHeaders }
}

// Modify network requests
browser.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/*',
]
"*://*.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/*",
"*://towardsdatascience.com/*",
"*://eand.co/*",
"*://extranewsfeed.com/*",
"*://democracyguardian.com/*",
"*://*.issuevoter.org/*",
],
},
[
'blocking',
'requestHeaders'
]
);
["blocking", "requestHeaders"]
)