Skip to content

Instantly share code, notes, and snippets.

@theaafofficial
Created September 7, 2024 19:17
Show Gist options
  • Select an option

  • Save theaafofficial/cee7cb136783ac800c981371fe5ff8dc to your computer and use it in GitHub Desktop.

Select an option

Save theaafofficial/cee7cb136783ac800c981371fe5ff8dc to your computer and use it in GitHub Desktop.
Select multiple passwords in ProtonPass website
(async function () {
  // Variables based on your input
  const totalPasswords = 0; // Total number of passwords
  const visiblePasswordsDivs = 25; // Number of divs visible at a time
  // Select the scroll container based on the parent class
  const scrollContainer = document.querySelector(".ReactVirtualized__Grid");
  // Get the total scrollable height of the container
  const totalScrollHeight = scrollContainer.scrollHeight;
  // Dynamically calculate the scroll step
  const averageDivHeight = totalScrollHeight / totalPasswords;
  const scrollStep = averageDivHeight * visiblePasswordsDivs;
  // Array to store already clicked divs to avoid re-clicking
  let clickedDivs = new Set();
  // Increased delay time to account for slower rendering
  const renderDelay = 3000;
  // Function to scroll and click child divs
  async function scrollAndClickDivs() {
    let lastScrollTop = 0;
    let maxScrollHeight = scrollContainer.scrollHeight;
    while (lastScrollTop < maxScrollHeight) {
      let divs = scrollContainer.querySelectorAll("div");
      divs.forEach((div) => {
        // If this div has already been clicked, skip it
        if (!clickedDivs.has(div)) {
          try {
            // Click the div and log it
            div.click();
            console.log("Clicked:", div);
            // Add this div to the clickedDivs set to avoid future clicks
            clickedDivs.add(div);
          } catch (error) {
            console.warn("Could not click:", div, error);
          }
        }
      });
      // Scroll down by the calculated step size
      scrollContainer.scrollTop += scrollStep;
      // Wait for new elements to render
      await new Promise((resolve) => setTimeout(resolve, renderDelay));
      // Update the scroll position and maximum scroll height
      lastScrollTop = scrollContainer.scrollTop;
      maxScrollHeight = scrollContainer.scrollHeight;
    }
  }
  // Start the scrolling and clicking
  await scrollAndClickDivs();
})();
@theaafofficial
Copy link
Author

theaafofficial commented Sep 7, 2024

If you're trying to select multiple passwords on a ProtonPass and don't want to select each one manually, you can use this JavaScript script in the browser's DevTools console.

Instructions:

  1. Open the passwords page in your browser.
  2. Enable selection mode on the page (make sure you can select passwords manually).
  3. Adjust the totalPasswords variable in the script to match the approximate number of passwords displayed.
  4. Paste the script into the Console tab of DevTools and press Enter.

The script will scroll and attempt to select multiple passwords automatically. It might miss a few, but it’s a quick alternative to selecting all passwords manually. Lastly, click the trash button at the end.

@LightBeamOvHe
Copy link

Thanks a LOT for your help. Pretty crazy that there's no way implemented way to do this and this is clutch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment