Skip to content

Commit 8a87b02

Browse files
authored
Merge pull request #862 from shy1132/master
fix #850 + refine firefox client-web-legacy fix
2 parents 5c42d56 + 1d8b812 commit 8a87b02

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

scripts/background_v2.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,21 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
5959
},
6060
["blocking", "requestHeaders"]
6161
);
62-
chrome.webRequest.onBeforeSendHeaders.addListener(
62+
chrome.webRequest.onBeforeSendHeaders.addListener( //this isnt particularly elegant solution
6363
function(details) {
6464
for (let i = 0; i < details.requestHeaders.length; i++) {
6565
if (details.requestHeaders[i].name.toLowerCase() === 'user-agent') {
6666
if (details.requestHeaders[i].value.toLowerCase().includes('firefox')) {
67-
let rvRegex = /rv:(\d+\.\d+)/;
67+
let latest = 128; //if this ever breaks set this to latest firefox version
68+
let rvRegex = /rv:(\d+\.\d+)/; //gecko version (whats important here)
69+
let versionRegex = /Firefox\/(\d+(?:\.\d+)+)/; //browser version
6870
let rvMatch = details.requestHeaders[i].value.match(rvRegex);
69-
if (rvMatch) {
71+
let versionMatch = details.requestHeaders[i].value.match(versionRegex);
72+
if (rvMatch && versionMatch) {
7073
let rv = parseFloat(rvMatch[1]);
71-
if (rv < 110) {
72-
details.requestHeaders[i].value = details.requestHeaders[i].value.replace(rvRegex, 'rv:110.0'); //twitter serves client-web-legacy if rv is less than 110, which breaks request signing
74+
let version = parseFloat(versionMatch[1]);
75+
if (rv < latest || version < latest) { //rv 110 is cutoff point between client-web-legacy and client-web, so we should just spoof browser and rv to latest
76+
details.requestHeaders[i].value = details.requestHeaders[i].value.replace(rvRegex, `rv:${latest}.0`).replace(versionRegex, `Firefox/${latest}.0`);
7377
}
7478
}
7579
}

scripts/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,7 @@ function renderNotification(n, options = {}) {
37643764
document.body.appendChild(a);
37653765
a.click();
37663766
a.remove();
3767-
} else if(n.entry.clientEventInfo.element === "users_followed_you") {
3767+
} else if(n.entry.clientEventInfo.element === "users_followed_you" || n.entry.clientEventInfo.element === "follow_from_recommended_user") {
37683768
let a = document.createElement('a');
37693769
a.href = `/${user.screen_name}/followers`;
37703770
document.body.appendChild(a);

scripts/twchallenge.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ window.addEventListener('message', e => {
6363
solveCallbacks[id].reject('Solver errored during initialization');
6464
delete solveCallbacks[id];
6565
}
66-
alert(`There was an error in initializing security header generator: ${data.error}. OldTwitter doesn't allow unsigned requests anymore for your account security.`);
66+
alert(`There was an error in initializing security header generator:\n${data.error}\nUser Agent: ${navigator.userAgent}\nOldTwitter doesn't allow unsigned requests anymore for your account security.`);
6767
console.error('Error initializing solver:');
6868
console.error(data.error);
6969
} else if(data.action === 'ready') {
@@ -163,9 +163,9 @@ async function initChallenge() {
163163
console.error(`Error during challenge init:`);
164164
console.error(e);
165165
if(location.hostname === 'twitter.com') {
166-
alert(`There was an error in initializing security header generator: ${e}. OldTwitter doesn't allow unsigned requests anymore for your account security. Currently the main reason for this happening is social network tracker protection blocking the script. Try disabling such settings in your browser and extensions that do that and refresh the page. Also using OldTwitter from twitter.com domain is not supported.`);
166+
alert(`There was an error in initializing security header generator: ${e}\nUser Agent: ${navigator.userAgent}\nOldTwitter doesn't allow unsigned requests anymore for your account security. Currently the main reason for this happening is social network tracker protection blocking the script. Try disabling such settings in your browser and extensions that do that and refresh the page. Also using OldTwitter from twitter.com domain is not supported.`);
167167
} else {
168-
alert(`There was an error in initializing security header generator: ${e}. OldTwitter doesn't allow unsigned requests anymore for your account security. Currently the main reason for this happening is social network tracker protection blocking the script. Try disabling such settings in your browser and extensions that do that and refresh the page.`);
168+
alert(`There was an error in initializing security header generator: ${e}\nUser Agent: ${navigator.userAgent}\nOldTwitter doesn't allow unsigned requests anymore for your account security. Currently the main reason for this happening is social network tracker protection blocking the script. Try disabling such settings in your browser and extensions that do that and refresh the page.`);
169169
}
170170
return false;
171171
}

0 commit comments

Comments
 (0)