// ==UserScript== // @name Twitter興味関心解除 // @namespace https://x.com/settings/your_twitter_data/twitter_interests // @version 1.25.02040700 // @description Twitter設定の興味関心のチェックを一気に外します(50個ずつ) // @author @PseudoTwDk // @match https://x.com/settings/your_twitter_data/twitter_interests // @icon https://www.google.com/s2/favicons?sz=64&domain=x.com // @run-at document-start // @grant none // ==/UserScript== // [設定とプライバシー]→[プライバシーと安全]→[表示するコンテンツ]→[興味関心] のページを開いてからリロードが必要です // リロードすると数秒後に [DELETE] ボタンが出現します // 短時間に多数件削除を行うとAPIの制限からかエラーが出る場合がありますがリロードすると50件くらいまでならちゃんと消えます // 50件を超える場合は10分とか30分後に再度続きを消す感じのオペレーションをしてください var flgComplete = 0; const SEL = 'input[type="checkbox"][aria-describedby^="CHECKBOX_"][checked]'; //実際に消す処理の本体 function execChg(){ var e, eb, i, c=0, f=0; e = document.querySelectorAll(SEL); if( e.length > 0 ){ if( window.confirm(" " + e.length + "件のチェックを削除しますか?\r\n 一度に50件まで処理します ") == false ){ return; } }else{ if( window.confirm(" チェック済みデータはありません ") == false ){ return; } } eb = document.getElementById('DeleteButton'); if( eb !== null ){ eb.innerHTML = "WAIT..."; } window.setTimeout(execChgWait, 100); } //ボタン文字列書き換えのため遅延実行 function execChgWait(){ var e, eb, i, c=0, f=0; e = document.querySelectorAll(SEL); for( i=0; i= 50 ){ f = 1; break; } console.log("Find Check [" + i + "]"); e[i].click(); e[i].setAttribute("checked",null); c++; } eb = document.getElementById('DeleteButton'); if( eb !== null ){ eb.innerHTML = "DELETE"; } if( i && !f ){ if( window.confirm(" チェックを " + c + " 件削除しました\r\n リロードしますか? ") == true ){ location.reload(); } } if( i && f ){ if( window.confirm(" チェックを50件削除しました\r\n リロードしますか? ") == true ){ location.reload(); } } } //ボタンを追加する遅延処理 function setupButton(){ var e, i, newHTML; e = document.querySelectorAll("button[id='DeleteButton']"); if( e.length > 0 ){ window.setTimeout(setupClick, 100); return; } e = document.querySelectorAll("h2 span"); for( i=0; i< e.length; i++ ){ if( e[i].innerHTML == "興味関心" ){ newHTML = ""; e[i].insertAdjacentHTML('afterend', newHTML); window.setTimeout(setupClick, 100); break; } } } //ボタンにクリックイベントを紐付ける遅延処理 function setupClick(){ var e = document.getElementById('DeleteButton'); if( e !== null ){ e.onclick = execChg; flgComplete = 1; } } //ロードが遅すぎる時のリトライ function setupRetry(){ if( flgComplete ) return; window.setTimeout(setupButton, 1000); window.setTimeout(setupRetry, 2000); } //遅延呼び出し window.setTimeout(setupButton, 1000); window.setTimeout(setupRetry, 2000);