add: custom emojis

fix: don't show reposts of posts from blocked users
fix: don't show questions when they're from users you've blocked
This commit is contained in:
trisua 2025-05-10 21:58:02 -04:00
parent 9f187039e6
commit 275dd0a1eb
25 changed files with 697 additions and 61 deletions

View file

@ -215,6 +215,28 @@ media_theme_pref();
});
// hooks
self.define("hooks::verify_emoji", (_) => {
for (const post of document.querySelectorAll("[hook=verify_emojis]")) {
const community_id = post.getAttribute("data-community");
const owner_is_supporter =
post.getAttribute("data-ownsup") === "true";
if (owner_is_supporter) {
return;
}
// not supporter; check emojis
for (const img of post.querySelectorAll(".emoji")) {
if (
img.src.split("/api/v1/communities/")[1].split("/")[0] !==
community_id
) {
img.remove();
}
}
}
});
self.define("hooks::scroll", (_, scroll_element, track_element) => {
const goals = [150, 250, 500, 1000];

View file

@ -24,6 +24,9 @@
res.message,
]);
delete self.LOGIN_ACCOUNT_TOKENS[res.payload];
self.set_login_account_tokens(self.LOGIN_ACCOUNT_TOKENS);
if (res.ok) {
setTimeout(() => {
window.location.href = "/";
@ -345,6 +348,26 @@
}
});
self.define("emojis", async () => {
const payload = (await (await fetch("/api/v1/my_emojis")).json())
.payload;
const out = [];
for (const [community, [category, emojis]] of Object.entries(payload)) {
for (const emoji of emojis) {
out.push({
category,
name: emoji.name,
shortcodes: [`${community}.${emoji.name}`],
url: `/api/v1/communities/${community}/emojis/${emoji.name}`,
});
}
}
return out;
});
// token switcher
self.define(
"set_login_account_tokens",