Skip to content

Commit

Permalink
maybe fix firefox esr
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Dec 7, 2024
1 parent 178c716 commit 1b0aaf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Old Twitter Layout (2024)",
"description": "__MSG_ext_description__",
"version": "1.8.9.6",
"version": "1.8.9.7",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
11 changes: 8 additions & 3 deletions scripts/twchallenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ fetch = async function(url, options) {
options.headers['X-Client-UUID'] = OLDTWITTER_CONFIG.deviceId;
}
if(!url.startsWith('http:') && !url.startsWith('https:')) {
url = `https://${location.host}${url}`;
let host = location.hostname;
if(!['x.com', 'twitter.com'].includes(host)) host = 'x.com';
if(!url.startsWith('/')) url = '/' + url;
url = `https://${host}${url}`;
}
let parsedUrl = new URL(url);
// try {
Expand All @@ -134,12 +137,14 @@ async function initChallenge() {
try {
let homepageData;
let sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
let host = location.hostname;
if(!['x.com', 'twitter.com'].includes(host)) host = 'x.com';
try {
homepageData = await _fetch(`https://${location.hostname}/`).then(res => res.text());
homepageData = await _fetch(`https://${host}/`).then(res => res.text());
} catch(e) {
await sleep(500);
try {
homepageData = await _fetch(`https://${location.hostname}/`).then(res => res.text());
homepageData = await _fetch(`https://${host}/`).then(res => res.text());
} catch(e) {
throw new Error('Failed to fetch homepage: ' + e);
}
Expand Down

0 comments on commit 1b0aaf9

Please sign in to comment.