show "unknown" followed users as unread
This commit is contained in:
parent
259a789bda
commit
a634f6da37
|
@ -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,13 +116,20 @@
|
||||||
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.
|
||||||
|
if (unreadForUnknown) {
|
||||||
|
latest[projId] = {
|
||||||
|
id: 0,
|
||||||
|
date: "1970-01-01T00:00:00.000Z"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
latest[projId] = {
|
latest[projId] = {
|
||||||
id: liProps.latestPost.postId,
|
id: liProps.latestPost.postId,
|
||||||
date: liProps.latestPost.publishedAt
|
date: liProps.latestPost.publishedAt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (li.querySelector(`svg.${notifyDotClass}`) != null) {
|
if (li.querySelector(`svg.${notifyDotClass}`) != null) {
|
||||||
// Dot already exists, we don't need to update it
|
// Dot already exists, we don't need to update it
|
||||||
|
|
Loading…
Reference in a new issue