Remote controll a chrome extension
Project description
Selenium-Injector
- Change proxy while running (auth supported)
- remotely execute functions within a Chrome-Extension
Feel free to test my code!
Getting Started
Dependencies
- Python >= 3.7
- Chrome-Browser installed
- Selenium
Installing
- [Windows] Install Chrome-Browser
pip install selenium_injector
Example script
from selenium_profiles import driver as mydriver
from selenium_profiles.profiles import profiles
from selenium_injector.injector import mv3_injector as injector
injector = injector()
mydriver = mydriver()
profile = profiles.Windows()
profile["options"]["extensions"] = {"extension_paths": [injector.path]}
driver = mydriver.start(profile, uc_driver=False)
input("Enable proxy\n")
injector.proxy.set("host", 41149, scheme="http", username="username",password="password")
input("Disable proxy\n")
injector.proxy.clear()
input("Press ENTER to quit")
injector.stop()
driver.quit()
Don't forget to execute
driver.quit()
in the End. Else-wise your temporary folder will get flooded! and it keeps running
Change proxy while running
from selenium_injector.injector import mv3_injector as injector
injector = injector(host="localhost", port = 8001)
# initialize chrome here & load the extension
# options.add_argument("--load-extension="+injector.path) # as argument
# profile["options"]["extensions"] = {"extension_paths": [injector.path]} # selenium-profiles
injector.proxy.set("host", 41149, scheme="http", username="username",password="password") # patch_webrtc = True, patch_location=True by default
input("Disable proxy\n")
injector.proxy.clear()
Disable webrtc-ip-leak
from selenium_injector.injector import mv3_injector as injector
injector = injector()
# initialize chrome here & load the extension here
injector.webrtc_leak.disable()
injector.webrtc_leak.clear() # reset webrtc
block location api
from selenium_injector.injector import mv3_injector as injector
injector = injector()
# initialize chrome here & load the extension here
injector.contentsettings.set_location(setting="ask")
injector.contentsettings.set_location(setting="allow")# reset api policies
for all available scripts, have a look at selenium_injector/files/injector_extension/background.js
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
Deprecated
Authors
License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
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-1.1.tar.gz
(38.1 kB
view hashes)