Strudels

remove the stupid volunteer page reload

Aug 22nd, 2025
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         stop volunteer page refresh
  3. // @namespace    http://tampermonkey.net/
  4. // @version      2025-08-22
  5. // @description  ugh
  6. // @author       rippy
  7. // @match        *://*.neopets.com/hospital/volunteer.phtml*
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=neopets.com
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.     startShift = function(e) {
  15.  
  16.         let fight = e.dataset.fight;
  17.         let pet = e.dataset.pet;
  18.  
  19.         if (document.getElementById("VolunteerJoinButton").hasAttribute("disabled") || fight == "" || pet == "") {
  20.             let errMsg = fight == "" ? "You have not selected a Battle! You must first select a Battle to volunteer!" : "You must select which pet you want to volunteer!";
  21.             document.getElementById("VolunteerErrMsg").innerHTML = errMsg;
  22.             togglePopup__2020(document.getElementById("VolunteerErrorPopup"));
  23.             return;
  24.         }
  25.  
  26.         e.setAttribute("disabled", '');
  27.  
  28.         let formData = new FormData();
  29.         formData.append("_ref_ck", getCK());
  30.         formData.append("fight_id", fight);
  31.         formData.append("pet_name", pet);
  32.  
  33.         document.getElementById("VolunteerErrMsg").innerHTML = "";
  34.  
  35.         fetch("/np-templates/ajax/plots/hospital/volunteer-join.php", {
  36.             method: "POST",
  37.             headers: {"x-requested-with": "XMLHttpRequest"},
  38.             body: formData,
  39.         })
  40.             .then(
  41.                 function (response) {
  42.                     if (response.status !== 200) {
  43.                         console.log("Error setting state!");
  44.                     }
  45.  
  46.                     response.json().then(function (data) {
  47.                         if (data.success) {
  48.                             //window.location.reload();
  49.                             togglePopup__2020(document.getElementById("VolunteerJoinedPopup"));
  50.                             setFightInService(fight, data);
  51.                             showFights();
  52.                             let clock = new vcClock((data.time / 3600), 0, 0);
  53.                             intervals["fight"+fight+"Clock"] = setInterval(function() {
  54.                                 clock.tick("fight",fight);
  55.                             }, 1000);
  56.                         }
  57.                         if (data.error) {
  58.                             document.getElementById("VolunteerErrMsg").innerHTML = data.errMsg;
  59.                             togglePopup__2020(document.getElementById("VolunteerErrorPopup"));
  60.                         }
  61.                         e.removeAttribute("disabled");
  62.                     });
  63.                 }
  64.             )
  65.             .catch(function (err) {
  66.                 console.log("Fetch Error :-S", err);
  67.             });
  68.     }
  69. })();
Advertisement
Add Comment
Please, Sign In to add comment