AO3: [Wrangling] Edit Tag buttons on inbox comments

add a button to the tag edit page next to the Reply button

  1. // ==UserScript==
  2. // @name AO3: [Wrangling] Edit Tag buttons on inbox comments
  3. // @description add a button to the tag edit page next to the Reply button
  4. // and make sure other links to tags inside the comment also lead to edit pages
  5. // @version 0.2
  6. // @author Rhine
  7. // @namespace https://github.com/RhineCloud
  8. // @match http*://*archiveofourown.org
  9. // @match http*://*archiveofourown.org/
  10. // @match http*://*archiveofourown.org/users/*/inbox*
  11. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function($) {
  16. // go through each tag comment
  17. $('li.comment:has(a:nth-of-type(2)[href^="/tags/"])').each(function() {
  18. // add a button to the tag's edit page
  19. let tag = $(this).find('a:nth-of-type(2)').attr('href').split('/')[2];
  20. let buttonHTML = '<li><a href="/tags/' + tag + '/edit">Edit Tag</a></li>';
  21. $(this).find('ul.actions li:has(a[href*="/inbox/reply"])').after(buttonHTML);
  22. // go through each link to a tags page inside the comment text
  23. $(this).find('blockquote.userstuff a[href*="/tags/"]').each(function() {
  24. // make sure it leads to the edit page
  25. if (!$(this).attr('href').endsWith('/edit')) {
  26. let linkParts = $(this).attr('href').split('/');
  27. let linkTag = linkParts[linkParts.indexOf('tags') + 1];
  28. $(this).attr('href', '/tags/' + linkTag + '/edit');
  29. }
  30. });
  31. });
  32. })(jQuery);