Skip to content

Instantly share code, notes, and snippets.

@kskmori
Forked from t3yamoto/index.md
Last active April 18, 2025 13:23
Show Gist options
  • Save kskmori/1c9458bd56a36374f196a8cd0a0c9e33 to your computer and use it in GitHub Desktop.
Save kskmori/1c9458bd56a36374f196a8cd0a0c9e33 to your computer and use it in GitHub Desktop.
Boxで開いているフォルダをBoxDriveで開きたい時に便利なブックマークレット(Windows用)

Boxで開いているフォルダをBoxDriveで開きたい時に便利なブックマークレット(Windows用)

ブラウザでBoxのフォルダを開いている時に、当該フォルダをBoxDrive(Windows Explorer)で開きたくなることがある。そんな時にこのブックマークレットを使用すれば、いい感じにパスをコピーできる。

以下で公開されているブックマークレットを元に修正したもの。

修正内容

  • (1) 階層メニューのパスがコピーされない場合がある不具合を修正
  • (2) 分類ラベルをコピーしないように修正
  • (3) パス形式を Windows 用に変更

Windows Explorer で開く分には (3) のパス形式は変更しなくても問題はないのだが、自分の場合パスをそのまま他のテキストにもコピーすることが多いため Windows パス形式に揃えた。

インストール方法

以下のスクリプトをEdgeのブックマークに任意の名前で登録する。

Windows 版

javascript: (async function () { let path = "%USERPROFILE%\\Box\\"; const dotButton = document.querySelectorAll( ".ItemListBreadcrumb > button")[0]; if (dotButton) { await dotButton.click(); path += [ ...document.querySelectorAll( "a[data-resin-target='openfolder'].menu-item"), ] .map((e) => e.innerText) .filter( (v) => v !== decodeURI( "%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB")) .join("\\"); if (!path.endsWith("\\")) path += "\\"; } path += [...document.querySelectorAll(".ItemListBreadcrumb-listItem")] .map((v) => v.firstElementChild.innerText) .filter( (v) => v !== "" && v !== decodeURI( "%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB")) .join("\\"); !(function (a) { var b = document.createElement("textarea"), c = document.getSelection(); (b.textContent = a), document.body.appendChild(b), c.removeAllRanges(), b.select(), document.execCommand("copy"), c.removeAllRanges(), document.body.removeChild(b); })(path); document.body.click(); })();

使い方

Boxでフォルダを表示している状態で登録したブックマークを呼び出すと、%USERPROFILE%\Box\to\local\path の様な形式でクリップボードにコピーされる。 Explorer のアドレスバーに貼り付けて移動する。

動作確認環境

  • Windows 11 23H2
  • Edge 134.0.3124.93

ライセンス

ライセンスはFork元の下記ライセンスと同じく Unlicense とします。 https://gist.github.com/t3yamoto/35a61f4f95edafbe71056c6ba35d8596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment