Skip to content

Commit

Permalink
fixed missing avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Aug 19, 2022
1 parent bc35b34 commit f51b960
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion layouts/home/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
isEnglish = isEnglish.languages[0] && isEnglish.languages[0].percentage > 60 && isEnglish.languages[0].language.startsWith('en');
tweet.innerHTML = /*html*/`
<div class="tweet-top" hidden></div>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img src="${t.user.profile_image_url_https.replace("_normal", "_bigger")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img onerror="this.src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_bigger.png'" src="${t.user.profile_image_url_https.replace("_normal.", "_bigger.")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<div class="tweet-header">
<a class="tweet-header-info" href="https://twitter.com/${t.user.screen_name}">
<b class="tweet-header-name ${t.user.verified || t.user.id_str === '1123203847776763904' ? 'user-verified' : ''} ${t.user.protected ? 'user-protected' : ''}">${escapeHTML(t.user.name)}</b>
Expand Down
2 changes: 1 addition & 1 deletion layouts/notifications/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
isEnglish = isEnglish.languages[0] && isEnglish.languages[0].percentage > 60 && isEnglish.languages[0].language.startsWith('en');
tweet.innerHTML = /*html*/`
<div class="tweet-top" hidden></div>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img src="${t.user.profile_image_url_https.replace("_normal", "_bigger")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img onerror="this.src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_bigger.png'" src="${t.user.profile_image_url_https.replace("_normal.", "_bigger.")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<div class="tweet-header">
<a class="tweet-header-info" href="https://twitter.com/${t.user.screen_name}">
<b class="tweet-header-name ${t.user.verified || t.user.id_str === '1123203847776763904' ? 'user-verified' : ''} ${t.user.protected ? 'user-protected' : ''}">${escapeHTML(t.user.name)}</b>
Expand Down
13 changes: 8 additions & 5 deletions layouts/profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,19 @@ let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'A
let everAddedAdditional = false;
function renderProfile() {
document.getElementById('profile-banner').src = pageUser.profile_banner_url ? pageUser.profile_banner_url : 'https://abs.twimg.com/images/themes/theme1/bg.png';
let attempts = 0;
document.getElementById('profile-avatar').addEventListener('error', () => {
if(attempts > 3) return document.getElementById('profile-avatar').src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png';
attempts++;
setTimeout(() => {
document.getElementById('profile-avatar').src = pageUser.profile_image_url_https.replace('_normal', '_400x400');
document.getElementById('profile-avatar').src = pageUser.profile_image_url_https.replace('_normal.', '_400x400.');
}, 500);
});
document.getElementById('profile-avatar').src = pageUser.profile_image_url_https.replace('_normal', '_400x400');
document.getElementById('nav-profile-avatar').src = pageUser.profile_image_url_https.replace('_normal', '_bigger');
document.getElementById('profile-avatar').src = pageUser.profile_image_url_https.replace('_normal.', '_400x400.');
document.getElementById('nav-profile-avatar').src = pageUser.profile_image_url_https.replace('_normal.', '_bigger.');
document.getElementById('profile-name').innerText = pageUser.name;
document.getElementById('nav-profile-name').innerText = pageUser.name;
document.getElementById('profile-avatar-link').href = pageUser.profile_image_url_https.replace('_normal', '_400x400');;
document.getElementById('profile-avatar-link').href = pageUser.profile_image_url_https.replace('_normal.', '_400x400.');;
document.getElementById('tweet-to').innerText = `Tweet to ${pageUser.name}`;

if(pageUser.verified || pageUser.id_str === '1123203847776763904') {
Expand Down Expand Up @@ -964,7 +967,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
isEnglish = isEnglish.languages[0] && isEnglish.languages[0].percentage > 60 && isEnglish.languages[0].language.startsWith('en');
tweet.innerHTML = /*html*/`
<div class="tweet-top" hidden></div>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img src="${t.user.profile_image_url_https.replace("_normal", "_bigger")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img onerror="this.src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_bigger.png'" src="${t.user.profile_image_url_https.replace("_normal.", "_bigger.")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<div class="tweet-header">
<a class="tweet-header-info" href="https://twitter.com/${t.user.screen_name}">
<b class="tweet-header-name ${t.user.verified || t.user.id_str === '1123203847776763904' ? 'user-verified' : ''} ${t.user.protected ? 'user-protected' : ''}">${escapeHTML(t.user.name)}</b>
Expand Down
2 changes: 1 addition & 1 deletion layouts/search/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
isEnglish = isEnglish.languages[0] && isEnglish.languages[0].percentage > 60 && isEnglish.languages[0].language.startsWith('en');
tweet.innerHTML = /*html*/`
<div class="tweet-top" hidden></div>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img src="${t.user.profile_image_url_https.replace("_normal", "_bigger")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img onerror="this.src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_bigger.png'" src="${t.user.profile_image_url_https.replace("_normal.", "_bigger.")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<div class="tweet-header">
<a class="tweet-header-info" href="https://twitter.com/${t.user.screen_name}">
<b class="tweet-header-name ${t.user.verified || t.user.id_str === '1123203847776763904' ? 'user-verified' : ''} ${t.user.protected ? 'user-protected' : ''}">${escapeHTML(t.user.name)}</b>
Expand Down
2 changes: 1 addition & 1 deletion layouts/tweet/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
isEnglish = isEnglish.languages[0] && isEnglish.languages[0].percentage > 60 && isEnglish.languages[0].language.startsWith('en');
tweet.innerHTML = /*html*/`
<div class="tweet-top" hidden></div>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img src="${t.user.profile_image_url_https.replace("_normal", "_bigger")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<a class="tweet-avatar-link" href="https://twitter.com/${t.user.screen_name}"><img onerror="this.src = 'https://abs.twimg.com/sticky/default_profile_images/default_profile_bigger.png'" src="${t.user.profile_image_url_https.replace("_normal.", "_bigger.")}" alt="${t.user.name}" class="tweet-avatar" width="48" height="48"></a>
<div class="tweet-header ${options.mainTweet ? 'tweet-header-main' : ''}">
<a class="tweet-header-info ${options.mainTweet ? 'tweet-header-info-main' : ''}" href="https://twitter.com/${t.user.screen_name}">
<b class="tweet-header-name ${options.mainTweet ? 'tweet-header-name-main' : ''} ${t.user.verified || t.user.id_str === '1123203847776763904' ? 'user-verified' : ''} ${t.user.protected ? 'user-protected' : ''}">${escapeHTML(t.user.name)}</b>
Expand Down
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 (2022)",
"description": "A new extension that returns old Twitter's look.",
"version": "1.4.4",
"version": "1.4.5",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
1 change: 1 addition & 0 deletions scripts/newtwitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setInterval(() => {
realPath === '/login' ||
realPath === '/register' ||
realPath === '/logout' ||
realPath === '/messages' ||
realPath === '/account/switch' ||
realPath.endsWith('/lists') ||
realPath.endsWith('/topics') ||
Expand Down

0 comments on commit f51b960

Please sign in to comment.