タイトルはそのうち決める

艦これのおぼえがきとか実験装置とかLaTexのメモとか。

Boothに置いたVRoidアイテムをエゴサするブックマークレット

boothに置いてあるアイテム、リンクを貼ってくれている人を探すのは意外と大変。

というのも、アイテムを指すURLが複数存在しているから。

 

  1. ショップ固有のアドレス
    shopname.booth.pm/items/xxxxxxx
  2. Boothの検索画面から飛ぶページ
    booth.pm/ja/items/xxxxxxx
  3. ↑の英語版ページ
    booth.pm/en/items/xxxxxxx
  4. ↑の韓国語版ページ
    booth.pm/ko/items/xxxxxxx
  5. ↑の简体中国語版ページ
    booth.pm/zh-cn/items/xxxxxxx
  6. ↑の繁體中国語版ページ
    booth.pm/zh-tw/items/xxxxxxx

で、単純には共通している「items/xxxxxxx」で検索したら良さそうに見える。
ただ、Twitter/Xだとこれでは検索にかからない。

 

なので、

"booth.pm/items/xxxxxxx" OR "booth.pm/ja/items/xxxxxxx" OR "booth.pm/en/items/xxxxxxx" OR "booth.pm/ko/items/xxxxxxx" OR "booth.pm/zh-cn/items/xxxxxxx" OR "booth.pm/zh-tw/items/xxxxxxx"

という文字列を生成して検索欄にうちこんだ時のURLを生成したくなる。

 

以下ではboothから対応するVRoidHubのページに飛ぶやつが公開されている。

sakuttobankas.com

これを真似て、ブックマークのアドレスにそのまま打てるようにしたのが以下。

javascript:const%20url%3Dlocation.href%3Bif(url.indexOf(%22booth.pm%22)%3E%200)%7Bconst%20item%3Durl.slice(-7)%3Blocation.href%3D%22https%3A%2F%2Ftwitter.com%2Fsearch%3Fq%3D\%22booth.pm%2fja%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%20OR%20\%22booth.pm%2fen%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%20OR%20\%22booth.pm%2fko%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%20OR%20\%22booth.pm%2fzh-cn%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%20OR%20\%22booth.pm%2fzh-tw%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%20OR%20\%22booth.pm%2fitems%2F%22%20%2B%20item%20%2B%20%22\%22%26f%3Dlive%22%3B%7Delse%7Balert('%E3%81%93%E3%81%AEURL%E3%81%AF%E4%BD%BF%E3%81%88%E3%81%BE%E3%81%9B%E3%82%93')%3B%7Dvoid(0);

 

ちなみに、元の文字列はこれ。

javascript:const url=location.href;if(url.indexOf("booth.pm")> 0){const item=url.slice(-7);location.href="https://twitter.com/search?q=\"booth.pm/ja/items/" + item + "\" OR \"booth.pm/en/items/" + item + "\" OR \"booth.pm/ko/items/" + item + "\" OR \"booth.pm/zh-cn/items/" + item + "\" OR \"booth.pm/zh-tw/items/" + item + "\" OR \"booth.pm/items/" + item + "\"&f=live";}else{alert('このURLは使えません');}void(0);