Greasy Fork

Greasy Fork is available in English.

Fanfiction.net Unwanted Result Filter

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

当前为 2015-10-31 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Fanfiction.net Unwanted Result Filter
// @namespace   http://www.ficfan.org/
// @description Make up for how limited Fanfiction.net's result filtering is
//              compared to sites like Twisting the Hellmouth.
// @copyright   2014-2015, Stephan Sokolow (http://www.ssokolow.com/)
// @license     MIT; http://www.opensource.org/licenses/mit-license.php
// @version     0.0.1
// @require     http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js
// @grant       GM_log
// @noframes
//
// @match *://www.fanfiction.net/*
// ==/UserScript==

(function() {
  // Change to "false" to turn off category filtering
  var filter_cats = true;

  // Change to "false" to turn off slash filtering
  var filter_slash = true;

  // Edit this list to choose which categories will cause an entry to be hidden
  var unwanted_cats = [
    // Never wanted
    "A song of Ice and Fire",
    "Assassin's Creed",
    "Avengers",
    "Beauty and the Beast",
    "Boondock Saints",
    "Borderlands",
    "Criminal Minds",
    "Dead Space",
    "Dragon Age",
    "Elder Scroll series",
    "Eyeshield 21",
    "Fairy Tail",
    "Freezing/フリージング",
    "Game of Thrones",
    "Glee",
    "Gundam",
    "Heroes",
    "High School DxD",
    "Hobbit",
    "Inheritance Cycle",
    "Invader Zim",
    "Katekyo Hitman Reborn!",
    "Kill la Kill",
    "Kuroshitsuji",
    "L.A. Law",
    "Law and Order",
    "Lord of the Rings",
    "NCIS",
    "Percy Jackson",
    "Pirates of the Caribbean",
    "Prince of Tennis",
    "RWBY",
    "Rise of the Guardians",
    "Super Smash Brothers",
    "Supernatural",
    "Tomb Raider",
    "Transformers",
    "True Blood",
    "Twilight",
    "Vampire Diaries",
    "Vocaloid",
    "Walking Dead",
    "Warcraft",
    "West Wing",
    // Not wanted right now
    "Battlestar Galactica & Halo",
    "Halo & Battlestar Galactica",
    "Naruto",
    "Ouran High School Host Club",
    "Rosario + Vampire",
    "Star Wars",
    ];

  var slash_re = new RegExp(".*(slash|yaoi)([.,!: ]|$)", 'i');
  var not_slash_re = new RegExp(".*(fem|not?[ ]+)(slash|yaoi)([.,!: ]|$)", 'i');
  var unwanted_re = new RegExp(".*(" + unwanted_cats.join('|') + ').*Rated:.*');

  if (typeof jQuery !== "undefined" && jQuery !== null) {
    var $ = jQuery;
  } else {
    console.log("ERROR: No jQuery!");
    return;
  }

  // Clear out ad box which misaligns "Hidden" message if it's first result
  $($('#content_wrapper_inner ins.adsbygoogle').parent()[0]).remove();

  var reslen, results = $(".z-list");
  for (var i = 0, reslen = results.length; i < reslen; i++) {
    var story = results[i];
    var meta_row = $('.xgray', story).text();
    var description = $('.z-padtop', story).contents()[0].data;
    var reason = null;

    // TODO: Redesign to collapse runs of hidden entries
    if (filter_slash && slash_re.test(description)
                     && !not_slash_re.test(description)) {
        reason = "Slash";
    } else if (filter_cats && unwanted_re.test(meta_row)) {
        // TODO: Enhance this to actually say the source's name
        reason = "Unwanted Source";
    }
    if (reason) {
      $(story).html("Hidden (" + reason + ")").css({
          minHeight: 0,
          maxHeight: '1em',
          color: 'lightgray',
          textAlign: 'center',
      });
    }
  }
}).call(this);