AO3 Scroll Position Tracking

Keep your place on the stories you're reading!

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

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

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

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

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

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

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

Advertisement:

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

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

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

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

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

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

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

Advertisement:

// ==UserScript==
// @name            AO3 Scroll Position Tracking
// @description     Keep your place on the stories you're reading!
// @version         1.0.0
// @author          Anonymous
// @namespace       861ddd094884eac5bea7a3b12e074f34
// @license         MIT
// @require         https://update.greasyfork.org/scripts/583749/1856870/Scroll%20Position%20Tracking%20Library.js
// @match           https://archiveofourown.org/works/*
// @match           https://web.archive.org/web/*/https://archiveofourown.org/works/*
// @match           https://archive.today/*
// @match           https://archive.is/*
// @match           https://archive.ph/*
// @icon            https://external-content.duckduckgo.com/ip3/archive.transformativeworks.org.ico
// @run-at          document-end
// @inject-into     content
// @grant           none
// ==/UserScript==

/* Attribution
 ****************

   - Adapted from spin-drift's AO3 Bunker, itself adapted from code by jcunews
       https://greasyfork.org/en/scripts/567423-ao3-bunker
       https://www.reddit.com/r/userscripts/comments/1ayfnoh/add_scroll_position_to_url_is_this_possible/

*/

(async function () {
    'use strict';

    let CONFIG = {
        origins: [{
            host: 'archiveofourown.org',
            path: /^\/works(\/\d+(?:\/chapters\/\d+)?)/,
            params: [{ key: 'view_full_work', value: 'true' }]
        }],
        // Delay between ceasing scroll and saving position (ms)
        save_delay: 500,
        // Lifetime of individually cached scroll positions (days)
        ttl: 42,
        // Smooth-scroll to saved position on restore
        animate_restore: true,
        // Duration of the scroll animation (ms)
        animation_length: 1000,
        // Max waiting period for page height check (s)
        // https://backlinko.com/page-speed-stats
        timeout: 30,
        // Verbose logging
        debug: false,
    };

    await ScrollPositionTracker.init(CONFIG);
})();