function getRandomDelay(min = 3000, max = 4000) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

async function loopPasteEmailsSequential() {
  for(let i = 0; i <= 999; i++) {
    const num = String(i).padStart(3, '0');
    const email = `w1${num}@ymail.ne.jp`;
    const inputFields = document.querySelectorAll(
      '.r-30o5oe.r-1dz5y72.r-13qz1uu.r-1niwhzg.r-17gur6a.r-1yadl64.r-deolkf.r-homxoj.r-poiln3.r-7cikom.r-1ny4l3l.r-t60dpp.r-fdjqy7'
    );
    console.log(inputFields);
    const inputField = inputFields[1];
    if (!inputField) {
      console.error('入力フィールドが見つかりません。中断します。');
      break;
    }
    // Reactの内部状態にアクセスするためのアプローチ
    // 1. 元々のprops/handlerを探す
    const reactKey = Object.keys(inputField).find(key => 
      key.startsWith('__reactProps$') || 
      key.startsWith('__reactEventHandlers$')
    );

    if (reactKey) {
      console.log('React props found:', reactKey);
      const reactProps = inputField[reactKey];

      // 2. onChangeハンドラを探す
      if (reactProps.onChange) {
        // フォーカスを設定
        inputField.focus();

        // 値を設定
        inputField.value = email;

        // Reactのchangeハンドラを直接呼び出す
        const syntheticEvent = {
          target: inputField,
          currentTarget: inputField,
          preventDefault: () => {},
          stopPropagation: () => {},
          isPropagationStopped: () => false,
          isDefaultPrevented: () => false,
          persist: () => {},
          nativeEvent: new Event('change', { bubbles: true }),
          bubbles: true,
          cancelable: true,
          type: 'change'
        };

        // ReactのonChangeを呼び出す
        reactProps.onChange(syntheticEvent);
        console.log(`ReactのonChangeハンドラを呼び出しました`);
      } else if (reactProps.onInput) {
        // onInputハンドラを探す
        inputField.focus();
        inputField.value = email;

        const syntheticEvent = {
          target: inputField,
          currentTarget: inputField,
          preventDefault: () => {},
          stopPropagation: () => {},
          isPropagationStopped: () => false,
          isDefaultPrevented: () => false,
          persist: () => {},
          nativeEvent: new Event('input', { bubbles: true }),
          bubbles: true,
          cancelable: true,
          type: 'input',
          data: email
        };

        reactProps.onInput(syntheticEvent);
        console.log(`ReactのonInputハンドラを呼び出しました`);
      } else {
        console.log('onChangeまたはonInputハンドラが見つかりませんでした');
      }
    } else {
      // Reactのプロパティが見つからない場合、標準的な方法を試みる
      inputField.focus();

      // 標準的なイベントディスパッチを試みる
      inputField.value = email;
      inputField.dispatchEvent(new Event('input', { bubbles: true }));
      inputField.dispatchEvent(new Event('change', { bubbles: true }));

      console.log('標準的なイベントディスパッチを実行しました');
    }

    console.log(`入力試行: ${email}`);

    const delay = getRandomDelay();
    await new Promise(resolve => setTimeout(resolve, delay));

    const errTaken = Array.from(document.querySelectorAll('*')).find(el => el.innerHTML === 'Email has already been taken.');
    if (errTaken) {
      console.error(`${email} has already been taken.`);
      break;
    }
  }
}

loopPasteEmailsSequential();
Edit Report
Pub: 28 Apr 2025 18:00 UTC
Views: 18