Greasy Fork

lbtest

test

目前为 2025-01-05 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.cloud/scripts/522876/1515250/lbtest.js

(function() {
    'use strict';

    // 初始化 listPageDocument 变量,用于存储列表页的 document
    let listPageDocument = document;

    // 监听 URL 改变(popstate 事件)
    window.addEventListener('popstate', function(event) {
        // 当 URL 改变时,确保控制列表页的 document
        if (event.state && event.state.page === 'listPage') {
            listPageDocument = document;  // 保持列表页的 document 不变
            console.log("Returned to list page document:", listPageDocument);
        }
    });

    // 在列表页初始化时,确保通过 pushState 保存 URL 状态
    function initializeListPage() {
        if (window.location.pathname !== '/listPage') {  // 你需要根据实际 URL 判断
            window.history.pushState({ page: 'listPage' }, '', '/listPage');
        }
        listPageDocument = document; // 初始化列表页的 document
        console.log("List page initialized with document:", listPageDocument);
    }

    initializeListPage();  // 初始化列表页控制

})();