snippets.zerodogg.org

Humble Bundle tiers

This snippet can be used to view the contents of the various tiers of a Humble Bundle. The easiest way is to use the bookmarklet, but you can also just copy the code and paste it into the browser console.

Bookmarklet: Humble tiers.

((document) => {
  const currency = document.querySelectorAll(".currency-symbol")[0].innerText;
  let tiers = Array.from(
    document.querySelectorAll(".js-tier-filter")
  ).reverse();
  let seen = {};
  let tierContent = {};
  let tierOrder = [];
  let next = () => {
    if (tiers.length === 0) {
      let content = "";
      for (const t of tierOrder) {
        content += "# " + t + "\n";
        for (const entry of tierContent[t]) {
          content += entry + "\n";
        }
        content += "\n";
      }
      alert(content);
      return;
    }
    let tier = tiers.shift();
    let tierName = tier.innerText;
    tier.click();
    setTimeout(() => {
      const entries = [];
      const cost = document.querySelectorAll(
        ".preset-prices > input:checked"
      )[0].value;
      tierName += " [" + currency + cost + "]";
      tierOrder.push(tierName);
      tierContent[tierName] = [];
      for (const q of document.querySelectorAll(".item-title")) {
        let name = q.innerText;
        if (seen[name] !== true) {
          entries.push(name);
          seen[name] = true;
        }
      }
      tierContent[tierName].push(...entries.sort());
      next();
    }, 500);
  };
  next();
})(document);