Strudels

Shop Wizard Beta Refresh

Apr 30th, 2022
1,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Shop Wizard Beta Refresh
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  make beta sw less bad i guess
  6. // @author       Rippy
  7. // @match        *://www.neopets.com/shops/wizard.phtml*
  8. // @grant        none
  9. // @require      http://code.jquery.com/jquery-latest.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     let shopwizard, table, criteria, min_price, max_price;
  16.  
  17.     function submitSearch() {
  18.         if (!shopwizard)
  19.             return;
  20.         $("#refreshresults").css({ opacity: 0 }); // simple visual indicator of loading without actually removing the element so the form results don't keep jumping up and down
  21.         document.getElementById("refreshresults").removeEventListener("click", submitSearch);
  22.         $.ajax({
  23.             type: "POST",
  24.             url: "/np-templates/ajax/wizard.php",
  25.             dataType: "html",
  26.             data: {
  27.                 "type": "process_wizard",
  28.                 "feedset":0,
  29.                 "shopwizard": shopwizard,
  30.                 "table": table,
  31.                 "criteria": criteria,
  32.                 "min_price": min_price,
  33.                 "max_price": max_price
  34.             },
  35.             success: function(response) {
  36.                 $("#shopWizardFormResults").html(response);
  37.                 $("#refreshresults").css({ opacity: 1 });
  38.                 document.getElementById("refreshresults").addEventListener("click", submitSearch);
  39.             },
  40.             error: function() {
  41.                 alert("Error");
  42.             }
  43.         });
  44.     };
  45.  
  46.  
  47.     const div = document.createElement("div");
  48.     div.setAttribute("id", "divRefresh");
  49.     div.innerHTML = '<br /><input id="refreshresults" class="button-default__2020 button-blue__2020  wizard-button__2020" type="submit" value="Resubmit" data-ajaxgenerated="yes">';
  50.     $("#pageDesc").append(div);
  51.     $("#divRefresh").hide();
  52.     document.getElementById("refreshresults").addEventListener("click", submitSearch);
  53.  
  54.     $("#submit_wizard").click(() => {
  55.         $("#divRefresh").show();
  56.         shopwizard = $("#shopwizard").val(),
  57.         table = $("#wizard-area option:selected").val(),
  58.         criteria = $("#criteria option:selected").val(),
  59.         min_price = $("#min_price").val(),
  60.         max_price = $("#max_price").val();
  61.     });
  62.     $("#criteria").val("exact");
  63. })();
Advertisement
Add Comment
Please, Sign In to add comment