Advertisement
Strudels

Instant Symol Hole with Quick Retry

Aug 5th, 2021 (edited)
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Instant Symol Hole with Quick Retry
  3. // @version      0.1
  4. // @author       Rippy
  5. // @match        *://www.neopets.com/medieval/symolhole.phtml
  6. // @grant        GM_setValue
  7. // @grant        GM_getValue
  8. // @require      http://code.jquery.com/jquery-latest.js
  9.  
  10. // ==/UserScript==
  11.  
  12. // mostly copying and repurposing the existing functions
  13. (function() {
  14.     'use strict';
  15.  
  16.     let symolForm = "<form method='post' id='process_symolhole' onsubmit='handleSubmit(); return false;'>" + $("#process_symolhole").html() + "<div id='attempts'></div><br /></form>";
  17.     let attempts = 0;
  18.  
  19.     handleSubmit = () => {
  20.         let goin = $("select#goin").val();
  21.         /*$.ajax({
  22.             type: 'post',
  23.             dataType: 'html',
  24.             url: '/medieval/process_symolhole_h5.phtml',
  25.             data: {type: 'wait', goin: goin},
  26.             success: function(data){
  27.                 var msg = JSON.parse(data);
  28.                 $('#symolhole-container').html(msg.start + msg.middle + msg.end);
  29.                 // insert other ajax call here if this needs to happen first
  30.             }
  31.         });*/
  32.         let count = 0;
  33.         let dots = window.setInterval(function () {
  34.             if (count > 2) {
  35.                 count = 0;
  36.                 $("#enterhole").text("   ");
  37.             } else if (count == 0) {
  38.                 $("#enterhole").text(".  ");
  39.                 count++;
  40.             } else if (count == 1) {
  41.                 $("#enterhole").text(".. ");
  42.                 count++;
  43.             } else {
  44.                 $("#enterhole").text("...");
  45.                 count++;
  46.             }
  47.         }, 300);
  48.  
  49.         $("#enterhole").attr("disabled", true);
  50.         let symolData = {};
  51.         symolData["type"] = "goin";
  52.         symolData["outfmt"] = "json";
  53.         symolData["goin"] = goin;
  54.  
  55.         $.ajax({
  56.             type: "POST",
  57.             dataType: 'html',
  58.             url: '/medieval/process_symolhole_h5.phtml',
  59.             data: symolData,
  60.             success: function (data) {
  61.                 //console.log(msg);
  62.                 clearInterval(dots);
  63.                 let msg = JSON.parse(data);
  64.                 if (msg.success) {
  65.                     attempts++;
  66.                     $('#symolhole-container').html(msg.message + symolForm);
  67.                     $('#goin').val(goin);
  68.                     $('#attempts').html(`Number of Attempts: ${attempts}<br />(Don't spam the button! Click in moderation)`);
  69.                } else {
  70.                    console.log(msg.errormsg);
  71.                }
  72.            },
  73.            error: function (e) {
  74.                //console.log(e.responseText);
  75.                alert("error");
  76.            }
  77.        }).done({
  78.            //console.log("I'm done!");
  79.        });
  80.    };
  81. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement