[osu!]Sayobot's 鏡像站 存檔當(dāng)前頁碼 跳轉(zhuǎn)頁面(自用備份)

以前經(jīng)常在鏡像站找譜下,一找就是幾十頁。但是下一次進(jìn)來的時(shí)候又是從第一頁開始了(我在鏡像站沒有找到類似頁碼或者能跳到指定頁碼的功能)。最后研究了一下可以通過修改offset值快速到之前自己瀏覽的頁數(shù)。?有愛自取,順便我也存?zhèn)€檔。
offset值獲取途徑:
1.自己看最后一次的/post 請(qǐng)求中的參數(shù) 自行通過記事本保存
2. 點(diǎn)下存檔offset值按鈕
食用:輸入offset值,點(diǎn)擊設(shè)置按鈕,再點(diǎn)原網(wǎng)站的下一頁功能即可到之前瀏覽的地方。

// ==UserScript==
// @name? ? ? ? ?Sayobot跳轉(zhuǎn)
// @namespace? ? http://tampermonkey.net/
// @version? ? ? 0.1
// @description? Jump Jump
// @author? ? ? ?bladek
// @match? ? ? ? https://osu.sayobot.cn/home
// @run-at? ? ? ?document-start
// @require? ? ? https://scriptcat.org/lib/637/1.3.1/ajaxHooker.js
// @grant? ? ? ? unsafeWindow
// ==/UserScript==
(function () {
? ? console.log('加載腳本');
? let saveOffset = localStorage.getItem("my-offset") || 0;
? let saveFlag = false;
? let nowOffset = 0;
? let previewSongsList = [];
? let nowPlayIndex = 0;
? ? ajaxHooker.hook(request => {
? ? if (request.url === 'https://api.sayobot.cn/?post' && request.method == 'POST' ) {
? ? ? const sendResult = JSON.parse(request.data) || {};
? ? ?console.log(request.data)
? ? ?console.log(sendResult)
? ? ? nowOffset = sendResult.offset;
? ? ? nowOffsetDom.innerText = nowOffset;
? ? ? if(saveFlag) {
? ? ? ? ? console.log("flag enter")
? ? ? ? ? sendResult.offset = saveOffset - 0;
? ? ? ? ? console.log(JSON.stringify(sendResult))
? ? ? ? ? request.data =? JSON.stringify(sendResult)
? ? ? ? ? saveFlag = false;
? ? ? }
? ? }
});
? const divStr = `
? ? ? ?<div class="temp" style="position: fixed;
? ? ? ?z-index: 9999;
? ? ? ?right: 40px;
? ? ? ?top: 250px;
? ? ? ?width: 293px;
? ? ? ?height: 137px;
? ? ? ?border: 1px solid red;
? ? ? ?display:flex;
? ? ? ?justify-content:center;
? ? ? ?align-items:center;
? ? ? ?flex-direction:column;"
? ? ? ?>
? ? ? ?<audio id="myAudio"></audio>
? ? ? ?<p id="title" style="user-select: inherit;"></p>
? ? ? ?<div>
? ? ? ?<button id="next" onclick="play('prev')">下一首</button>
? ? ? ?<button id="prev" onclick="play('next')">上一首</button>
? ? ? ?<button id="save">存檔目前Offset值</button>
? ? ? ?</div>
? ? ? ?<div style="display:flex"><span>修改Offset:</span><input type="text" id="offsetValue" value="${saveOffset}"/><button id="setOffset">設(shè)置!</button></div>
? ? ? ?<p>當(dāng)前偏差值:<span id="nowOffset">${nowOffset}</span></p>
? ? ? ?</div>
? ? `;
? const div = document.createElement("div");
? div.innerHTML = divStr;
? document.body.append(div);
? const audio = document.getElementById("myAudio");
? const title = document.getElementById("title");
? const save = document.getElementById("save");
? const setOffset = document.getElementById("setOffset");
? const nowOffsetDom = document.getElementById("nowOffset");
? const play = (action) => {
? ? const { previewLink, title: songTitle } = previewSongsList[nowPlayIndex];
? ? audio.src = previewLink;
? ? title.innerText = songTitle;
? ? if (action == "next") {
? ? ? nowPlayIndex++;
? ? } else {
? ? ? if (nowPlayIndex > 1) {
? ? ? ? nowPlayIndex--;
? ? ? }
? ? }
? ? console.log(previewSongsList);
? ? console.log(nowPlayIndex);
? ? audio.play();
? };
? save.addEventListener("click", () => {
? ? localStorage.setItem("my-offset", nowOffset);
? });
? setOffset.addEventListener("click", () => {
? ? saveOffset =? document.getElementById('offsetValue').value;
? ? nowOffset = saveOffset;
? ? saveFlag = true;
? ? ? alert("設(shè)置完成!")
? });
})();