Greasy Fork

AO3 Publication date

Adds AO3 publication date i.e. date of publication of first chapter to AO3 search/sort page

目前为 2022-11-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         AO3 Publication date
// @namespace    https://greasyfork.org/en/scripts/455343/
// @version      1.01
// @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/*
// @grant        	none
// @license         none
// ==/UserScript==

(function ao3firstpubdate() {
    'use strict';

var html_date_heading ='&nbsp;&nbsp;&nbsp;<span style="font-size: 12px;">Date published :</span><strong><span style="font-size: 14px; color: blue;">&nbsp;';
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 + '</span></strong>&nbsp;');
                    }).fail(function() {
                        console.log('failed');
                    });


                }
            });
        }

})();