// ==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.1.0 // // @require http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js // @require https://greasyfork.org/scripts/2855-gm-config/code/GM_config.js?version=33973 // // @grant GM_registerMenuCommand // @grant GM_getValue // @grant GM_setValue // @grant GM_log // @noframes // // @match *://www.fanfiction.net/* // @downloadURL none // ==/UserScript== (function($) { /* NOTE TO USERS OF VERSION 0.0.1: * Sorry for erasing any modifications you made to the filter settings. * * I didn't put much thought into version 0.0.1 and, as a result, it was * impossible to release an update without erasing modifications. * * I'm now storing settings via GM_setValue, so it should never happen again * and there's a proper configuration GUI available at * Greasemonkey > User Script Commands... > Configure Result Filter... */ // ----==== Configuration ====---- var fieldDefs = { 'filter_slash': { 'section': ['Slash Filter', 'Hide stories with slash based on warnings in story descriptions'], 'label': 'Enabled', 'labelPos': 'right', 'type': 'checkbox', 'default': true, }, 'hide_slash': { 'label': 'No Placeholder', 'labelPos': 'right', 'type': 'checkbox', 'default': false, }, 'slash_pat': { 'label': 'Slash is...', 'title': 'A regular expression which matches slash in descriptions', 'type': 'text', 'size': 255, 'default': ".*(slash|yaoi)([.,!: ]|$)" }, 'not_slash_pat': { 'label': '...but not...', 'title': 'A regular expression which matches "not slash" and so on', 'type': 'text', 'size': 255, 'default': ".*(fem|not?[ ]+)(slash|yaoi)([.,!: ]|$)" }, 'filter_cats': { 'section': ['Unwanted Category Filter', 'Hide unwanted fandoms in author pages and "All Crossovers" searches'], 'label': 'Enabled', 'labelPos': 'right', 'type': 'checkbox', 'default': true, }, 'hide_cats': { 'label': 'No Placeholder', 'labelPos': 'right', 'type': 'checkbox', 'default': false, }, 'unwanted_cats': { 'label': 'Unwanted categories (One per line, blanks lines and lines ' + 'beginning with # will be ignored):', 'title': 'One entry per line', 'type': 'textarea', 'size': 100, 'default': [ "# --== Never wanted ==-- ", "Invader Zim", "Supernatural", "Twilight", "", "# --== Not right now ==-- ", "Harry Potter & Avengers", "Naruto", ].join("\n"), }, 'unwanted_cats_escape': { 'label': 'Lines are literal strings (uncheck for regular expressions)', 'labelPos': 'right', 'title': 'NOTE: Leading/trailing whitespace is always ignored and ' + 'newlines always have OR behaviour.', 'type': 'checkbox', 'default': true, }, 'unwanted_cats_commute': { 'label': 'Automatically generate "B & A" lines from "A & B" lines', 'labelPos': 'right', 'title': "WARNING: This will break regexes with & inside () or []", 'type': 'checkbox', 'default': true, } }; var config_params = { 'id': 'ffnet_result_filter', 'title': 'Fanfiction.net Unwanted Result Filter', 'fields': fieldDefs, 'css': ( // Match Fanfiction.net styling ".section_header { background-color: #339 !important; }\n" + ".section_desc { background-color: #f6f7ee !important; }\n" + // Form layout fixes "input[type=text], textarea { width: 99%; resize: vertical; }\n" + "input[type=checkbox] { vertical-align: middle; }\n" + "#ffnet_result_filter_filter_slash_var, " + "#ffnet_result_filter_filter_cats_var, " + "#ffnet_result_filter_hide_slash_var, " + "#ffnet_result_filter_hide_cats_var " + " { display: inline-block; margin-right: 1em !important; } " + "#ffnet_result_filter_field_unwanted_cats { min-height: 10em; }"), 'events': { 'open': function(doc) { $(this.frame).css('border-color', '#d4d4d4'); $("