Skip to content

Commit

Permalink
add boring indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Aug 28, 2024
1 parent 814ebc0 commit dfce4e3
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 13 deletions.
3 changes: 2 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,5 +644,6 @@
"nonexistent_user": { "message": "This account doesn't exist" },
"nonexistent_user_desc": { "message": "Try searching for another." },
"suspended_user": { "message": "Account suspended" },
"suspended_user_desc": { "message": "The profile you are trying to view has been suspended." }
"suspended_user_desc": { "message": "The profile you are trying to view has been suspended." },
"show_boring_indicators": { "message": "Show indicator in followers/following page if last tweet of person is a retweet/quote/non-existent" }
}
23 changes: 23 additions & 0 deletions layouts/header/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,29 @@ emoji-picker {
font-weight: 100;
}

.user-indicator-no-status::after {
content: "\f045";
color: #dd2b2b;
font-family: var(--icon-font);
margin-left: 5px;
font-weight: 100;
}

.user-indicator-retweeted::after {
content: "\f152";
color: #5c913b;
font-family: var(--icon-font);
margin-left: 5px;
font-weight: 100;
}

.user-indicator-quoted::after {
content: "\f157";
color: #4a9fc7;
font-family: var(--icon-font);
margin-left: 5px;
font-weight: 100;
}

