はじめに
ブラウザ版Twitter用ブックマークレットです。
アカウントを指定してツイートを検索する時に、コピー&ペーストする手間をひとつ省く便利なやつです。
.js
javascript:(()=>{const t=location.href.split("/");if(t[2].endsWith("twitter.com")&&t[3]){const o=t[3].split("?")[0],i=prompt("Search from @"+o,"");i&&(location.href="//twitter.com/search?f=live&q="+i+"%20from:"+o)}})();
使い方
- 検索対象とするTwitterアカウントのホーム、またはツイートのページを予め開いておく。
 - ブックマークレットを実行。
 - 入力画面が表示されるので、キーワードを入力する。
 
簡潔な説明
圧縮前のコードはこちら。
.js
(
    () => {
// ----------
const path = location.href.split('/');
// twitter ID check
if (path[2].endsWith('twitter.com') && path[3]) {
    // id
    const id = path[3].split('?')[0];// no parameters
    // keywords
    const keywords = prompt('Search from @' + id, '');
    // search results
    if (keywords) {
        location.href = '//twitter.com/search?f=live&q=' + keywords + '%20from:' + id;
    }
}
// ----------
    }
)();
大体の流れは次の通りです。
- URLからtwitter IDを取得する => 
path[3] - 
window.promptで検索キーワードを取得する =>keywords - 取得した値をもとに検索パラメータをセットする
 - 組み立てたURLを開く
 
註
- iPhone: Safari, Chromeで動作確認しました。
 - 以下の例のように、
https://twitter.com/にアカウントが続くURLでのみ実行可能です。 
OK ![]()
https://twitter.com/Qiita
https://twitter.com/Qiita/status/1351820856100487168
NG ![]()
https://twitter.com
https://twitter.com/search?q=qiita
あとがき
今どきwindow.promptを使うのがちょっとアレなんですが、取り敢えず動けばOKです。
いつもお世話様です。
本日もありがとうございました。
参考
【簡単にできる】ブックマークレットのすゝめ【初心者向け】
https://qiita.com/len_crow/items/189603f2c5f462bb670c
Twitterの高度な検索