Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add Extension to chrome V2 #154

Closed
canonsky1992 opened this issue Apr 25, 2021 · 24 comments
Closed

Cannot add Extension to chrome V2 #154

canonsky1992 opened this issue Apr 25, 2021 · 24 comments

Comments

@canonsky1992
Copy link

chrome_options = Options()
chrome_options.add_argument('user-data-dir='+profiles[i])
chrome_options.add_extension('data/exten.crx')
driver = uc.Chrome(options=chrome_options)
Why v2 cannot add extension?

@rnyPlanet
Copy link

@ultrafunkamsterdam hi thanks for chromedriver. I also cannot add an extension. Is this a bug? @ultrafunkamsterdam extensions work for you?

@ultrafunkamsterdam
Copy link
Owner

No. Extensions do not work in combination with remote debugging (which is used by this module).

@rnyPlanet
Copy link

got it. maybe there is some way out to add auth proxy? (I tried seleniumwire - there is a problem with mitmproxy that changes fingerprint and cloudflare returns 503 error. I also thought about an extension that would help with a proxy - but remote debugging does not work with the extension). you have more knowledge - is there any way out? v2 works fine, but damn I need to work with auth proxy

@ultrafunkamsterdam
Copy link
Owner

Fingerprint is not a network thing so mitm proxy wouldn't change it. That's for sure 😉

@rnyPlanet
Copy link

well i don't have enough knowledge, and i read this there mitm and selenium-wire.

@rnyPlanet
Copy link

rnyPlanet commented May 9, 2021

