// ==UserScript== // @name Random Story // @namespace Selbi // @include http*://*fimfiction.net/* // @version 1 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js // @description Adds a button to random jump to a story page. You need to refresh the number of stories manually. // @downloadURL none // ==/UserScript== //GM_deleteValue("storycount"); var numberofstories = GM_getValue("storycount"); var randomstory = 0; if (numberofstories == undefined) numberofstories = "Click!"; randomstory = Math.floor(numberofstories * Math.random()); $(".inner:first a:last").after('
Random Story
'); unsafeWindow.updateStoryCount = function() { $.get("//www.fimfiction.net/stories/latest", function(source) { var newstories = $(".views:first", source).attr("data-story"); if (newstories > numberofstories || newstories.length > numberofstories.length) { numberofstories = newstories; GM_setValue("storycount", numberofstories); $("#refreshstorycountButton").html('Refresh (' + numberofstories + ')'); } randomstory = Math.floor(numberofstories * Math.random()); $("#randomstoryButton").attr("href", '/story/' + randomstory); }); }