Greasy Fork

Greasy Fork is available in English.

FastAdmin文档阅读助手

FastAdmin文档阅读助手,帮助记录上次阅读位置

当前为 2021-01-19 提交的版本,查看 最新版本

// ==UserScript==
// @name         FastAdmin文档阅读助手
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  FastAdmin文档阅读助手,帮助记录上次阅读位置
// @author       IT老猫
// @match        https://doc.fastadmin.net/developer*
// @match        https://doc.fastadmin.net/doc*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('lprequestend', (event)=> {
        localStorage.setItem('url', document.URL);
    })
    window.addEventListener('load', (event)=> {
        let url = localStorage.getItem('url');
        if (!!url) {
            if(confirm('找到上次阅读位置,是否从上次位置阅读')){
                document.location.href = url;
                localStorage.removeItem('url');
            }
        } else {
            localStorage.setItem('url', document.URL);
        }
    })
})();