[Neopets] Grave Danger Random Diver

Adds a button that sends a random petpet off to the catacombs, without any equipment.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         [Neopets] Grave Danger Random Diver
// @namespace    https://greasyfork.org/en/scripts/487970
// @version      0.4
// @description  Adds a button that sends a random petpet off to the catacombs, without any equipment.
// @author       Piotr Kardovsky
// @match        https://www.neopets.com/halloween/gravedanger/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=neopets.com
// @grant        none
// @license      MIT
// @require      http://code.jquery.com/jquery-latest.min.js
// @run-at       document-end
// ==/UserScript==
var $ = window.jQuery;

const GDU = "https://www.neopets.com/halloween/gravedanger/";

(function() {
    'use strict';
    let pname = null;
    let doAgain = () => {
            $.post(GDU, {'again':'1'}, (r) => {
                let match = r.match(/(petpets: \{"[\s\S]+"\}),/)[0];
                match = "{\"petpets\"" + match.substring(7, match.length-1) + "}";
                let getGD = JSON.parse(match);
                let pArr = Object.keys(getGD.petpets);
                pname = pArr[Math.floor(Math.random() * (pArr.length - 1) + 1)];
                //console.log(pArr, pname);
                setTimeout( () => {
                    $.post(GDU, {'neopet':pname, 'equipped':"0"}, (m) => { location.reload(); });
                }, Math.floor(Math.random() * 400 + 600))
            });
    }

    let rndAgn = $('<button/>').addClass('button-default__2020 button-blue__2020 rndAgnBtn').css({'margin':'0px auto', 'width':'50%'}).text('Dive again with a random Petpet!').on('click', (e) => { e.preventDefault(); doAgain(); });

    $(document).ready(() => {
        $('#gdSelection .select:contains("Choose a Petpet!")').before(rndAgn);
        $('.gdForm').prepend($('<br/>'),rndAgn.clone(true, true));
    });
})();