Last active
July 1, 2019 02:49
-
-
Save pxpc2/8eb6dc2d56fc8d601df6 to your computer and use it in GitHub Desktop.
criando um script pra aumentar visualizações de perfil no powerbot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pedro.url; | |
import javax.swing.*; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLConnection; | |
public class ProfileViews { | |
public static String myProfile; | |
public static boolean connecting = false; | |
public static boolean connect(final String url) { | |
try { | |
final URL leUrl = new URL(url); | |
URLConnection leConnection = | |
leUrl.openConnection(); | |
leConnection.connect(); | |
Thread.sleep(leConnection.getConnectTimeout()); | |
if (leConnection.getContent() != null) { | |
final HttpURLConnection con = | |
(HttpURLConnection) | |
leConnection; | |
if (con.getContent() != null) { | |
con.disconnect(); | |
return true; | |
} | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return false; | |
} | |
public static void main(String[] args) { | |
myProfile = JOptionPane.showInputDialog( | |
"Enter with your profile link" | |
); | |
if (myProfile != null && myProfile.length() > 0) { | |
connecting = true; | |
} | |
if (connecting) { | |
final Thread t = new Thread(new LeThread()); | |
t.run(); | |
final Thread l = new Thread(new LeChecker()); | |
l.run(); | |
} | |
} | |
private static class LeThread implements Runnable { | |
public void run() { | |
if (ProfileViews.connecting) { | |
connect(myProfile); | |
} | |
} | |
} | |
private static class LeChecker implements Runnable, KeyListener { | |
public boolean pressed = false; | |
public void keyTyped(KeyEvent e) { | |
} | |
public void keyPressed(KeyEvent e) { | |
final int key = e.getKeyCode(); | |
if (key == KeyEvent.VK_ESCAPE) { | |
pressed = true; | |
JOptionPane.showMessageDialog(null, "Stopping the connections!"); | |
} | |
} | |
public void keyReleased(KeyEvent e) { | |
} | |
public void run() { | |
if (pressed) { | |
ProfileViews.connecting = false; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment