Esempio n. 1
0
def shopping_page():
    grasp(driver)
    try:
        # try:
        item = driver.find_element_by_css_selector("*.btn.btn-primary.btn-sm")
        # except NoSuchElementException:
        #     driver.refresh()
        #     shopping_page()
        global LAST_PURCHASE
        delay = (datetime.now() - LAST_PURCHASE[1]) / timedelta(microseconds=1)
        if item.tag_name == "input":  # buying from NPC store
            # if LAST_PURCHASE[0] == "NPC":
            time.sleep(max(5000000 - delay, 0) * .000001)
            # else:
            #     time.sleep(max(1000000 - delay, 0) * .000001)
            click(item)
            try:
                WebDriverWait(
                    driver,
                    15).until(lambda x: EC.title_contains("Purchasing from"))
            except:
                driver.execute_script("window.history.go(-1)")
                driver.refresh()
                shopping_page()
            LAST_PURCHASE = ("NPC", datetime.now())
        else:
            time.sleep(max(1000000 - delay, 0) * .000001)
            click(item)
            try:
                WebDriverWait(
                    driver, 15).until(lambda x: EC.presence_of_element_located(
                        (By.ID, "purchasedContainer")))
            except:
                driver.refresh()
                shopping_page()
            LAST_PURCHASE = ("user", datetime.now())

        if "Purchasing from" in driver.title:
            grasp(driver)
    except:
        driver.refresh()
        shopping_page()
Esempio n. 2
0
def doQuest(url):
    driver.get(url)
    grasp(driver)
    try:
        # driver.find_elements_by_class_name("ui message") # Doesn't work in Windows
        driver.find_elements_by_xpath("//div[@class='ui message']")
        if quest_start_page():
            quest_progress_page()
        else:
            return driver.page_source
    except Exception as e:
        print(e)
        quest_progress_page()
    # driver.get(url + "/finish")
    try:
        WebDriverWait(driver, 15).until(finish_page)
    except:
        driver.refresh()
        WebDriverWait(driver, 15).until(finish_page)
        grasp(driver)
    try:
        driver.find_element_by_xpath("//h4[contains(text(), 'Oh No!')]")
        driver.execute_script("history.back();")  # TODO: buy only missing item
        quest_progress_page()  # TODO: buy only missing item
    except NoSuchElementException:
        pass

    driver.get(url)
    grasp(driver)

    return driver.page_source
Esempio n. 3
0
def shinwa():
    driver.get("https://subeta.net/explore/goddess.php")
    WebDriverWait(driver, 15).until(EC.title_is("Temple of Shinwa - Subeta"))
    grasp(driver,
          EC.element_to_be_clickable((By.XPATH, "//input[@type='submit']")))
    try:
        click(driver.find_element_by_xpath("//input[@type='submit']"))
        WebDriverWait(driver, 15).until(
            EC.text_to_be_present_in_element((By.TAG_NAME, "h1"),
                                             "Thank you!"))
    except:
        try:
            driver.find_element_by_xpath("//a[@class='btn btn-primary']")
            pass
        except:
            return
    try:
        quest_url = driver.find_element_by_xpath("//b/a").get_attribute('href')
        doQuest(quest_url)
        shinwa()
    except Exception as e:
        return  # Shinwa finished(?)
Esempio n. 4
0
def play():
    try:
        driver.find_element_by_xpath("//input[@type='submit']").click()
        WebDriverWait(driver, 10).until(EC.title_is("Slots - Subeta"))
        grasp(driver)
    except:
        driver.get(
            f"https://subeta.net/user_shops.php/mine/{shop}/quick_stock")
        grasp(driver)
        driver.find_element_by_xpath("//button[@x-type='shop']").click()
        driver.find_element_by_xpath("//input[@type='submit']").click()
        grasp(driver)

        driver.get("https://subeta.net/games/slots.php")
        WebDriverWait(driver, 10).until(EC.title_is("Slots - Subeta"))
        grasp(driver)
