Fanfiction.net Unwanted Result Filter

Make up for how limited Fanfiction.net's result filtering is

目前為 2015-10-31 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Fanfiction.net Unwanted Result Filter
  3. // @namespace http://www.ficfan.org/
  4. // @description Make up for how limited Fanfiction.net's result filtering is
  5. // compared to sites like Twisting the Hellmouth.
  6. // @copyright 2014-2015, Stephan Sokolow (http://www.ssokolow.com/)
  7. // @license MIT; http://www.opensource.org/licenses/mit-license.php
  8. // @version 0.0.1
  9. // @require http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js
  10. // @grant GM_log
  11. // @noframes
  12. //
  13. // @match *://www.fanfiction.net/*
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. // Change to "false" to turn off category filtering
  18. var filter_cats = true;
  19.  
  20. // Change to "false" to turn off slash filtering
  21. var filter_slash = true;
  22.  
  23. // Edit this list to choose which categories will cause an entry to be hidden
  24. var unwanted_cats = [
  25. // Never wanted
  26. "A song of Ice and Fire",
  27. "Assassin's Creed",
  28. "Avengers",
  29. "Beauty and the Beast",
  30. "Boondock Saints",
  31. "Borderlands",
  32. "Criminal Minds",
  33. "Dead Space",
  34. "Dragon Age",
  35. "Elder Scroll series",
  36. "Eyeshield 21",
  37. "Fairy Tail",
  38. "Freezing/フリージング",
  39. "Game of Thrones",
  40. "Glee",
  41. "Gundam",
  42. "Heroes",
  43. "High School DxD",
  44. "Hobbit",
  45. "Inheritance Cycle",
  46. "Invader Zim",
  47. "Katekyo Hitman Reborn!",
  48. "Kill la Kill",
  49. "Kuroshitsuji",
  50. "L.A. Law",
  51. "Law and Order",
  52. "Lord of the Rings",
  53. "NCIS",
  54. "Percy Jackson",
  55. "Pirates of the Caribbean",
  56. "Prince of Tennis",
  57. "RWBY",
  58. "Rise of the Guardians",
  59. "Super Smash Brothers",
  60. "Supernatural",
  61. "Tomb Raider",
  62. "Transformers",
  63. "True Blood",
  64. "Twilight",
  65. "Vampire Diaries",
  66. "Vocaloid",
  67. "Walking Dead",
  68. "Warcraft",
  69. "West Wing",
  70. // Not wanted right now
  71. "Battlestar Galactica & Halo",
  72. "Halo & Battlestar Galactica",
  73. "Naruto",
  74. "Ouran High School Host Club",
  75. "Rosario + Vampire",
  76. "Star Wars",
  77. ];
  78.  
  79. var slash_re = new RegExp(".*(slash|yaoi)([.,!: ]|$)", 'i');
  80. var not_slash_re = new RegExp(".*(fem|not?[ ]+)(slash|yaoi)([.,!: ]|$)", 'i');
  81. var unwanted_re = new RegExp(".*(" + unwanted_cats.join('|') + ').*Rated:.*');
  82.  
  83. if (typeof jQuery !== "undefined" && jQuery !== null) {
  84. var $ = jQuery;
  85. } else {
  86. console.log("ERROR: No jQuery!");
  87. return;
  88. }
  89.  
  90. // Clear out ad box which misaligns "Hidden" message if it's first result
  91. $($('#content_wrapper_inner ins.adsbygoogle').parent()[0]).remove();
  92.  
  93. var reslen, results = $(".z-list");
  94. for (var i = 0, reslen = results.length; i < reslen; i++) {
  95. var story = results[i];
  96. var meta_row = $('.xgray', story).text();
  97. var description = $('.z-padtop', story).contents()[0].data;
  98. var reason = null;
  99.  
  100. // TODO: Redesign to collapse runs of hidden entries
  101. if (filter_slash && slash_re.test(description)
  102. && !not_slash_re.test(description)) {
  103. reason = "Slash";
  104. } else if (filter_cats && unwanted_re.test(meta_row)) {
  105. // TODO: Enhance this to actually say the source's name
  106. reason = "Unwanted Source";
  107. }
  108. if (reason) {
  109. $(story).html("Hidden (" + reason + ")").css({
  110. minHeight: 0,
  111. maxHeight: '1em',
  112. color: 'lightgray',
  113. textAlign: 'center',
  114. });
  115. }
  116. }
  117. }).call(this);