AO3: Shake Prompt Fill

Adds a button to shake an unrevealed fill in a collection

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AO3: Shake Prompt Fill
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @license     MIT
// @description  Adds a button to shake an unrevealed fill in a collection
// @author       Jamez
// @match        *://*.archiveofourown.org/collections/*/requests
// @match        *://*.archiveofourown.org/collections/*/signups/*
// @icon         http://archiveofourown.org/favicon.ico
// @grant        none
// ==/UserScript==
(function($) {
    $(document).ready(function() {
        if (!$('body').hasClass('logged-in')) { return; }

        var base_url = "https://archiveofourown.org/collections/$COLLECTION$/works?commit=Sort+and+Filter&work_search%5Bquery%5D=id%3A$ID$";

        $('.index.group li.work').each(function() {
            var workElement = $(this);
            var workIdMatch = workElement.attr('id').match(/work_(\d+)/);
            if (workIdMatch) {
                var workId = workIdMatch[1];
                var mysteryCheck = workElement.find('div.mystery');
                if (mysteryCheck.length > 0) {
                    var collectionElement = workElement.find('h5 a');
                    if (collectionElement.length > 0) {
                        var collectionName = collectionElement.attr('href').split("/")[2];
                        var workUrl = base_url.replace("$COLLECTION$", collectionName).replace("$ID$", workId);

                        var button = $('<a>', {
                            text: 'Shake Fill',
                            href: workUrl,
                        });

                        var actions = workElement.find('.actions');
                        if (actions.length) {
                            actions.append(button);
                        } else {
                            workElement.append(button);
                        }
                    }
                }
            }
        });
    });
})(window.jQuery);