PR

X自動ミュートワード設定コード

かなり突貫工事で作ったのでもしうまくいかなかったらすみません。時間を空けてもう一度やるとうまくいくかもです。

絶対に間違えないよう、より詳しい導入方法を解説しました。→【インプレゾンビ対策】X(旧Twitter)でミュートワードを自動で設定する方法 | セカヤサブログ (itokoba.com)

async function muteCharactersWithSkip(characters) {
  async function randomDelay() {
    const min = 1500
    const max = 2500
    const delay = Math.random() * (max - min) + min
    return new Promise((resolve) => setTimeout(resolve, delay))
  }

  const simulateInput = (element, value) => {
    const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
      window.HTMLInputElement.prototype,
      "value"
    ).set
    nativeInputValueSetter.call(element, value)

    const inputEvent = new Event("input", { bubbles: true })
    element.dispatchEvent(inputEvent)
  }

  for (const char of characters) {
    const addButton = document.querySelector(
      'a[aria-label="ミュートする単語またはフレーズを追加"]'
    )
    if (addButton) {
      addButton.click()
      await randomDelay()
    }

    const inputElement = document.querySelector('input[name="keyword"]')
    simulateInput(inputElement, char)

    document
      .querySelector('div[data-testid="settingsDetailSave"][role="button"]')
      .click()
    await randomDelay()

    let alreadyMutedMessage = document.querySelector('[aria-live="assertive"]')
    if (
      alreadyMutedMessage &&
      alreadyMutedMessage.textContent.includes("既にミュートしています")
    ) {
      console.log(`${char}は既にミュートされています。スキップします。`)
      simulateInput(inputElement, "")
      continue
    }

    console.log(`${char}をミュートリストに追加しました。`)
  }

  console.log("全ての文字のミュート処理が完了しました。")
}

const characters = ["क","ख","ग","घ","ङ","च","छ","ज","झ","ञ","य","श","ड","ढ","ण","र","ष","ड़","त","थ","द","ध","न","ल","स","फ","ब","भ","म","व","अ","आ","इ","ई","उ","ऊ","ऋ","ए","ऐ","ओ","औ","प","फ","ब","भ","म","य","र","ल","व","श","ष","स","ह","उ","ध","प","म","स","𑘁","𑘃","𑘄","𑘎","𑘐","𑘑","𑘓","𑘕","𑘰","𑘛","𑘝","𑘠","𑘢","𑘤","𑘥","𑘨","𑘭","𑘮","ق","غ","ف","ى","ء","ظ","ط","خ","ض","ص","ن","م","ح","ث","ش","ل","ذ","ر","ت","ز","ي","و","ك","ج","د","ب","ا","ぷろふから","プロフから","ぷろふのリンク","プロフのリンク","ぷろふみて","プロフみて","プロフリンク","プロフをみて","プロフを見て","プロフ見て"]

muteCharactersWithSkip(characters)
タイトルとURLをコピーしました