Neopets: Books Checklist

Adds a button to check which books still need to be read. Includes both Book Club and Booktastic Books.

安裝腳本?
作者推薦腳本

您可能也會喜歡 Neopets: Gourmet food checklist

安裝腳本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Neopets: Books Checklist
// @author       Tombaugh Regio
// @version      1.0
// @description  Adds a button to check which books still need to be read. Includes both Book Club and Booktastic Books.
// @namespace    https://greasyfork.org/users/780470
// @match        http://www.neopets.com/books_read.phtml?pet_name=*
// @match        http://www.neopets.com/moon/books_read.phtml?pet_name=*
// @match        https://items.jellyneo.net/tools/book-checklist/
// @match        https://items.jellyneo.net/tools/booktastic-checklist/
// @grant        GM_openInTab
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

const URL = document.URL

if (URL.includes("books_read")) {
    const title = document.querySelector(".content").querySelector("b")

    //Add a book checker button
    const priceCheckerButton = document.createElement("button")
    const priceCheckerLink = document.createElement("a")
    priceCheckerButton.innerText = "Check to-read list"
    priceCheckerButton.style.margin = "0 0.5em"
    priceCheckerButton.style.cursor = "pointer"

    //Save the page's entire HTML and open the book checker page
    priceCheckerButton.onclick = e => {
        e.preventDefault()
        const HTML = new XMLSerializer().serializeToString(document)

        let link
        if (URL.includes("moon")) link = "https://items.jellyneo.net/tools/booktastic-checklist/"
        else link = "https://items.jellyneo.net/tools/book-checklist/"

        GM_setValue("copiedHTML", HTML)
        GM_openInTab(link)
    }

    //Append button after title
    title.after(priceCheckerButton)
}

if (URL.includes("jellyneo")) {
    const inputTextArea = document.querySelector("#checklist-code")
    const priceCheckButton = document.querySelector("#checklist-submit")
    const copiedHTML = GM_getValue("copiedHTML")

    inputTextArea.textContent = copiedHTML

    if (inputTextArea.textContent.length > 0) priceCheckButton.click()
}