AO3: highlight tags

Configure tags to be highlighted with different colors

当前为 2015-04-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name AO3: highlight tags
  3. // @description Configure tags to be highlighted with different colors
  4. // @namespace http://gf.qytechs.cn/users/6872-fangirlishness
  5. // @author Fangirlishness
  6. // @include http://archiveofourown.org/*
  7. // @include https://archiveofourown.org/*
  8. // @grant none
  9. // @version 1.0
  10. // ==/UserScript==
  11.  
  12. // loosely derived from tuff-ghost's ao3 hide some tags (with permission)
  13.  
  14. (function($) {
  15.  
  16. /**** CONFIG ********************/
  17.  
  18. // add the tag pattern you want to highlight (can appear anywhere in the tag) and the color for each
  19. var tagsToHighlight = {"Alternate Universe":"#fda7d1", // pink
  20. "Fanart":"#adf7d1", // light green
  21. "Mpreg.*":"red", // regexp patterns can be used
  22. "somethingelse": "blue"}; // named colors work too
  23.  
  24. /********************************/
  25. $('.blurb ul.tags, .meta .tags ul').each(function() {
  26. var $list = $(this);
  27. $list.find('a.tag').each(function() {
  28. var $tag = $(this);
  29. var text = $tag.text();
  30. for (var key in tagsToHighlight) {
  31. var pattern = new RegExp(key, "g")
  32. if(text.match(pattern) != null) {
  33. highlightTag($tag, tagsToHighlight[key]);
  34. }
  35. }
  36. });
  37. });
  38.  
  39. function highlightTag($tag, color) {
  40. $tag.css('background-color', color);
  41. }
  42. })(jQuery);

QingJ © 2025

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