# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'reg_gmail.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication
from selenium import webdriver
import random, os, time, requests
from threading import Thread

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(804, 616)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("E:/SCD/Python/8bcab946fdf981a1895dd54c3ff055d0.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(icon)
        self.groupBox = QtWidgets.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(10, 100, 381, 451))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.groupBox.setFont(font)
        self.groupBox.setObjectName("groupBox")
        self.lv_status = QtWidgets.QListWidget(self.groupBox)
        self.lv_status.setGeometry(QtCore.QRect(10, 20, 361, 421))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.lv_status.setFont(font)
        self.lv_status.setObjectName("lv_status")
        self.groupBox_2 = QtWidgets.QGroupBox(Dialog)
        self.groupBox_2.setGeometry(QtCore.QRect(410, 100, 381, 451))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.groupBox_2.setFont(font)
        self.groupBox_2.setObjectName("groupBox_2")
        self.lv_account = QtWidgets.QListWidget(self.groupBox_2)
        self.lv_account.setGeometry(QtCore.QRect(10, 20, 361, 421))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.lv_account.setFont(font)
        self.lv_account.setObjectName("lv_account")
        self.te_password = QtWidgets.QTextEdit(Dialog)
        self.te_password.setGeometry(QtCore.QRect(210, 10, 171, 31))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.te_password.setFont(font)
        self.te_password.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.te_password.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.te_password.setObjectName("te_password")
        self.te_api = QtWidgets.QTextEdit(Dialog)
        self.te_api.setGeometry(QtCore.QRect(210, 60, 171, 31))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.te_api.setFont(font)
        self.te_api.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.te_api.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.te_api.setObjectName("te_api")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(30, 20, 121, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(30, 70, 171, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(420, 20, 181, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.btn_changeip = QtWidgets.QPushButton(Dialog)
        self.btn_changeip.setGeometry(QtCore.QRect(650, 10, 131, 41))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.btn_changeip.setFont(font)
        self.btn_changeip.setObjectName("btn_changeip")
        self.label_4 = QtWidgets.QLabel(Dialog)
        self.label_4.setGeometry(QtCore.QRect(240, 560, 491, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(Dialog)
        self.label_5.setGeometry(QtCore.QRect(340, 590, 171, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.btn_reg = QtWidgets.QPushButton(Dialog)
        self.btn_reg.setGeometry(QtCore.QRect(650, 60, 131, 41))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.btn_reg.setFont(font)
        self.btn_reg.setObjectName("btn_reg")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

        self.btn_reg.clicked.connect(self.runprofile)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Reg Gmail by Simcongdanh"))
        self.groupBox.setTitle(_translate("Dialog", "Status"))
        self.groupBox_2.setTitle(_translate("Dialog", "Account"))
        self.label.setText(_translate("Dialog", "Password :"))
        self.label_2.setText(_translate("Dialog", "API Chothuesimcode :"))
        self.label_3.setText(_translate("Dialog", "Change Ip with Dcom :"))
        self.btn_changeip.setText(_translate("Dialog", "Change IP"))
        self.label_4.setText(_translate("Dialog", "Liên hệ : Công Danh  -   097.234.7979  - 0886.97.6789"))
        self.label_5.setText(_translate("Dialog", "Zalo : 0886.97.6789"))
        self.btn_reg.setText(_translate("Dialog", "REG"))

    def getfrofile(self):
        profile = webdriver.FirefoxProfile()
        profile.set_preference("browser.privatebrowsing.autostart", True)
        return profile

    def gerenalname(self):
        ho = {
            "Le",
            "Nguyen",
            "Ly",
            "Tran",
            "Trinh",
            "Hoai",
            "Hoang",
            "Phan",
            "Bui",
            "Do",
            "Ho",
            "Ngo",
            "Duong",
            "Huynh",
            "Pham",
            "Vo",
            "Vu",
            "Hoai"
        }
        ten_dem = {
            "van",
            "le",
            "truong",
            "to",
            "tuan",
            "huu",
            "an",
            "anh",
            "gia",
            "hoai",
            "khanh",
            "nhat",
            "minh",
            "bao",
            "cong",
            "duc",
            "dinh",
            "duy",
            "hieu",
            "khai",
            "manh",
            "vy"
        }
        ten = {
            "huan",
            "phat",
            "thien",
            "huu",
            "tien",
            "sieu",
            "ma",
            "tieu",
            "cuong",
            "loi",
            "canh",
            "tue",
            "vu",
            "dat",
            "thanh",
            "cong",
            "kiet",
            "thai",
            "phuong",
            "hoai",
            "khanh",
            "nhat",
            "minh",
            "bao",
            "cong",
            "duc",
            "dinh",
            "khai",
            "manh",
            "vy"
        }
        list_ho = list(ho)
        list_ten_dem = list(ten_dem)
        list_ten = list(ten)
        random_ho = random.choice(list_ho)
        random_ten_dem = random.choice(list_ten_dem)
        random_ten = random.choice(list_ten)
        # domains = ["@hotmail.com", "@gmail.com", "@aol.com", "@mail.com", "@mail.kz", "@yahoo.com"]
        randomemail_1 = random_ho + random_ten_dem + random_ten + str(random.randint(0, 999)) +  str(random.randint(0, 999)) +  str(random.randint(0, 999))
        return randomemail_1

    def random_lastname(self):
        ho = {
            "Le",
            "Nguyen",
            "Ly",
            "Tran",
            "Trinh",
            "Hoai",
            "Hoang",
            "Phan",
            "Bui",
            "Do",
            "Ho",
            "Ngo",
            "Duong",
            "Huynh",
            "Pham",
            "Vo",
            "Vu",
            "Hoai"
        }
        list_ho = list(ho)
        return random.choice(list_ho)

    def random_name(self):
        ten = {
            "huan",
            "phat",
            "thien",
            "huu",
            "tien",
            "sieu",
            "ma",
            "tieu",
            "cuong",
            "loi",
            "canh",
            "tue",
            "vu",
            "dat",
            "thanh",
            "cong",
            "kiet",
            "thai",
            "phuong",
            "hoai",
            "khanh",
            "nhat",
            "minh",
            "bao",
            "cong",
            "duc",
            "dinh",
            "khai",
            "manh",
            "vy"
        }
        list_ten = list(ten)
        return random.choice(list_ten)
    def getbalance(self):
        api = self.te_api.toPlainText()
        url = "https://chothuesimcode.com/api?act=account&apik=" + str(api)
        get_balance = requests.get(url).json()
        balance = get_balance["Result"]
        self.lv_status.addItem(balance)
    def get_inforapprun(self):
        url_apprun = "https://chothuesimcode.com/api?act=app&apik=" + str(self.te_api.toPlainText())
        apprun = requests.get(url_apprun).json()
        infor_apprun = apprun["Result"]
        self.lv_status.addItem(infor_apprun)
    def getnumber(self):
        url_getnumber = "https://chothuesimcode.com/api?act=number&apik=" + str(self.te_api.toPlainText()) + "&appId=1005"
        getnumber = requests.get(url_getnumber).json()
        resulf_getnumber = getnumber["Result"]
        self.lv_status.addItem(resulf_getnumber)
        number = resulf_getnumber["Number"]
        id = resulf_getnumber["Id"]
        return number, id
    def get_otp(self):
        id = self.getnumber()[-1]
        url_getotp = "https://chothuesimcode.com/api?act=code&apik=" + str(self.te_api.toPlainText()) + "&id=" + str(id)
        getotp = requests.get(url_getotp).json()
        resulf_getotp = getotp["Result"]
        self.lv_status.addItem(resulf_getotp)
        otp = resulf_getotp['Code']
        return otp
    def runprofile(self):
        browser = webdriver.Firefox(firefox_profile=self.getfrofile())
        browser.get("https://accounts.google.com/signup")
        time.sleep(1)
        last_name = self.random_lastname()
        name = self.random_name()
        username = self.gerenalname()
        password = self.te_password.toPlainText()
        browser.find_element_by_id("lastName").send_keys(last_name)
        browser.find_element_by_id("firstName").send_keys(name)
        browser.find_element_by_id("username").send_keys(username)
        browser.find_element_by_name("Passwd").send_keys(password)
        browser.find_element_by_name("ConfirmPasswd").send_keys(password)
        browser.find_element_by_id("accountDetailsNext").click()
        time.sleep(1)
        number = self.getnumber()[0]
        otp = self.get_otp()
        browser.find_element_by_id("phoneNumberId").send_keys("0" + str(number))
        browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button")

if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    Dialog = QDialog()
    ex = Ui_Dialog()
    ex.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
