Existing answers have been useful, but this should do the full submission and give you the share URL.
Since this AngularJS app doesn't seem to use ids and classes much, using text contents seems like a reasonable choice for hitting a couple of the buttons.
I had to use .evaluate(el => el.click())
instead of .click()
to click one of the buttons successfully as described here.
const puppeteer = require("puppeteer");
const clickXPath = async (page, xp) => {
await page.waitForXPath(xp);
const [el] = await page.$x(xp);
await el.evaluate(el => el.click());
};
const randomEmail = () =>
Array(10).fill().map(() =>
String.fromCharCode(~~(Math.random() * 26 + 97))
).join("") +
`${(Math.random() + "").replace(/\./, "")}@gmail.com`
;
let browser;
(async () => {
const url = "https://gleam.io/hxVaH/win-a-krooked-big-eyes-too-skateboard";
browser = await puppeteer.launch({headless: false});
const [page] = await browser.pages();
await page.goto(url, {waitUntil: "networkidle0"});
await clickXPath(page, `//span[contains(text(), "Refer Friends")]`);
const nameSel = '[class="entry-method expanded"] input[name="name"]';
const emailSel = '[class="entry-method expanded"] input[name="email"]';
await page.waitForSelector(nameSel);
await page.type(nameSel, "my name33");
await page.type(emailSel, randomEmail());
const hasText = () => page.evaluate(() =>
!!document.querySelector(".share-link__link")?.innerText.trim()
);
for (let tries = 1000; !(await hasText()) && tries--;) {
await clickXPath(page, `//span[contains(text(), "Save")]`);
await page.waitForTimeout(100);
}
const shareCode = await page.$eval(".share-link__link", el => el.innerText);
console.log(shareCode); // => https://wn.nr/w9Wz5p
})()
.catch(err => console.error(err))
.finally(async () => await browser.close())
;