Skip to content

Commit

Permalink
Merge pull request #869 from not-nullptr/master
Browse files Browse the repository at this point in the history
feat: improve "this user does not exist" page
  • Loading branch information
dimdenGD authored Jul 12, 2024
2 parents 68469f7 + 3636f12 commit e0f7475
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@
"block_sure_desc": { "message": "They will not be able to follow you or view your Tweets, and you will not see Tweets or notifications from @$SCREEN_NAME$.", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } },
"blocked_by_user" : { "message": "@$SCREEN_NAME$ blocked you", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } },
"why_you_cant_see_block_user": { "message": "You can't follow or see @$SCREEN_NAME$'s Tweets.", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } },
"nonexistent_user": { "message": "This account doesn't exist" },
"nonexistent_user_desc": { "message": "Try searching for another." },
"you_blocked_user": { "message": "You blocked @$SCREEN_NAME$", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } },
"do_you_want_see_blocked_user": { "message": "Are you sure you want to view these Tweets? Viewing Tweets won't unblock @$SCREEN_NAME$.", "placeholders": { "screen_name": { "content": "CoolPerson2000" } } },
"I_want_see_blocked_user": { "message": "Yes, view profile" },
Expand Down
2 changes: 1 addition & 1 deletion layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3007,7 +3007,7 @@ setInterval(() => {
userDataFunction(u);
});
}
}, 1750);
}, 0); // fixes a bug where user info doesn't load on the profile page occasionally
setTimeout(() => {
let version = document.getElementById('oldtwitter-version');
let version2 = document.getElementById('oldtwitter-version-left');
Expand Down
23 changes: 18 additions & 5 deletions layouts/profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,17 @@ function updateUserData() {
API.user.get(user_handle, false),
API.account.verifyCredentials()
]).catch(e => {
if(String(e).includes("reading 'result'")) {
document.getElementById('loading-box').hidden = true;
document.getElementById('profile-name').innerText = `@${user_handle}`;
document.getElementById('timeline').innerHTML = html`<div class="unable_load_timeline" dir="auto" style="padding: 50px;color: var(--darker-gray); font-size: 20px;"><h2>${LOC.nonexistent_user.message}</h2><p style="font-size: 15px;" href="/${pageUser.screen_name}">${LOC.nonexistent_user_desc.message.replaceAll("$SCREEN_NAME$",pageUser.screen_name)}</p></div>`;
document.getElementById('profile-avatar').src = 'moz-extension://9605be5b-b11d-4459-879e-2b65fd1d7bca/images/default_profile_images/default_profile_0_400x400.png';
return;
}
document.getElementById('loading-box').hidden = false;
if(String(e).includes('User has been suspended.')) {
return document.getElementById('loading-box-error').innerHTML = html`${LOC.user_was_suspended.message}<br><a href="/home">${LOC.go_homepage.message}</a>`;
}
if(String(e).includes("reading 'result'")) {
return document.getElementById('loading-box-error').innerHTML = html`${LOC.user_was_not_found.message}<br><a href="/home">${LOC.go_homepage.message}</a>`;
}
return document.getElementById('loading-box-error').innerHTML = html`${String(e)}.<br><a href="/home">${LOC.go_homepage.message}</a>`;
});
if(oldUser.reason) {
Expand All @@ -214,10 +218,19 @@ function updateUserData() {
}
if(pageUserData.reason) {
let e = pageUserData.reason;
document.getElementById('loading-box').hidden = false;
if(String(e).includes("reading 'result'")) {
return document.getElementById('loading-box-error').innerHTML = html`${LOC.user_was_not_found.message}<br><a href="/home">${LOC.go_homepage.message}</a>`;
document.getElementById('loading-box').hidden = true;
document.getElementById('profile-name').innerText = `@${user_handle}`;
document.getElementById('timeline').innerHTML = html`<div class="unable_load_timeline" dir="auto" style="padding: 50px;color: var(--darker-gray); font-size: 20px;"><h2>${LOC.nonexistent_user.message}</h2><p style="font-size: 15px;" href="/${pageUser.screen_name}">${LOC.nonexistent_user_desc.message.replaceAll("$SCREEN_NAME$",pageUser.screen_name)}</p></div>`;
document.getElementById('trends').hidden = true;
document.getElementById('profile-nav-center-cell').style.display = 'none'; // ???
document.getElementById('profile-banner-sticky').style.backgroundColor = 'var(--background-color)';
document.getElementById('wtf').hidden = true;
document.getElementById('profile-nav').style.boxShadow = 'none';
document.getElementById('profile-avatar').src = chrome.runtime.getURL(`images/default_profile_images/default_profile_0_normal.png`);
return;
}
document.getElementById('loading-box').hidden = false;
return document.getElementById('loading-box-error').innerHTML = html`${String(e)}.<br><a href="/home">${LOC.go_homepage.message}</a>`;
}
followersYouFollowData = followersYouFollowData.value;
Expand Down

0 comments on commit e0f7475

Please sign in to comment.