Auto-remove notifications on fave

This automatically removes submission notifications, when faving a submission.

  1. // ==UserScript==
  2. // @name Auto-remove notifications on fave
  3. // @namespace https://github.com/f1r3w4rr10r/fa-utils
  4. // @version 1.0.0
  5. // @description This automatically removes submission notifications, when faving a submission.
  6. // @author f1r3w4rr10r
  7. // @match https://www.furaffinity.net/view/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (async function () {
  14. "use strict";
  15.  
  16. const favLinks = Array.from(
  17. document.querySelectorAll(
  18. '.favorite-nav > [href^="/fav/"], .fav > [href^="/fav/"]',
  19. ),
  20. );
  21.  
  22. for (const favLink of favLinks) {
  23. if (!(favLink instanceof HTMLAnchorElement))
  24. throw new Error("'favLink' was not an instance of 'HTMLAnchorElement'.");
  25.  
  26. favLink.addEventListener("click", async (event) => {
  27. event.preventDefault();
  28.  
  29. const href = favLink.href;
  30. const urlMatch = href.match(/\/fav\/(\d+)\//);
  31. if (!urlMatch) {
  32. console.error("The fav URL did not match.", href);
  33. throw new Error("The fav URL did not match.");
  34. }
  35.  
  36. const submissionId = urlMatch[1];
  37. if (!submissionId) throw new Error("Could not extract a submission ID.");
  38.  
  39. const result = await fetch("/msg/submissions/old@24/", {
  40. method: "POST",
  41. body: new URLSearchParams({
  42. "messagecenter-action": "remove_checked",
  43. "submissions[]": submissionId,
  44. }),
  45. redirect: "manual",
  46. });
  47.  
  48. if (result.type !== "opaqueredirect") {
  49. console.error("Could not remove the submission notification.", result);
  50. throw new Error("Could not remove the submission notification.");
  51. }
  52.  
  53. window.location.assign(href);
  54. });
  55. }
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址