diff --git a/bilibili-archive-checker.user.js b/bilibili-archive-checker.user.js index 11170b7..3b4d75e 100644 --- a/bilibili-archive-checker.user.js +++ b/bilibili-archive-checker.user.js @@ -4,7 +4,7 @@ // @description 检查 BiliBili 视频是否已经存档到 Internet Archive。 // @author yzqzss // @match https://www.bilibili.com/video/* -// @run-at document-end +// @run-at document-start // @grant GM_xmlhttpRequest // @grant unsafeWindow // ==/UserScript== @@ -12,6 +12,8 @@ (function () { 'use strict'; + const initialState = unsafeWindow.__INITIAL_STATE__; + function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } @@ -35,11 +37,11 @@ // 从 URL 获取当前视频的 BV 号 function getBVNumber() { - return unsafeWindow.__INITIAL_STATE__.bvid; + return initialState.bvid; } function getPageNumber() { - return unsafeWindow.__INITIAL_STATE__.p; + return initialState.p; } function humanReadableUpperPartMap(string, backward) { @@ -208,5 +210,5 @@ } } - main(); + document.addEventListener("DOMContentLoaded", main); })();