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();
})();
@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