Negg Cave Solver

Adds a button to automatically copy page source, and open solution page

安裝腳本?
作者推薦腳本

您可能也會喜歡 Handy Buttons

安裝腳本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Negg Cave Solver
// @namespace   Neopets
// @match        *://www.neopets.com/shenkuu/neggcave/
// @match        *://thedailyneopets.com/articles/negg-solver/
// @version     1.1
// @author      themagicteeth
// @grant       GM_openInTab
// @grant       GM_setValue
// @grant       GM_getValue
// @description Adds a button to automatically copy page source, and open solution page
// ==/UserScript==


function makeButton(text) {
  const copyButton = document.createElement("button")  // Create the button element
  copyButton.innerText = text // Button text
  copyButton.style.margin = "0 0.5em"  // Styling for the button
  return copyButton
}

// Set onClick of button to open the link in new tab
function setOnClick(button, url) {
  button.onclick = e => {
    GM_openInTab(url)
  }
}

if (!document.URL.includes("thedailyneopets")) {
  GM_setValue("source", document.documentElement.outerHTML)
}

// Negg cave
if (document.URL.includes("neggcave")) {
  const beforeButton = document.getElementById("mnc_popup_generic_wrongdate")  // Location to place the button
  const newButton = makeButton("Get the solution!")
  beforeButton.after(newButton)
  setOnClick(newButton, "https://thedailyneopets.com/articles/negg-solver/")
}

if (document.URL.includes("negg-solver")) {
  document.getElementById("PageSourceBox").value = GM_getValue("source")
}