- // ==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);