Skip to content

Commit c719233

Browse files
committed
fix solver
1 parent df23f54 commit c719233

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Old Twitter Layout (2026)",
33
"description": "__MSG_ext_description__",
4-
"version": "1.9.6.6",
4+
"version": "1.9.6.7",
55
"manifest_version": 3,
66
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
77
"background": {

sandbox.html

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,35 @@
4646
return;
4747
}
4848
const id = idMatch[1];
49-
const defaultMatch = challengeData.match(/default:\(\)=>(\w+)\}\)/);
50-
if (!defaultMatch) {
49+
50+
const assignMatch = challengeData.match(/(\w+\s*\.\s*default\s*=\s*)\(\s*\)\s*=>/);
51+
const propMatch = challengeData.match(/default:\(\)=>(\w+)\}\)/);
52+
if (!assignMatch && !propMatch) {
5153
console.error('Default export not found');
5254
event.source.postMessage({ action: 'initError', error: 'Default export not found' }, event.origin);
5355
initError = true;
5456
return;
5557
}
56-
const defaultVar = defaultMatch[1];
58+
5759
// TO EXTENSION REVIEWERS (mostly Mozilla):
5860
// This script is part of Twitter's security challenge, before mindlessly rejecting extension actually review what code does please! It's in sandbox for a reason.
5961
// It only ever executes code from trusted Twitter domain, abs.twimg.com (specifically their script that generates security headers)
6062
// It's impossible to have it contained in extension itself, since it's generated dynamically
6163
// you can see where script is loaded in scripts/twchallenge.js
6264
// it also can't use any extension APIs, since it's contained in object url iframe
63-
const patchedChallengeData = challengeData.replace(
64-
`default:()=>${defaultVar}`,
65-
`default:(window._CHALLENGE=()=>${defaultVar})`
66-
);
65+
let patchedChallengeData;
66+
if (assignMatch) {
67+
patchedChallengeData = challengeData.replace(
68+
assignMatch[0],
69+
`${assignMatch[1]}window.__CHALLENGE_FN__=()=>`
70+
);
71+
} else {
72+
const defaultVar = propMatch[1];
73+
patchedChallengeData = challengeData.replace(
74+
`default:()=>${defaultVar}`,
75+
`default:(window._CHALLENGE=()=>${defaultVar})`
76+
);
77+
}
6778
eval(patchedChallengeData);
6879

6980
// 1) Collect all module factories that have already been pushed
@@ -109,6 +120,10 @@
109120
};
110121
wreq.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
111122
webpackChunk_twitter_responsive_web[1][1][id](chunks, cache, wreq);
123+
124+
if (window.__CHALLENGE_FN__) {
125+
window._CHALLENGE = () => window.__CHALLENGE_FN__;
126+
}
112127
solver = window._CHALLENGE()();
113128
event.source.postMessage({ action: 'ready' }, event.origin);
114129
} catch (e) {
@@ -154,4 +169,4 @@
154169
</script>
155170
</body>
156171

157-
</html>
172+
</html>

0 commit comments

Comments
 (0)