Search code examples
pythonseleniumgoogle-chrome-extensionselenium-chromedriverchrome-web-store

how to install an extension from chrome web store using selenium python


I am trying to automate an action in this website, https://chocolia.eu/voter but i get blocked by cloudflare, it freezes the website and when i refresh it here is what it does : image

i can use undetected chrome driver for this situation and it works with it but i need an extension for this to work and undetected chrome driver is not compatible with extensions so i want to install it from chrome webstore but you have to confirm the installation of the extension and it is not a javascript alert as i tried driver.switch_to.alert .


Solution

  • You need to be undetected but U.C can't install extension, you should read the solution given by colossatr0n in this thread : Can a website detect when you are using Selenium with chromedriver? Here is a partial copy of the response, the idee is to replace the cdc_ in chromedriver.exe to not be detected :

    The bot detection scripts usually look anything containing word "selenium" / "webdriver" in any of the variables (on window object), and also document variables called $cdc_ and $wdc_. This is the function I modified in chromedriver:
    File call_function.js:

    function getPageCache(opt_doc) {
      var doc = opt_doc || document;
      //var key = '$cdc_asdjflasutopfhvcZLmcfl_';
      var key = 'randomblabla_';
      if (!(key in doc))
        doc[key] = new Cache();
      return doc[key];
    }
    

    (Note the comment. All I did I turned $cdc_ to randomblabla_.)

    And finally i recommande you to replace $cdc_ by xxxx (same number of charactere) and modify it in HexEditor. ( Moi aussi j'ai joué à chocolia.Mc avant add : l !'Magics#3537 )