我看到哪里啦?!

让页面重新滚到上次阅读的位置。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        我看到哪里啦?!
// @namespace   回到上次阅读位置
// @match       *://*/*
// @grant       none
// @version     1.0
// @author      -
// @description 让页面重新滚到上次阅读的位置。
// ==/UserScript==

const scrollToBottomAndThenReTry = (d, oldPos, times=0)=>{
  if(d.scrollHeight >= oldPos){
    d.scrollTop = oldPos
    return
  }
  if(++times > 20) return
  d.scrollTop = d.scrollHeight
  window.setTimeout(()=>{
    scrollToBottomAndThenReTry(d, oldPos, times)
  }, 3000)
}

window.addEventListener('load', ()=>{
  const keyName = 'lastPosWhichISee-'+window.location.href
  const oldPos = localStorage.getItem(keyName)
  if(!oldPos) return
  const d = document.documentElement
  scrollToBottomAndThenReTry(d, oldPos)
})
window.addEventListener('scroll', ()=>{
  const keyName = 'lastPosWhichISee-'+window.location.href
  const nowPos = document.documentElement.scrollTop
  if(nowPos){
    localStorage.setItem(keyName, nowPos)
  }
})