LordPankake

UC Topscore

Jun 17th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         UC Topscore bot
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Automate topscoring of UC arcade games
  6. // @author       GenericSkid & Ceanko
  7. // @match        https://www.unknowncheats.me/forum/arcade.php?do=play&gameid=*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     var gameElem = $("#game_embedobj");
  13.     // check if game exists, automate score if exists
  14.     if (gameElem.length) {
  15.         var game = gameElem.attr("src").split("/")[2].split(".")[0];
  16.         var highscore = parseInt($("div.smallfont:contains('Score to Beat:')").next().text().replace(/,/g,""));
  17.         // Insert to form
  18.         var sidePanel = document.getElementById("collapseobj_gamepanel");
  19.         var form = document.createElement("form");
  20.          form.action = "https://www.unknowncheats.me/forum/index.php?act=Arcade&do=newscore";
  21.          form.method = "POST";
  22.          form.target = "_self";
  23.          form.id = "cheat_frm";
  24.         var frmName = document.createElement("input");
  25.          frmName.name = "gname";
  26.          frmName.type = "hidden";
  27.          frmName.value = game;
  28.         var frmScore = document.createElement("input");
  29.          frmScore.name = "gscore";
  30.          frmScore.type = "hidden";
  31.          frmScore.value = highscore + 1;
  32.         var frmSubmit = document.createElement("input");
  33.          frmSubmit.type = "submit";
  34.          frmSubmit.value = "Submit score";
  35.         form.appendChild(frmName);
  36.         form.appendChild(frmScore);
  37.         form.appendChild(frmSubmit);
  38.         sidePanel.appendChild(form);
  39.         // automate press button
  40.         submitScore();
  41.     } else {
  42.         // no game on page, visit next page
  43.         visitNext();
  44.     }
  45.     // function for submitting forms without redirection
  46.     function submitScore(){
  47.         $.ajax({
  48.             url:'https://www.unknowncheats.me/forum/index.php?act=Arcade&do=newscore',
  49.             type:'POST',
  50.             data:$('#cheat_frm').serialize(),
  51.             success:function(){
  52.                 visitNext();
  53.             }
  54.         });
  55.     }
  56.     // visit next page
  57.     function visitNext() {
  58.         // get gameID
  59.         var gameID = parseInt(window.location.href.split("&gameid=")[1]);
  60.         // visit next game, max game should be around 400
  61.         window.location.href = "https://www.unknowncheats.me/forum/arcade.php?do=play&gameid=" + (gameID + 1);
  62.     }
  63. })();
Advertisement
Add Comment
Please, Sign In to add comment