// ==UserScript== // @name AO3: Badge for Unread Inbox Messages // @namespace https://greasyfork.org/en/users/906106-escctrl // @version 1.0.1 // @description puts a little notification badge in the menu for unread messages in your AO3 inbox // @author escctrl // @match https://*.archiveofourown.org/* // @license MIT // @require https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js // @grant none // @downloadURL none // ==/UserScript== /****************** CONFIGURATION ******************/ // how often the script will check for unread messages (in hours) const REFRESH_INTERVAL = 12; // if the badge should show as an icon (true), or as text (false) const BADGE_ICON = true; // pick a background color for the badge to stand out more, or leave empty quotes "" const HIGHLIGHT_COLOR = "gold"; // if the inbox link in the sidebar should automatically filter to unread messages only const FILTER_INBOX = false; // ****************** NOTE ON LOCAL STORAGE ****************** // For compatibility between userscript managers, this script uses local storage, which is visible from the Developer console. // If you ever uninstall the script, unfortunately its data can't be automatically deleted. // If you want to remove the data it sets, (1) visit archiveofourown.org, (2) go into the Developer console, // (3) look for the Local Storage (4) and delete the entries for "unread_inbox_count" and "unread_inbox_date". // The script also removes its data if you ever visit AO3 while logged out. (function($) { 'use strict'; // first question: is the user logged in? if not, don't bother with any of this const linkDash = $("#greeting p.icon a").attr('href') || ""; if (linkDash === "") { localStorage.removeItem('unread_inbox_count'); localStorage.removeItem('unread_inbox_date'); return; } var highlight_css = (HIGHLIGHT_COLOR !== "") ? `#greeting #inboxbadge { background-color: ${HIGHLIGHT_COLOR}; border-radius: .25em; }` : ""; $("head").append(``) .prepend(`