drabble judgment

is that thing tagged drabble actually a drabble

  1. // ==UserScript==
  2. // @name drabble judgment
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description is that thing tagged drabble actually a drabble
  6. // @author scriptfairy
  7. // @match http*://archiveofourown.org/*works*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function($) {
  12. var works = $('li.blurb');
  13. for (i=0;i<works.length;i++) {
  14. var freeforms = $('li.freeforms',works[i]), wordCount = $('dd.words',works[i]).text(), chapterCount = $('dd.chapters',works[i]).text();
  15. wordCount = parseInt(wordCount.replace(',',''));
  16. chapterCount = parseInt(chapterCount.substring(0,chapterCount.indexOf('/')));
  17. freeforms = freeforms.filter(function(index){
  18. return $(this).text().search(/[Dd]rabbles?$/) != -1;
  19. });
  20. if (freeforms.length >= 1 && (wordCount/chapterCount <= 90 || (wordCount/chapterCount >= 110) && wordCount/chapterCount <= 300)) {
  21. $('a',freeforms[0]).text('Probably not a Drabble');
  22. }
  23. else if (freeforms.length >=1 && wordCount/chapterCount > 300 && wordCount/chapterCount <= 1000) {
  24. $('a',freeforms[0]).text('Not actually a Drabble');
  25. }
  26. else if (freeforms.length >=1 && wordCount/chapterCount > 1000) {
  27. $('a',freeforms[0]).text('NOTHING LIKE A DRABBLE');
  28. }
  29. }
  30. })(window.jQuery);