A rewrite of Poly+, my quality-of-life browser extension for Polytoria. Built entirely fresh using the WXT extension framework, Typescript, and with added better overall code quality.
extension

minor: reimplement "Hide Sidebar Notification Badges"

Index d8df51f2 ef21f3e7

Changed files
+18 -11
entrypoints
utils
+4 -6
entrypoints/account.content/friends.ts
···
const firstPage = Array.from(container.getElementsByTagName('a'))
.map((link) => link.getAttribute('href')?.split('/')[2]);
-
//api.iterate('internal', '/friends?page=', 1).then(data => console.log(data))
-
const setDisabled = function(value: boolean) {
acceptAll.disabled = value;
declineAll.disabled = value;
···
acceptAll.addEventListener('click', async () => {
setDisabled(true);
-
const ids = await api.iterate('internal', '/friends/requests?page=', 1);
+
const ids = await api.iterate('internal', 'friends/requests?page=', 1);
const payloads = ids.map((request: any) => ({
method: 'POST',
headers: {
···
userID: request.senderID
})
}));
-
api.batchAction('/friends/send', payloads);
+
api.batchAction('friends/send', payloads);
});
declineAll.addEventListener('click', async () => {
setDisabled(true);
-
const ids = await api.iterate('internal', '/friends/requests?page=', 1);
+
const ids = await api.iterate('internal', 'friends/requests?page=', 1);
const payloads = ids.map((request: any) => ({
method: 'POST',
headers: {
···
userID: request.senderID
})
}));
-
api.batchAction('/friends/remove', payloads);
+
api.batchAction('friends/remove', payloads);
});
};
+2 -3
entrypoints/home.content.ts
···
const placeData: Array<placeApiSchema> = await pullCache(
'favoritedPlaces',
-
async () => await api.batch('public', '/places/', places),
+
async () => await api.batch('public', 'places/', places),
300000,
false
);
···
.then(async (friends) => {
const userData = await pullCache(
'bestFriends',
-
async () => await api.batch('internal', '/users/', friends),
+
async () => await api.batch('public', 'users/', friends),
300000,
false
);
···
const trendingItems = Array.from(document.querySelectorAll('a[href^="/store"]:has(.place-card)'));
for (const item of trendingItems) {
-
console.log(item)
const priceTag = item.getElementsByClassName('text-success')[0];
const currency = bricksToCurrency(parseInt(priceTag.textContent!), "USD");
+10 -1
entrypoints/sitewide.content.ts
···
.then((values) => {
if (values.irlBrickPrice.enabled) {
const currency = bricksToCurrency(user.bricks, "USD");
-
if (currency) document.getElementsByClassName('brickBalanceCount')[0].textContent += ` (${currency})`;
+
if (currency) {
+
document.getElementsByClassName('brickBalanceCount')[0].textContent += ` (${currency})`;
+
};
+
};
+
+
if (values.hideNotificationBadges.enabled) {
+
const badges = document.getElementsByClassName('notif-nav notif-sidebar');
+
for (const badge of badges) {
+
badge.remove();
+
};
};
});
});
+2 -1
utils/storage.ts
···
bestFriends: { enabled: true },
forumMentions: { enabled: true },
improvedFriendLists: { enabled: true },
-
irlBrickPrice: { enabled: true }
+
irlBrickPrice: { enabled: true },
+
hideNotificationBadges: { enabled: false }
}
export type preferencesSchema = typeof defaultPreferences & {