.tweet-media-video-overlay {
position: absolute;
Expand Down
24 changes: 22 additions & 2 deletions layouts/profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,17 @@ async function renderFollowing(clear = true, cursor) {
if(vars.showUserFollowerCountsInLists) {
label = `${formatLargeNumber(u.followers_count)} ${vars.modernUI ? LOC.followers.message : LOC.followers.message.toLowerCase()}`;
}
appendUser(u, userList, label);
let usernameClass = '';
if(!u.status) {
usernameClass = 'user-indicator-no-status';
} else if(u.status) {
if(u.status.retweeted_status) {
usernameClass = 'user-indicator-retweeted';
} else if(u.status.quoted_status_id_str) {
usernameClass = 'user-indicator-quoted';
}
}
appendUser(u, userList, label, usernameClass);
});
document.getElementById('loading-box').hidden = true;
loadingFollowing = false;
Expand Down Expand Up @@ -1003,7 +1013,17 @@ async function renderFollowers(clear = true, cursor) {
if(vars.showUserFollowerCountsInLists) {
label = `${formatLargeNumber(u.followers_count)} ${vars.modernUI ? LOC.followers.message : LOC.followers.message.toLowerCase()}`;
}
appendUser(u, userList, label);
let usernameClass = '';
if(!u.status) {
usernameClass = 'user-indicator-no-status';
} else if(u.status) {
if(u.status.retweeted_status) {
usernameClass = 'user-indicator-retweeted';
} else if(u.status.quoted_status_id_str) {
usernameClass = 'user-indicator-quoted';
}
}
appendUser(u, userList, label, usernameClass);
});
document.getElementById('loading-box').hidden = true;
loadingFollowers = false;
Expand Down
3 changes: 3 additions & 0 deletions layouts/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ <h2>__MSG_mobile__</h2><br>
</div>
</div>
<h2>__MSG_advanced_options__</h2><br>
<div class="setting">
<input type="checkbox" id="show-boring-indicators"> <label for="show-boring-indicators">__MSG_show_boring_indicators__</label>
</div>
<div class="setting">
<input type="checkbox" id="update-timeline-automatically"> <label for="update-timeline-automatically">__MSG_update_timeline_automatically__</label>
</div>
Expand Down
8 changes: 8 additions & 0 deletions layouts/settings/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ setTimeout(async () => {
let showUserFollowerCountsInLists = document.getElementById('show-user-follower-counts-in-lists');
let hideUnfollowersPage = document.getElementById('hide-unfollowers-page');
let transitionProfileBanner = document.getElementById('transition-profile-banner');
let showBoringIndicators = document.getElementById('show-boring-indicators');

let root = document.querySelector(":root");
{
Expand Down Expand Up @@ -733,6 +734,12 @@ setTimeout(async () => {
renderTrends(false, false);
});
});
showBoringIndicators.addEventListener('change', () => {
vars.showBoringIndicators = showBoringIndicators.checked;
chrome.storage.sync.set({
showBoringIndicators: showBoringIndicators.checked
}, () => { });
});
hideTrends.addEventListener('change', () => {
vars.hideTrends = hideTrends.checked;
hideStuff();
Expand Down Expand Up @@ -1059,6 +1066,7 @@ setTimeout(async () => {
showQuoteCount.checked = !!vars.showQuoteCount;
hideUnfollowersPage.checked = !!vars.hideUnfollowersPage;
transitionProfileBanner.checked = !!vars.transitionProfileBanner;
showBoringIndicators.checked = !!vars.showBoringIndicators;
if(vars.customCSS) {
writeCSSToDB(vars.customCSS)
}
Expand Down
1 change: 0 additions & 1 deletion sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
return;
}
let data = event.data;
console.log('iframe message', data);
if (data.action === 'init') {
try {
let animsDiv = document.getElementById('anims');
Expand Down
56 changes: 51 additions & 5 deletions scripts/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,52 @@ const API = {
});
},
getFollowing: (id, cursor) => {
return new Promise((resolve, reject) => {
fetch(`https://${location.hostname}/i/api/1.1/friends/list.json?user_id=${id}&count=100${cursor ? `&cursor=${cursor}` : ""}`, {
headers: {
"authorization": OLDTWITTER_CONFIG.oauth_key,
"x-csrf-token": OLDTWITTER_CONFIG.csrf,
"x-twitter-auth-type": "OAuth2Session",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
credentials: "include"
}).then(i => i.json()).then(data => {
if (data.errors && data.errors[0]) {
return reject(data.errors[0].message);
}
resolve({
list: data.users,
cursor: data.next_cursor_str !== "0" ? data.next_cursor_str : null
});
}).catch(e => {
reject(e);
});
});
},
getFollowers: (id, cursor, count = 100) => {
return new Promise((resolve, reject) => {
fetch(`https://${location.hostname}/i/api/1.1/followers/list.json?user_id=${id}&count=${count}${cursor ? `&cursor=${cursor}` : ""}`, {
headers: {
"authorization": OLDTWITTER_CONFIG.oauth_key,
"x-csrf-token": OLDTWITTER_CONFIG.csrf,
"x-twitter-auth-type": "OAuth2Session",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
credentials: "include"
}).then(i => i.json()).then(data => {
if (data.errors && data.errors[0]) {
return reject(data.errors[0].message);
}
resolve({
list: data.users,
cursor: data.next_cursor_str !== "0" ? data.next_cursor_str : null
});
}).catch(e => {
reject(e);
});
});
},
getFollowingV2: (id, cursor) => {
return new Promise((resolve, reject) => {
let obj = {
"userId": id,
Expand All @@ -2185,7 +2231,7 @@ const API = {
},
credentials: "include"
}).then(i => i.json()).then(data => {
debugLog('user.getFollowing', 'start', {id, cursor, data});
debugLog('user.getFollowingV2', 'start', {id, cursor, data});
if (data.errors && data.errors[0].code === 32) {
return reject("Not logged in");
}
Expand All @@ -2206,14 +2252,14 @@ const API = {
}).filter(e => e),
cursor: list.find(e => e.entryId.startsWith('cursor-bottom-')).content.value
}
debugLog('user.getFollowing', 'end', out);
debugLog('user.getFollowingV2', 'end', out);
resolve(out);
}).catch(e => {
reject(e);
});
});
},
getFollowers: (id, cursor, count = 100) => {
getFollowersV2: (id, cursor, count = 100) => {
return new Promise((resolve, reject) => {
let obj = {
"userId": id,
Expand Down Expand Up @@ -2247,7 +2293,7 @@ const API = {
},
credentials: "include"
}).then(i => i.json()).then(data => {
debugLog('user.getFollowers', 'start', {id, cursor, data});
debugLog('user.getFollowersV2', 'start', {id, cursor, data});
if (data.errors && data.errors[0].code === 32) {
return reject("Not logged in");
}
Expand All @@ -2267,7 +2313,7 @@ const API = {
}),
cursor: list.find(e => e.entryId.startsWith('cursor-bottom-')).content.value
};
debugLog('user.getFollowers', 'end', out);
debugLog('user.getFollowersV2', 'end', out);
resolve(out);
}).catch(e => {
reject(e);
Expand Down
3 changes: 2 additions & 1 deletion scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ async function loadVars() {
'acknowledgedCustomizationButton', 'modernUI', 'showExactValues', 'hideTimelineTypes', 'autotranslateLanguages',
'autotranslationMode', 'muteVideos', 'dontPauseVideos', 'showUserPreviewsOnMobile', 'systemDarkMode', 'localizeDigit',
'disableRetweetHotkey', 'disableLikeHotkey', 'disableFindHotkey', 'extensionCompatibilityMode', 'disableDataSaver', 'disableAcceptType',
'showUserFollowerCountsInLists', 'showQuoteCount', 'hideUnfollowersPage', 'transitionProfileBanner', 'customDownloadTemplate'
'showUserFollowerCountsInLists', 'showQuoteCount', 'hideUnfollowersPage', 'transitionProfileBanner', 'customDownloadTemplate',
'showBoringIndicators'
], data => {
// default variables
if(typeof(data.linkColorsInTL) !== 'boolean') {
Expand Down
4 changes: 2 additions & 2 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ function renderMedia(t) {
return _html;
}

async function appendUser(u, container, label) {
async function appendUser(u, container, label, usernameClass = '') {
let userElement = document.createElement('div');
userElement.classList.add('user-item');
if(vars.twitterBlueCheckmarks && u.ext && u.ext.isBlueVerified && u.ext.isBlueVerified.r && u.ext.isBlueVerified.r.ok) {
Expand All @@ -1518,7 +1518,7 @@ async function appendUser(u, container, label) {
<a href="/${u.screen_name}" class="user-item-link">
<img src="${(u.default_profile_image && vars.useOldDefaultProfileImage) ? chrome.runtime.getURL(`images/default_profile_images/default_profile_${Number(u.id_str) % 7}_normal.png`): u.profile_image_url_https}" alt="${u.screen_name}" class="user-item-avatar tweet-avatar" width="48" height="48">
<div class="user-item-text">
<span${u.id_str === '1708130407663759360' ? ' title="Old Twitter Layout extension developer"' : ''} class="tweet-header-name user-item-name${u.protected ? ' user-protected' : ''}${u.muting ? ' user-muted' : ''}${u.verified || u.verified_type ? ' user-verified' : u.id_str === '1708130407663759360' ? ' user-verified user-verified-dimden' : ''} ${u.verified_type === 'Government' ? 'user-verified-gray' : u.verified_type === 'Business' ? 'user-verified-yellow' : u.verified_type === 'Blue' ? 'user-verified-blue' : ''}">${escapeHTML(u.name)}</span><br>
<span${u.id_str === '1708130407663759360' ? ' title="Old Twitter Layout extension developer"' : ''} class="tweet-header-name user-item-name ${usernameClass} ${u.protected ? ' user-protected' : ''}${u.muting ? ' user-muted' : ''}${u.verified || u.verified_type ? ' user-verified' : u.id_str === '1708130407663759360' ? ' user-verified user-verified-dimden' : ''} ${u.verified_type === 'Government' ? 'user-verified-gray' : u.verified_type === 'Business' ? 'user-verified-yellow' : u.verified_type === 'Blue' ? 'user-verified-blue' : ''}">${escapeHTML(u.name)}</span><br>
<span class="tweet-header-handle">@${u.screen_name}</span>
${u.followed_by ? `<span class="follows-you-label">${LOC.follows_you.message}</span>` : ''}
${label ? `<br><span class="user-item-additional">${escapeHTML(label)}</span>` : ''}
Expand Down
1 change: 0 additions & 1 deletion scripts/twchallenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function solveChallenge(path, method) {
solveQueue.push({ id, path, method })
} else {
try {
console.log("sending challenge to solver", solverIframe.contentWindow, path);
solverIframe.contentWindow.postMessage({ action: 'solve', id, path, method }, '*');
} catch(e) {
console.error(`Error sending challenge to solver:`, e);
Expand Down

0 comments on commit dfce4e3

Please sign in to comment.