// ==UserScript== // @name Fanfiction.net Latest Chapter Links // @namespace http://rephrase.net/box/user-js/ // @description Make fanfiction.net list pages (inc. C2s, author pages etc.) link to latest chapters // @include *fanfiction.net/(anime|game|book|misc|cartoon|movie|comic|tv)/* // @include *fanfiction.net/l/* // @include *fanfiction.net/u/* // @include *fanfiction.net/community/* // @include *fanfiction.net/~* // ==/UserScript== (function(){ /* Part one: replace story rows in active window */ var latest_link = function(whole, context, sid, sname, latest, words) { var o; var word_count = words.replace(",", "") var words_per_chapter = Math.floor(word_count/latest) o = context o += "Chapters: " + latest + "" o += " Words: " + words + " (~" + words_per_chapter + ")" return o } document.documentElement.innerHTML = document.documentElement.innerHTML.replace( /(href=["']\/s\/([0-9]+)\/(.*?)["'][\s\S]*?)Chapters: ([0-9]+) - Words: ([0-9,]+)/mg, latest_link); /* Part two: replace the storylist_render function so dynamic sorts get the right stuff -- use this byzantine injection method to avoid touching unsafeWindow. */ function wrapper(){ window.storylist_render = function(story_array,startrow,show_cat,show_author) { var buffer = []; var story; var words_per_chapter; for(var i = story_array.length, c = startrow; i>0; i--, c++){ story=story_array[i-1]; buffer[buffer.length] = c + ". "; buffer[buffer.length] = story.stitle + " "; if (show_author==1) buffer[buffer.length] = "by "+story.penname+" "; if (story.ratingtimes>0) buffer[buffer.length] = "reviews"; buffer[buffer.length]="
"+story.summary+""; } return buffer.join(""); }; /* Fixes an issue caused by part 1. */ document.documentElement.style.fontFamily = myfontstyle; document.documentElement.style.fontSize = myfontsize + 'px'; }; /* Attach to window. */ var newscript = document.createElement("script"); newscript.type = "text/javascript"; newscript.appendChild(document.createTextNode(wrapper.toSource() + "; wrapper();")); document.documentElement.appendChild(newscript); }());
"; if (show_cat == 1) buffer[buffer.length] = story.category+" - "; buffer[buffer.length] = array_censors[story.censorid]+" - "; buffer[buffer.length] = array_languages[story.languageid]+" - "; if(story.genreid > 0) { buffer[buffer.length] = array_genres[story.genreid]; if(story.subgenreid > 0) { buffer[buffer.length] = "/"+array_genres[story.subgenreid]; } } else if(story.subgenreid > 0){ buffer[buffer.length] = array_genres[story.subgenreid]+" - "; } words_per_chapter = Math.floor(story.wordcount / story.chapters) buffer[buffer.length] = " - Chapters: " + story.chapters + " - Words: "+story.wordcount+" (~"+words_per_chapter+") - Reviews: "+story.ratingtimes+" - Updated: "+story.dateupdatetext+" - Published: "+story.datesubmittext+"