ao3 hide certain tags

suppress tags that aren't capitalized

  1. // ==UserScript==
  2. // @name ao3 hide certain tags
  3. // @namespace https://greasyfork.org/en/users/36620
  4. // @version 0.3.1
  5. // @description suppress tags that aren't capitalized
  6. // @author scriptfairy
  7. // @include http://archiveofourown.org/*works*
  8. // @include https://archiveofourown.org/*works*
  9. // @grant none
  10. // ==/UserScript==
  11. //
  12. function isCap(str) {
  13. if (/[\W\d]/.test(str[0])) {return true;}
  14. else if (str[0] !== str[0].toLowerCase()) {return true;}
  15. else {return false;}
  16. }
  17. //
  18. (function($) {
  19. $('<style>').text('.hide {float:right;}').appendTo($('head'));
  20. //
  21. var lis = $('.index .tags li.freeforms');
  22. for (i=0;i<lis.length;i++) {
  23. var li = lis[i];
  24. var tagtext = li.innerText;
  25. if (tagtext.indexOf(" ") == -1 && !isCap(tagtext)) {
  26. li.style.display = 'none';
  27. }
  28. else if (tagtext.indexOf(" ") > -1 && (!isCap(tagtext) || !isCap(tagtext.slice(tagtext.indexOf(" ")+1)))) {
  29. li.style.display = 'none';
  30. }
  31. }
  32. for (j=0;j<$('.index .blurb').length;j++) {
  33. var work = $('.index .blurb')[j];
  34. var worktags = $(work).children('.tags')[0];
  35. if ($('[style$="display: none;"]', worktags).length > 0) {
  36. var button = document.createElement('div');
  37. button.setAttribute('class','hide');
  38. button.innerHTML = '<button type="button" class="showtag">Show More Tags</button>';
  39. $(worktags).after(button);
  40. }
  41. }
  42. //
  43. $(document).ready(function(){
  44. $('.showtag').click(function() {
  45. var blurb = $(this).parent().prev()[0];
  46. console.log(blurb);
  47. $('[style$="display: none;"]', blurb).removeAttr('style');
  48. $(this).parent('div').remove();
  49. });
  50. });
  51. })(window.jQuery);