Greasy Fork is available in English.

AO3: Links for Entire Works

Add links to next and previous chapter to Entire Works of AO3.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         AO3: Links for Entire Works
// @namespace    https://greasyfork.org/en/users/163551-vannius
// @version      1.5
// @license      MIT
// @description  Add links to next and previous chapter to Entire Works of AO3.
// @author       Vannius
// @match        https://archiveofourown.org/works/*view_full_work=true*
// @grant        none
// ==/UserScript==

(function() {
    // get id="chapter-[d]+" tags
    let chapters = [];
    let index = 1;
    while (true) {
        const chapter = document.getElementById('chapter-' + index);
        if (chapter) {
            chapters.push(chapter);
            index += 1;
        } else {
            break;
        }
    }

    for (let i = 0; i < chapters.length; i++) {
        // Display add links to right of each chapter title.
        const rightSpan = document.createElement('span');
        rightSpan.style.float = 'right';

        // Make a link to current chapter
        if (i === 0) {
            const currentChapter = document.createElement('a');
            currentChapter.title = "Current chapter";
            currentChapter.href = "#chapter-" + (i + 1);
            currentChapter.appendChild(document.createTextNode('◆'));
            rightSpan.appendChild(currentChapter);
        }
        // Make a link to prev chapter
        if (i !== 0) {
            const prevChapter = document.createElement('a');
            prevChapter.title = "Previous chapter";
            prevChapter.href = "#chapter-" + i;
            prevChapter.appendChild(document.createTextNode('▲'));
            rightSpan.appendChild(prevChapter);
        }
        // Make a link to next chapter
        if (i != chapters.length - 1) {
            const nextChapter = document.createElement('a');
            nextChapter.title = "Next chapter";
            nextChapter.href = "#chapter-" + (i + 2);
            nextChapter.appendChild(document.createTextNode('▼'));
            rightSpan.appendChild(nextChapter);
        }
        // Make a link to current chapter
        if (i == chapters.length - 1) {
            const currentChapter = document.createElement('a');
            currentChapter.title = "Current chapter";
            currentChapter.href = "#chapter-" + (i + 1);
            currentChapter.appendChild(document.createTextNode('◆'));
            rightSpan.appendChild(currentChapter);
        }

        // Add links
        chapters[i].querySelector(".chapter .title").appendChild(rightSpan);
    }
})();