drabble judgment

is that thing tagged drabble actually a drabble

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         drabble judgment
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  is that thing tagged drabble actually a drabble
// @author       scriptfairy
// @match        http*://archiveofourown.org/*works*
// @grant        none
// ==/UserScript==

(function($) {
    var works = $('li.blurb');
    for (i=0;i<works.length;i++) {
        var freeforms = $('li.freeforms',works[i]), wordCount = $('dd.words',works[i]).text(), chapterCount = $('dd.chapters',works[i]).text();
        wordCount = parseInt(wordCount.replace(',',''));
        chapterCount = parseInt(chapterCount.substring(0,chapterCount.indexOf('/')));
        freeforms = freeforms.filter(function(index){
            return $(this).text().search(/[Dd]rabbles?$/) != -1;
        });
        if (freeforms.length >= 1 && (wordCount/chapterCount <= 90 || (wordCount/chapterCount >= 110) && wordCount/chapterCount <= 300)) {
            $('a',freeforms[0]).text('Probably not a Drabble');
        }
        else if (freeforms.length >=1 && wordCount/chapterCount > 300 && wordCount/chapterCount <= 1000) {
            $('a',freeforms[0]).text('Not actually a Drabble');
        }
        else if (freeforms.length >=1 && wordCount/chapterCount > 1000) {
            $('a',freeforms[0]).text('NOTHING LIKE A DRABBLE');
        }
    }
})(window.jQuery);