Skip to main content

inject javascript into chrome

Project description

Selenium-Injector

  • Change proxy while running (auth supported)
  • remotely contoll Chrome using websockets and extensions

Feel free to test my code!

Getting Started

Dependencies

Installing

Example scripts

click on element

from selenium_injector.webdriver import Chrome
# from selenium.webdriver import Chrome as base_driver
from undetected_chromedriver import Chrome as base_driver

driver = Chrome(base_driver=base_driver)

driver.get("https://www.wikipedia.org/")
driver.driverless.socket.exec_command("utils.find_element.ByXpath", '//*[@id="js-link-box-en"]/strong', user=driver.driverless.tab_user)

js = driver.driverless.socket.js
t = js.types
u = js.utils

try:
    prev_url = driver.current_url[:]
    driver.driverless.socket.exec(u.click_element(u.find_element_by_xpath('//*[@id="js-link-box-en"]/strong')), user=driver.driverless.tab_user, timeout=2)
except TimeoutError as e:
    # noinspection PyUnboundLocalVariable
    if driver.current_url != prev_url:
        pass
    else:
        raise e

driver.quit()

Don't forget to execute driver.quit() in the End. Else-wise your temporary folder will get flooded! and it keeps running

set proxy dynamically

from selenium_injector.webdriver import Chrome
driver = Chrome()

driver.driverless.proxy.set(host="example_host.com", port=143, password="password", username="user-1")

driver.get("https://whatismyipaddress.com/")

driver.driverless.proxy.clear()
driver.quit()

Help

Please feel free to open an issue or fork!

Todo

  • Add MV2 extension
    • change headers
  • add events
  • types.eval
    • for-loops
    • async execution
  • authentificaten proxies
    • manage webrtc-leak
    • manage locatiom api leak
    • proxy per request
  • add chrome.scripting support
  • add automation tools
    • click
    • send_keys
    • find_element
      • by XPATH

Deprecated

Authors

Aurin Aegerter

License

Shield: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

Disclaimer

I am not responsible what you use the code for!!! Also no warranty!

Acknowledgments

Inspiration, code snippets, etc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selenium_injector-2.0.tar.gz (14.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page