Skip to content

Commit

Permalink
add option to show follower counts in user lists
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 10, 2023
1 parent 9caff63 commit 6dfadb0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 6 deletions.
4 changes: 3 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,7 @@
"disable_accept_type": { "message": "Disable accept-type when uploading media. This fixes the problem of not being able to access all images on some Android versions.", "description": "This option only appears on mobile" },
"manage_searches": { "message": "Manage searches" },
"add_search": { "message": "Add search" },
"pinned_searches": { "message": "Pinned searches" }
"pinned_searches": { "message": "Pinned searches" },
"show_follower_counts_in_lists": { "message": "Show users follower counts on follower/following pages." },
"not_possible_to_see_unfollowers": { "message": "Unfortunately, it's not possible to see unfollowers for accounts with more than 50,000 followers." }
}
4 changes: 3 additions & 1 deletion _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,5 +539,7 @@
"disable_accept_type": { "message": "Выключить 'accept-type' при открытии галереи для загрузки медиа. Включите если на вашем Андроиде нельзя выбрать/найти некоторые картинки в галерее.", "description": "This option only appears on mobile" },
"manage_searches": { "message": "Изменить поиски" },
"add_search": { "message": "Добавить поиск" },
"pinned_searches": { "message": "Закреплённые поиски" }
"pinned_searches": { "message": "Закреплённые поиски" },
"show_follower_counts_in_lists": { "message": "Показывать кол-во подписчиков пользователей в списке подписок." },
"not_possible_to_see_unfollowers": { "message": "К сожалению, информация про отписчиков не доступна для аккаунтов с более чем 50,000 подписчиков." }
}
4 changes: 3 additions & 1 deletion _locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,5 +539,7 @@
"disable_accept_type": { "message": "Виключити 'accept-type' при відкритті галереї для загрузки медіа. Включить якщо на вашому Андроїді не можна вибрати/знайти деякі картинки в галереї.", "description": "This option only appears on mobile" },
"manage_searches": { "message": "Пошуки" },
"add_search": { "message": "Добавити пошук" },
"pinned_searches": { "message": "Закріплені пошуки" }
"pinned_searches": { "message": "Закріплені пошуки" },
"show_follower_counts_in_lists": { "message": "Показувати кількість підписників користувачів в списку підписок." },
"not_possible_to_see_unfollowers": { "message": "На жаль, інформація про відписників не доступна для аккаунтів з більше ніж 50,000 підписників." }
}
2 changes: 1 addition & 1 deletion layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ let userDataFunction = async user => {
}

// unfollows
if(user.followers_count > 0 && user.followers_count < 50000) {
if(user.followers_count > 0 && user.followers_count < 50000 && user.friends_count < 50000) {
chrome.storage.local.get(['unfollows'], async d => {
let res = d.unfollows;
if(!res) res = {};
Expand Down
3 changes: 3 additions & 0 deletions layouts/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ <h2>__MSG_profile__</h2><br>
<div class="setting">
<input type="checkbox" id="show-media-count"> <label for="show-media-count">__MSG_show_media_count__</label>
</div>
<div class="setting">
<input type="checkbox" id="show-user-follower-counts-in-lists"> <label for="show-user-follower-counts-in-lists">__MSG_show_follower_counts_in_lists__</label>
</div>
<div class="setting">
<input type="checkbox" id="disable-profile-customizations"> <label for="disable-profile-customizations">__MSG_disable_profile_customizations__</label>
</div>
Expand Down
6 changes: 6 additions & 0 deletions layouts/settings/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ setTimeout(async () => {
let extensionCompatibilityMode = document.getElementById('extension-compatibility-mode');
let disableDataSaver = document.getElementById('disable-data-saver');
let disableAcceptType = document.getElementById('disable-accept-type');
let showUserFollowerCountsInLists = document.getElementById('show-user-follower-counts-in-lists');

let root = document.querySelector(":root");
{
Expand Down Expand Up @@ -330,6 +331,11 @@ setTimeout(async () => {
vars.autotranslationMode = autotranslationMode.value;
});
});
showUserFollowerCountsInLists.addEventListener('change', () => {
chrome.storage.sync.set({
showUserFollowerCountsInLists: showUserFollowerCountsInLists.checked
}, () => { });
});
enableIframeNavigation.addEventListener('change', () => {
chrome.storage.sync.set({
enableIframeNavigation: enableIframeNavigation.checked
Expand Down
7 changes: 7 additions & 0 deletions layouts/unfollows/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function renderUserData() {
document.getElementById('user-avatar-link').href = `https://twitter.com/${user.screen_name}`;
document.getElementById('user-info').href = `https://twitter.com/${user.screen_name}`;

if(user.followers_count > 50000 || user.friends_count > 50000) {
document.getElementById('timeline').innerHTML = `<span style="color:var(--light-gray)">${LOC.not_possible_to_see_unfollowers.message}</span>`;
}

if(vars.enableTwemoji) twemoji.parse(document.getElementById('user-name'));

document.getElementById('loading-box').hidden = true;
Expand All @@ -58,6 +62,9 @@ function renderUserData() {
function renderUnfollows(page = 0) {
chrome.storage.local.get(['unfollows'], async d => {
loading = true;
if(user.followers_count && (user.followers_count > 50000 || user.friends_count > 50000)) {
return;
}

let res = d.unfollows;
if(!res) res = {};
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 (2023)",
"description": "__MSG_ext_description__",
"version": "1.7.8.5",
"version": "1.7.8.6",
"manifest_version": 3,
"homepage_url": "https://github.com/dimdenGD/OldTwitter",
"background": {
Expand Down
3 changes: 2 additions & 1 deletion scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async function loadVars() {
'enableAd', 'acknowledgedCssAccess', 'disableProfileCustomizations', 'openNotifsAsModal', 'enableIframeNavigation',
'acknowledgedCustomizationButton', 'modernUI', 'showExactValues', 'hideTimelineTypes', 'autotranslateLanguages',
'autotranslationMode', 'muteVideos', 'dontPauseVideos', 'showUserPreviewsOnMobile', 'systemDarkMode', 'localizeDigit',
'disableRetweetHotkey', 'disableLikeHotkey', 'extensionCompatibilityMode', 'disableDataSaver', 'disableAcceptType'
'disableRetweetHotkey', 'disableLikeHotkey', 'extensionCompatibilityMode', 'disableDataSaver', 'disableAcceptType',
'showUserFollowerCountsInLists'
], data => {
// default variables
if(typeof(data.linkColorsInTL) !== 'boolean') {
Expand Down
10 changes: 10 additions & 0 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ function renderMedia(t) {
return html;
}

let insertedLabelStyle = false;
async function appendUser(u, container, label) {
let userElement = document.createElement('div');
userElement.classList.add('user-item');
Expand All @@ -1389,6 +1390,15 @@ async function appendUser(u, container, label) {
delete u.verified_type;
u.verified = false;
}
if(!label && vars.showUserFollowerCountsInLists) {
label = `${formatLargeNumber(u.followers_count)} ${vars.modernUI ? LOC.followers.message : LOC.followers.message.toLowerCase()}`;
if(!insertedLabelStyle) {
insertedLabelStyle = true;
let style = document.createElement('style');
style.innerHTML = `.user-item-text { bottom: -3px !important; }`;
document.head.appendChild(style);
}
}
userElement.innerHTML = `
<div>
<a href="https://twitter.com/${u.screen_name}" class="user-item-link">
Expand Down

0 comments on commit 6dfadb0

Please sign in to comment.