AO3: [Wrangling] Jump to Page!

Adds button to let you jump to a certain page of tag results!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AO3: [Wrangling] Jump to Page!
// @description  Adds button to let you jump to a certain page of tag results!
// @version      1.0.1

// @author       owlwinter
// @namespace    N/A
// @license      MIT license

// @match        *://*.archiveofourown.org/tags/*/wrangle?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const change_page = function change_page(a) {
        const old_page = new URL(window.location);
        const search = old_page.searchParams;
        search.set("page", a);
        old_page.search = "?" + search.toString();
        window.location = old_page.toString();
    }

    const nextbuttons = document.querySelectorAll("li.next");
    for (let a of nextbuttons) {
        const form = document.createElement("form")
        const textbox = document.createElement("input");
        textbox.type = "text";
        textbox.style.paddingLeft = "5px";
        textbox.style.paddingRight = "5px";
        textbox.style.marginLeft = "10px";
        textbox.style.width = "50px";
        textbox.style.textAlign = "center"
        textbox.placeholder = "Jump";
        form.appendChild(textbox)
        form.addEventListener("submit", (e) => { e.preventDefault(); change_page(textbox.value)});
        a.parentElement.appendChild(form);
    }
})();