AO3 Filter Bookmarks By Length

Script to filter bookmarks based on word count. Edit min_len and max_len to taste.

目前为 2024-03-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         AO3 Filter Bookmarks By Length
// @namespace    https://greasyfork.org/en/users/296127-doleful-shades
// @version      0.1
// @description  Script to filter bookmarks based on word count. Edit min_len and max_len to taste.
// @author       dolefulshades
// @match      http://archiveofourown.org/*/bookmarks*
// @match      https://archiveofourown.org/*/bookmarks*
// @match      http://archiveofourown.org/bookmarks*
// @match      https://archiveofourown.org/bookmarks*
// @grant    none
// @license    MIT
// ==/UserScript==

// minimum length
var min_len = 0;

// maximum length
var max_len = Infinity;


(function($) {
    var works = $('.bookmarks-index .blurb:has(.stats)'); //all works
    var words = $(".bookmarks-index .blurb .stats dt:contains('Words:')"); //all "Words:" descriptors before word count
    //$(words).css('color', 'red');
    for(var i=0;i<$(works).length;i++){
        var len = $($(words)[i].nextElementSibling).text().replace(',',''); //get word count for each work
        //console.log(len);

        if (true && len < min_len||len > max_len) { //if the word count does not fall between min_len and max_len, hide the work
            //console.log('hid '+len);
            var work = $(works)[i];
            $(work).hide();
        }
    }

})(window.jQuery);