AO3 One-Click Mute Button

Adds a mute direct link to each fic box.

  1. // ==UserScript==
  2. // @name AO3 One-Click Mute Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Adds a mute direct link to each fic box.
  6. // @author exuvia
  7. // @match https://archiveofourown.org/users/*/muted/users/confirm_mute*
  8. // @match https://archiveofourown.org/tags/*/works*
  9. // @require http://code.jquery.com/jquery-3.5.1.min.js
  10. // @icon http://archiveofourown.org/favicon.ico
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. //////SETTINGS//////
  17. const username = ""; //Required. Enter your username here.
  18. const skipConfirm = true; //To skip the confirm mute button
  19. const hideMuteMessages = false; //Default disabled. Has ~0.5 second delay, may be annoying.
  20. ////////////////////
  21.  
  22. if (hideMuteMessages){
  23. //hideMuteMessages
  24. //do not just get p.notes because this will also hide the Notes sections on fics. Technically, this also hides any author's notes that have this exact text.
  25. const muteMessage = Array.from(document.querySelectorAll("p.notes")).filter(a=>a.innerText.includes("You have muted some users on the Archive. Some items may not be shown, and any counts may be inaccurate. You can mute or unmute users on your Muted Users page."))
  26. if (muteMessage.length > 0) muteMessage[0].hidden = true;
  27. }
  28.  
  29. if (window.location.href.includes("confirm_mute") && skipConfirm) {
  30. //skipConfirm
  31. document.querySelector(`input[value="Yes, Mute User"]`).click();
  32. }
  33. else{
  34. //add mute buttons
  35. //console.log("Adding mute button")
  36. $(`a[rel="author"]`).each((i, a)=>{
  37. let blockedUsername = a.innerText;
  38. const button = $(`<a href="https://archiveofourown.org/users/${username}/muted/users/confirm_mute?muted_id=${blockedUsername}" style="color: black;position: absolute;top: 30px;right: 0;margin: 0;">Mute</a>`);
  39. button.insertBefore(a);
  40. }
  41. )
  42. }
  43. })();