Greasy Fork

Greasy Fork is available in English.

AO3: Link to Entire Works

Add links to entire works right after title of story.

当前为 2017-12-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AO3: Link to Entire Works
// @namespace    http://greasyfork.icu/en/users/163551-vannius
// @version      1.0
// @description  Add links to entire works right after title of story.
// @author       Vannius
// @match       http*://archiveofourown.org/works/*
// @match       http*://archiveofourown.org/tags/*/works*
// @match       http*://archiveofourown.org/works?*
// @match       http*://archiveofourown.org/series/*
// @match       http*://archiveofourown.org/bookmarks*
// @match       http*://archiveofourown.org/users/*
// @grant        none
// ==/UserScript==

(function() {
    // Scrape data
    const articles = document.getElementsByClassName('blurb');

    for (let article of articles){
        // Scrape each article
        const titleTag = article.getElementsByClassName('heading')[0].firstChild.nextElementSibling;
        const originalHref = titleTag.href;
        const series = (originalHref.indexOf("/series/") != -1) ? true : false;

        // When article isn't series page
        if (!series){
            const chapters = article.getElementsByTagName('dl')[0].getElementsByClassName('chapters')[1].textContent.split("/");
            // When chapter number isn't one
            if (chapters[0] != '1'){
                // Make link element
                const addLink = document.createElement('a');
                addLink.href = originalHref + "?view_full_work=true";
                addLink.appendChild(document.createTextNode('E'));

                // Add link element right after title of story.
                titleTag.parentElement.insertBefore(addLink, titleTag.nextSibling);
                // Adjust placement of addLink.
                titleTag.parentElement.insertBefore(document.createTextNode(' '), addLink);
            }
        }
    }
})();