Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package easyxyzspammer;
- import com.gargoylesoftware.htmlunit.BrowserVersion;
- import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
- import com.gargoylesoftware.htmlunit.SilentCssErrorHandler;
- import com.gargoylesoftware.htmlunit.WebClient;
- import com.gargoylesoftware.htmlunit.html.DomElement;
- import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
- import com.gargoylesoftware.htmlunit.html.HtmlButton;
- import com.gargoylesoftware.htmlunit.html.HtmlButtonInput;
- import com.gargoylesoftware.htmlunit.html.HtmlInput;
- import com.gargoylesoftware.htmlunit.html.HtmlPage;
- import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import static java.lang.Thread.sleep;
- import java.util.ArrayList;
- import java.util.Random;
- import java.util.logging.Level;
- import javax.swing.JOptionPane;
- public class EasyXyzSpammer {
- static ArrayList<String> allNames = new ArrayList<>();
- static ArrayList<HtmlPage> allSetupNamePages = new ArrayList<>();
- static ArrayList<HtmlPage> allOnGamePages = new ArrayList<>();
- public static void main(String[] args) throws Exception {
- String gameId = JOptionPane.showInputDialog("Enter Game Id");
- final String SIGNINPAGELINK = "https://pyx-1.pretendyoure.xyz/zy/game.jsp#game="+gameId;
- java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
- System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
- //load name array
- String testName;
- Random rand = new Random();
- int randomNameNum = 0;
- String nameUsed = "";
- boolean eof = false;
- try {
- BufferedReader reader = new BufferedReader(new FileReader("src/easyxyzspammer/names.txt"));
- while(!eof) {
- testName = reader.readLine();
- if(testName != null) {
- allNames.add(testName);
- } else {
- eof = true;
- System.out.println("Loaded Name Array, Continuing Program...");
- }
- }
- } catch (IOException e) {
- System.out.println("IO Exception Caught: " + e);
- }
- try (final WebClient xyzClient = new WebClient(BrowserVersion.BEST_SUPPORTED)) {
- xyzClient.getOptions().setThrowExceptionOnScriptError(false);
- xyzClient.setJavaScriptTimeout(10000);
- xyzClient.getOptions().setJavaScriptEnabled(true);
- xyzClient.getOptions().setThrowExceptionOnScriptError(false);
- xyzClient.getOptions().setCssEnabled(false);
- xyzClient.setAjaxController(new NicelyResynchronizingAjaxController());
- xyzClient.getOptions().setTimeout(10000);
- xyzClient.setCssErrorHandler(new SilentCssErrorHandler());
- for(int j = 0; j < 20; j++) {
- System.out.println("Run: " + j + "\n ");
- randomNameNum = rand.nextInt(allNames.size()) + 0;
- allSetupNamePages.add(xyzClient.getPage(SIGNINPAGELINK));
- HtmlInput setNickname = allSetupNamePages.get(j).getHtmlElementById("nickname");
- xyzClient.waitForBackgroundJavaScriptStartingBefore(100);
- setNickname.reset();
- setNickname.type(allNames.get(randomNameNum));
- nameUsed = allNames.get(randomNameNum);
- xyzClient.waitForBackgroundJavaScriptStartingBefore(300);
- System.out.println("Set Nickname Successfully!, Continuing To Game Page...");
- HtmlButtonInput goToGamePageButton = allSetupNamePages.get(j).getHtmlElementById("nicknameconfirm");
- allOnGamePages.add(goToGamePageButton.click());
- xyzClient.waitForBackgroundJavaScript(200);
- System.out.println("Joined Game: " + gameId + " With Name: " + nameUsed + " Successfully!\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement