From cc18961fe41f57399dddf83c64e875d52cb3dfdf Mon Sep 17 00:00:00 2001 From: OverflowCat Date: Sun, 6 Aug 2023 22:36:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20support=20`Bilibili=20=E6=97=A7=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=A1=B5`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bilibili-archive-checker.user.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); })();