# superfluid.finance自动化填写白名单 **Published by:** [MaxPj](https://paragraph.com/@ludaobi/) **Published on:** 2022-09-01 **URL:** https://paragraph.com/@ludaobi/superfluid-finance ## Content 需要说明的是: 1、官方地址 https://www.superfluid.finance/ 2、该填写白名单领取POAP的活动已经结束了。 3、这个网页防爬功能做的比较好,使用了iframe结构,操作起来比较麻烦,本次选择了比较取巧的方式。 const puppeteer = require('puppeteer-extra') const RecaptchaPlugin = require('puppeteer-extra-plugin-recaptcha') puppeteer.use( RecaptchaPlugin({ provider: { id: '2captcha', token: '' // REPLACE THIS WITH YOUR OWN 2CAPTCHA API KEY ⚡ }, visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved) }) ) let emails = [ // "test@ludaobi.com", // "demo@ludaobi.com", ] const inviteUrl = "https://www.superfluid.finance/" async function forloop(){ for (let index = 0; index < emails.length; index++) { await Promise.race([ helper(index), awaitSync(120000) ]) } } async function helper(index){ const browser = await puppeteer.launch({ headless: false, timeout:0, devtools: false, }) try { let url = inviteUrl const pages = await browser.pages() const page = pages[0] await page.goto(url, { waitUntil: 'networkidle2', })await page.evaluate(() => { var shs = document.querySelectorAll(".scroll-content .sf-hero"); for(var i=0; i< shs.length; i++){ shs\[i\].parentNode.removeChild(shs\[i\]); } var elements = document.querySelectorAll(".scroll-content section"); for(var i=0; i< elements.length; i++){ if (i<4) { elements\[i\].parentNode.removeChild(elements\[i\]); } } }) let ifm = await page.$(".sf-outro-form iframe") const fm = await ifm.contentFrame(); let \_email = emails\[index\] let \_name = \_email.split("@")\[0\] let ninput = await fm.waitForSelector('.hs_firstname input'); ninput.type(\_name) await wait(500) let einput = await fm.waitForSelector('.hs_email input'); einput.type(\_email) await wait(1000) const acceptBtn = await fm.waitForSelector(\`.actions .hs-button\`); acceptBtn.click() console.log(index, emails\[index\]) await page.$("iframe.hs-form-iframe") await wait(2000) await browser.close() } catch (error) { console.log("catch error: ",emails[index], error) } finally { console.log("gogoo") } await browser.close() } async function awaitSync(ms) { await wait(ms) } function wait(ms) { return new Promise(resolve =>setTimeout(() =>resolve(), ms)); }; // async function autoScroll(page){ // await page.evaluate(async () => { // console.log(111111111) // await new Promise((resolve, reject) => { // var totalHeight = 0; // var distance = 100; // var timer = setInterval(() => { // var scrollHeight = document.body.scrollHeight; // console.log(2222222,scrollHeight) // window.scrollBy(0, distance); // totalHeight += distance; // if(totalHeight >= scrollHeight){ // clearInterval(timer); // resolve(); // } // }, 100); // }); // }); // } // async function autoScrollN( // page, // delay = 500, // percent = 0.3, // duration = 16 // ) { // await page.evaluate(new Function(` // var lastDate; // var duration = ${duration}; // return new Promise((resolve, reject) => { // try { // let lastScroll = 0; // let retry = 0; // const MAX_SCROLL = Number.MAX_SAFE_INTEGER; // const instance = document.documentElement.scrollHeight; // const interval = setInterval(() => { // window.scrollBy(0, instance * ${percent}); // const scrollTop = document.documentElement.scrollTop; // if ( // scrollTop === MAX_SCROLL || // (Date.now() > lastDate + ${delay} && lastScroll === scrollTop) // ) { // clearInterval(interval); // resolve(); // } else { // lastScroll = scrollTop; // lastDate = Date.now(); // } // }, duration); // } catch (err) { // reject(err.toString()); // } // }); // `)); // }; forloop() ## Publication Information - [MaxPj](https://paragraph.com/@ludaobi/): Publication homepage - [All Posts](https://paragraph.com/@ludaobi/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@ludaobi): Subscribe to updates