show "unknown" followed users as unread

This commit is contained in:
snow flurry 2024-04-30 12:11:24 -07:00
parent 259a789bda
commit a634f6da37

View file

@ -4,15 +4,23 @@
// @match https://cohost.org/rc/project/following* // @match https://cohost.org/rc/project/following*
// @grant GM.getValue // @grant GM.getValue
// @grant GM.setValue // @grant GM.setValue
// @version 1.0 // @version 1.1
// @author snow flurry <snow@datagirl.xyz> // @author snow flurry <snow@datagirl.xyz>
// @description Puts a dot next to users you follow with unread posts. // @description Puts a dot next to users you follow with unread posts.
// ==/UserScript== // ==/UserScript==
// Changelog:
// 1.1:
// - Default to showing "unknown" followed users as unread.
// - If you want the previous setting, set "unreadForUnknown"
// to false in the script's Values tab.
(async () => { (async () => {
// Used by GM.getValue/GM.setValue // Used by GM.getValue/GM.setValue
const gmvalLastViewed = "lastViewed"; const gmvalLastViewed = "lastViewed";
const notifyDotClass = "__x-notify-dot"; const notifyDotClass = "__x-notify-dot";
// Whether to show "unknown" users as unread by default
const unreadForUnknown = GM.getValue("unreadForUnknown", true);
// Stolen from the notification dot on the "refresh" button :3 // Stolen from the notification dot on the "refresh" button :3
const dotSvgPath = ` const dotSvgPath = `
<path d="M29.9375 34.712c-4.5219 1.3518-8.8029 1.9644-12.843 <path d="M29.9375 34.712c-4.5219 1.3518-8.8029 1.9644-12.843
@ -108,12 +116,19 @@
const projId = liProps.project.projectId.toString(); const projId = liProps.project.projectId.toString();
if (!(projId in latest)) { if (!(projId in latest)) {
// No latest post! We won't show a dot, but will note this // No latest post! Use unreadForUnknown to figure
// for later. // out what to do.
latest[projId] = { if (unreadForUnknown) {
id: liProps.latestPost.postId, latest[projId] = {
date: liProps.latestPost.publishedAt id: 0,
}; date: "1970-01-01T00:00:00.000Z"
};
} else {
latest[projId] = {
id: liProps.latestPost.postId,
date: liProps.latestPost.publishedAt
};
}
} }
if (li.querySelector(`svg.${notifyDotClass}`) != null) { if (li.querySelector(`svg.${notifyDotClass}`) != null) {