# Pill Wheelポチポチbot

By [Something about Web3](https://paragraph.com/@0xkyosuke) · 2024-05-28

---

まえがき
----

Farcasterのframeは言うてもiframeなのでJavascriptで操作できる。  
ポチポチゲーはbot作って自動化しないともったいない。  
もちろん無効になるリスクはあるけどリターンとの兼ね合いを考えると躊躇しても意味ない気がする。  
だってどうせ短命やん。

今回のターゲットは👇️

[https://warpcast.com/pilll/0xeabcccf9](https://warpcast.com/pilll/0xeabcccf9)

注意点
---

不定期にエラーが出ます。おそらくレートリミット。Farcaster側で制御してるっぽく、frame全部がしばらく死にます。  
そうなったらしばらく待ってからページをリロードしてコードを実行させたらOKです。

やり方
---

調べてください。

コード
---

    // ボタンのテキストが「🔄Spin -100 points」であるボタンを探す関数
    function findButtonByLabel(label) {
        const buttons = document.querySelectorAll('button');
        for (let button of buttons) {
            if (button.innerText.includes(label)) {
                return button;
            }
        }
        return null;
    }
    
    // ランダムな間隔でボタンをクリックする関数
    function autoClickButton(label) {
        function clickButton() {
            const button = findButtonByLabel(label);
            if (button) {
                button.click();
            } else {
                console.log(`ボタンが見つかりません: ${label}`);
            }
            // 次のクリックまでのランダムな間隔を設定
            // 下はインターバルが2秒から4秒
            // (a-b)+c
            // a: max, b: min, c: interval
            const randomInterval = Math.random() * (4000 - 2000) + 2000;
            setTimeout(clickButton, randomInterval);
        }
        clickButton();
    }
    
    // 「🔄Spin -100 points」のラベルのボタンを自動クリック
    autoClickButton('🔄Spin -100 points');

---

*Originally published on [Something about Web3](https://paragraph.com/@0xkyosuke/pill-wheel-bot)*
