Skip to content

Commit

Permalink
script v1 with pyderman
Browse files Browse the repository at this point in the history
  • Loading branch information
jromerooo2 committed Dec 19, 2022
1 parent 50cc215 commit 6f851d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion adblocker.py
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
import random
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
import selenium.webdriver.support.ui as ui
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
import pyderman

driverpath = pyderman.install(browser=pyderman.chrome)
driver = webdriver.Chrome(driverpath)

driver.maximize_window()
weburl = "https://www.youtube.com"
driver.get(weburl)

wait = ui.WebDriverWait(driver, 3000)

while True:
try:
if EC.presence_of_element_located((By.XPATH,".//div/div/div/div/div/span/button/div[contains(text(),'Skip Ad')]")):
button = driver.find_element(By.XPATH, ".//div/div/div/div/div/span/button/div[contains(text(),'Skip Ad')]")
driver.execute_script("arguments[0].click();", button)
print("ad skipped")
time.sleep(2)
else:
continue

except NoSuchElementException:
print("no element detected")
time.sleep(2)
Binary file added lib/chromedriver_108.0.5359.71
Binary file not shown.

0 comments on commit 6f851d9

Please sign in to comment.