// ==UserScript== // @name AO3 Publication date // @namespace https://greasyfork.org/en/scripts/455343/ // @version 1.2 // @description Adds AO3 publication date i.e. date of publication of first chapter to AO3 search/sort page // @author MM // @match https://archiveofourown.org/tags/* // @match https://archiveofourown.org/works?commit=Sort+and+Filter* // @grant none // @license none // @downloadURL none // ==/UserScript== (function ao3firstpubdate() { 'use strict'; var html_date_heading ='   Date published : '; if(jQuery('.header h4.heading').length) { // Near as I can figure, the best way of identifying actual stories in an index page is with the h4 tag with class 'heading' within a list of type 'header' jQuery('.header h4.heading').each(function() { var sStoryPath = jQuery(this).find('a').first().attr('href'); var oHeader = this; // If link is from collections, get proper link var aMatch = sStoryPath.match(/works\/(\d+)/); if(aMatch !== null) { var iStoryId = aMatch[1]; jQuery.get('https://archiveofourown.org/works/' + iStoryId, function(oData) { var status = jQuery(oData).find('dd.published').text(); //console.log(status); jQuery(oHeader).append(html_date_heading + status + ' '); }).fail(function() { console.log('failed'); }); } }); } })();