Esempio n. 5
0
def camp(driver):
    driver.get(f"https://subeta.net/shop.php?shopid={id}")
    grasp(driver)
    try:
        items = driver.find_elements_by_xpath("//form[contains(@action, 'shop.php')]")
        # if budget is None:
            # elem = items[0].find_element(By.XPATH, ".//input[@class='ui image']")
        if description is not None:
            links = [x.find_element(By.XPATH, ".//input[@class='ui image']") for x in items
                     if description in x.text]
            elem = links[random.randrange(len(links))]
        elif budget is not None and budget > 0:
            links = [x.find_element(By.XPATH, ".//input[@class='ui image']") for x in items
                     if int(x.find_element(By.XPATH, ".//font/b").text.replace(",", "").split()[0]) < budget]
            elem = links[random.randrange(len(links))] # anything within budget
        #elif budget == 0:
        else:
            #links = [x.find_element(By.XPATH, ".//input[@class='ui image']") for x in
            #         sorted(items, key=lambda x:int(x.find_element(By.XPATH, ".//font/b").text.replace(",", "").split()[0]))]
            #elem = links[0] # cheapest thing
            elem = min(items, key=lambda x:int(x.find_element(By.XPATH, ".//font/b").text.replace(",", "").split()[0])).find_element(By.XPATH, ".//input[@class='ui image']") # cheapest thing
        elem.click()
        WebDriverWait(driver, 30).until( EC.title_contains('Purchasing from') )
        grasp(driver)
        source = driver.page_source
        
        if 'This item was already purchased.' in source:
            #camp(driver)
            return
        elif "You have too many items" in source:
            driver.get(f"https://subeta.net/user_shops.php/mine/{shop_id}/quick_stock")
            driver.find_element_by_xpath("//button[@x-type='wardrobe']").click()
            driver.find_element_by_xpath("//input[@value='Stock Now']").click()
            driver.execute_script("history.back();")
            driver.find_element_by_xpath("//button[@x-type='shop']").click()
            driver.find_element_by_xpath("//input[@value='Stock Now']").click()
            return
            
        while not any(x in source for x in ['Sold Out!', "You have too many items"]):
            time.sleep(5)
            driver.refresh() 
            WebDriverWait(driver, 30).until( EC.title_contains('Purchasing from') )
            grasp(driver)
            source = driver.page_source
        return
        #else:
        #    time.sleep(5)
        #camp(driver)
    except:
        time.sleep(11) # prime number so as not to line up with restock schedule
        return
Esempio n. 6
0
def load_url(s, url):
    r = s.get(url, timeout=15)
    grasp(s, r.text)
    return r.text
Esempio n. 7
0
def restart():
    driver.get(
        f"https://subeta.net/explore/healer.php?act=heal&petid={ACTIVE}")
    elem = WebDriverWait(driver,
                         10).until(EC.title_is("Healer's Abode - Subeta"))
    grasp(driver)
Esempio n. 8
0
        attempt(url, tries + 1)
    else:
        return False


def cycle(driver):
    driver.get('https://subeta.net/games/battle/quest.php/start')
    elem = WebDriverWait(driver,
                         10).until(EC.title_is("Battle Quests - Subeta"))
    grasp(driver)

    url = driver.find_element_by_xpath(
        "//a[contains(@href, 'act=battle')]").get_attribute('href')
    success = attempt(url, 0)

    if success:
        cycle(driver)
    else:
        return


driver = login()

driver.execute_script(
    'window.localStorage.setItem("sb-battle-preselect", true);')
driver.get('https://subeta.net/games/battle/quest.php/start')
elem = WebDriverWait(driver, 10).until(EC.title_is("Battle Quests - Subeta"))
grasp(driver)
cycle(driver)

driver.quit()
Esempio n. 9
0
def load_url(url, condition=None):
    driver.get(url)
    if condition:
        WebDriverWait(driver, 15).until(condition)
    grasp(driver)
Esempio n. 10
0
def play():
    try:  # Virgin start
        driver.find_element_by_link_text("Want to play?")
        driver.get(f"{URL}?act=start")
        grasp(driver)
    except:
        pass

    try:  # pairing stage
        card_links = [
            x.get_attribute('href') for x in driver.find_elements_by_xpath(
                "//a[contains(@href, '?act=pair&card')]")
        ]
        for x in card_links:
            if card_links.count(x) > 1:
                driver.get(x)
                grasp(driver)
        while "continue the game" in driver.page_source:
            driver.get(f"{URL}?act=continue")
            grasp(driver)
    except:
        pass

    try:  # blind stage
        links = [
            x.get_attribute('href') for x in driver.find_elements_by_xpath(
                "//a[contains(@href, '?act=continue')]")
        ]
        driver.get(choice(links))
        grasp(driver)
    except:
        pass

    try:  # Post-finish start
        driver.find_element_by_link_text("Play Again?")
        driver.get(f"{URL}?act=start")
        grasp(driver)
    except:
        pass

    driver.get(URL)
    grasp(driver)