ブラウザでBoxのフォルダを開いている時に、当該フォルダをBoxDrive(Windows Explorer)で開きたくなることがある。そんな時にこのブックマークレットを使用すれば、いい感じにパスをコピーできる。
以下で公開されているブックマークレットを元に修正したもの。
- (1) 階層メニューのパスがコピーされない場合がある不具合を修正
- (2) 分類ラベルをコピーしないように修正
- (3) パス形式を Windows 用に変更
Windows Explorer で開く分には (3) のパス形式は変更しなくても問題はないのだが、自分の場合パスをそのまま他のテキストにもコピーすることが多いため Windows パス形式に揃えた。
以下のスクリプトをEdgeのブックマークに任意の名前で登録する。
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