// ==UserScript== // @name Fanfiction.net - Customize Default Result Filter // @namespace ssokolow.com // @description Override Fanfiction.net's default choices for result filters // @version 1 // @license MIT // // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // // @noframes // @match *://www.fanfiction.net/* // @downloadURL none // ==/UserScript== // TODO: Try to find a way to safely URL-match so I can minimize the number // of cases where I need to redirect and use @run-at document-start // for the rest. var has_filters = document.getElementById('filters') !== null; var preferred_filter = GM_getValue('preferred_filter'); if (preferred_filter && window.location.search === "" && has_filters) { window.location.search = preferred_filter; } if (has_filters) { GM_registerMenuCommand("Save Current Filters as Default", function() { GM_setValue('preferred_filter', window.location.search); }, 'S'); }