add: don't allow poll creator to vote
add: unfollow user when you block them add: force other user to unfollow you by blocking them add: leave receiver communities when you block them
This commit is contained in:
parent
5a330b7a18
commit
460e87e90e
11 changed files with 165 additions and 17 deletions
|
@ -91,10 +91,11 @@ media_theme_pref();
|
|||
|
||||
self.define("rel_date", (_, date) => {
|
||||
// stolen and slightly modified because js dates suck
|
||||
const diff = (new Date().getTime() - date.getTime()) / 1000;
|
||||
const diff = Math.abs((new Date().getTime() - date.getTime()) / 1000);
|
||||
const day_diff = Math.floor(diff / 86400);
|
||||
|
||||
if (Number.isNaN(day_diff) || day_diff < 0 || day_diff >= 31) {
|
||||
console.log(diff);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -162,6 +163,48 @@ media_theme_pref();
|
|||
}
|
||||
});
|
||||
|
||||
self.define("clean_poll_date_codes", ({ $ }) => {
|
||||
for (const element of Array.from(
|
||||
document.querySelectorAll(".poll_date"),
|
||||
)) {
|
||||
const created = Number.parseInt(
|
||||
element.getAttribute("data-created"),
|
||||
);
|
||||
const expires = Number.parseInt(
|
||||
element.getAttribute("data-expires"),
|
||||
);
|
||||
|
||||
const then = new Date(created + expires);
|
||||
|
||||
if (Number.isNaN(element.innerText)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
element.setAttribute("title", then.toLocaleString());
|
||||
|
||||
console.log($.rel_date(then));
|
||||
const pretty =
|
||||
$.rel_date(then)
|
||||
.replaceAll(" minutes ago", "m")
|
||||
.replaceAll(" minute ago", "m")
|
||||
.replaceAll(" hours ago", "h")
|
||||
.replaceAll(" hour ago", "h")
|
||||
.replaceAll(" days ago", "d")
|
||||
.replaceAll(" day ago", "d")
|
||||
.replaceAll(" weeks ago", "w")
|
||||
.replaceAll(" week ago", "w")
|
||||
.replaceAll(" months ago", "m")
|
||||
.replaceAll(" month ago", "m")
|
||||
.replaceAll(" years ago", "y")
|
||||
.replaceAll(" year ago", "y") || "";
|
||||
|
||||
element.innerText =
|
||||
pretty === undefined ? then.toLocaleDateString() : pretty;
|
||||
|
||||
element.style.display = "inline-block";
|
||||
}
|
||||
});
|
||||
|
||||
self.define("copy_text", ({ $ }, text) => {
|
||||
navigator.clipboard.writeText(text);
|
||||
$.toast("success", "Copied!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue