Greasy Fork 支持简体中文。

ao3 hide certain tags

suppress tags that aren't capitalized

目前為 2016-04-10 提交的版本,檢視 最新版本

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