no solutions at all?( What happens if remove remote debugging? won't bypass cloudflare? (remove for the ability to install extensions with auth proxy)

@rnyPlanet
Copy link

@ultrafunkamsterdam Sorry to bother you, I guess I'm already bored you) I found a couple of possibilities 1 and 2 (use --load-extension to load the extension for the remote debugging browser, this line with arguments), I tried but got an error ERR_SOCKS_CONNECTION_FAILED. I wanted to ask if you tried this? if not, is there a chance that it will help?

@ultrafunkamsterdam
Copy link
Owner

You can definitly add extensions. But you'll need a steady profile as extensions are kept in the profile.

image

@the-white-light
Copy link

I've managed to load extensions by extracting the CRX file into a folder and then using --load-extension.

@vancouverjackluo
Copy link

I've managed to load extensions by extracting the CRX file into a folder and then using --load-extension.

Hello @the-white-light , can you elaborate how you approached it with --load-extension?
I have the following code, doesn't work:
options.add_argument('--load-extension = C:\Code\project_MP\ABC.crx')

@vancouverjackluo
Copy link

Can you kindly explain in detail how this works? a sample code will be much appreciated.

Thanks

@the-white-light
Copy link

the-white-light commented Dec 25, 2021

You had it mostly right, but as I said before you need to extract the extension first, then direct the code to the destination folder.

I extracted the .crx file to ./MultiPass and then did opt.add_argument('--load-extension=./MultiPass')

@vancouverjackluo
Copy link

vancouverjackluo commented Dec 25, 2021

You had it mostly right, but as I said before you need to extract the extension first, then direct the code to the destination folder.

I extracted the .crx file to ./MultiPass and then did opt.add_argument('--load-extension=./MultiPass')

@the-white-light yes, I have extracted the extension into .crx file and saved in the same directory(folder):
options.add_argument('--load-extension = ./ABC.crx')

tried it...still doesn't work. Here is my entire code:

import undetected_chromedriver as uc
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

def main():
options = uc.ChromeOptions()
options.add_argument("--no-sandbox --no-first-run --no-service-autorun --password-store=basic")
driver = uc.Chrome(options=options)
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_argument('--load-extension = ./abc.crx')

if name == 'main':
main()

@the-white-light
Copy link

the-white-light commented Dec 25, 2021

Please re-read what I wrote. You need to extract the crx, and it is not used in the code. You downloaded the crx file, which is basically just a zip file. Extract it then point your code to the destination folder.

@vancouverjackluo
Copy link

Please re-read what I wrote. You need to extract the crx, and it is not used in the code. You downloaded the crx file, which is basically just a zip file. Extract it then point your code to the destination folder.

did that.

@the-white-light
Copy link

  1. No you didn't. You still are using the crx file in your code, see the line I posted — no crx.
  2. You added it to options after initializing the chromedriver, it needs to be before the driver = line.

@vancouverjackluo
Copy link

2. er initializing the chro

@the-white-light thanks, my mistake. does the .crx file needs to be the only file in the subfolder?

@the-white-light
Copy link

No, you just extract it into a folder and point your code to that.

@vancouverjackluo
Copy link

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else

image

@90xboy
Copy link

90xboy commented Dec 27, 2021

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else

image

hey mate, did you solve this error? i also can not add extension.

@dafriyie
Copy link

dafriyie commented Jan 13, 2022

I know it's late to add this comment but it might help someone in the future. When you extract the extension, point your code to the full path of the extracted folder like C:\Users\yourproject\extension It worked for me!!!

@ribonred
Copy link

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else
image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this..
try download the extension as zip.. then extract to some folder

then you can
options.add_argument('--load-extension = ./extraction_folder')

should not .crx file

@90xboy
Copy link

90xboy commented Jan 30, 2022

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else
image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this.. try download the extension as zip.. then extract to some folder

then you can options.add_argument('--load-extension = ./extraction_folder')

should not .crx file

hi mate, i can kindly share a sample code, i try but still get error. I newbie in python selenium, tks for your help
Here my code:
from selenium.webdriver.common import keys
import undetected_chromedriver.v2 as uc
import time
if name == 'main':
options = uc.ChromeOptions()
options.add_argument("--disable-notifications")
options.add_argument('--load-extension =C:\python\myproject\Extract file') # extract file zip to directory
# setting profile
options.user_data_dir = "c:\temp\profile18"
driver = uc.Chrome(options=options,version_main=97)
time.sleep(2)
input('ok')

@ribonred
Copy link

ext
├── pass
│   ├── 47a1591dea3b6d1f42f9b3cd0673f69c.svg
│   ├── background.js
│   ├── icons
│   │   ├── 128
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   ├── 32
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   ├── 48
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   └── 64
│   │       ├── gold.png
│   │       └── grey.png
│   ├── manifest.json
│   ├── popup.css
│   ├── popup.html
│   └── popup.js
└── solver
    ├── content
    │   ├── hcaptcha.js
    │   ├── model.js
    │   └── tf.js
    ├── images
    │   ├── icon_128.png
    │   ├── icon_16.png
    │   ├── icon_32.png
    │   └── icon_48.png
    ├── manifest.json
    ├── model
    │   ├── group1-shard1of5
    │   ├── group1-shard2of5
    │   ├── group1-shard3of5
    │   ├── group1-shard4of5
    │   ├── group1-shard5of5
    │   └── model.json
    └── worker.js

ext is root folder of extension.. inside ext folder pass and solver are extracted extension
then load the extension like this

options.add_argument('--load-extension=./ext/solver,./ext/pass')

i use 2 extension here, so is separated by coma in argument

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else
image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this.. try download the extension as zip.. then extract to some folder
then you can options.add_argument('--load-extension = ./extraction_folder')
should not .crx file

hi mate, i can kindly share a sample code, i try but still get error. I newbie in python selenium, tks for your help Here my code: from selenium.webdriver.common import keys import undetected_chromedriver.v2 as uc import time if name == 'main': options = uc.ChromeOptions() options.add_argument("--disable-notifications") options.add_argument('--load-extension =C:\python\myproject\Extract file') # extract file zip to directory # setting profile options.user_data_dir = "c:\temp\profile18" driver = uc.Chrome(options=options,version_main=97) time.sleep(2) input('ok')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants