以下の様に、ブラウザでBoxのフォルダを開いている時に、当該フォルダをBoxDrive(Finder)で開きたくなることがある。そんな時にこのブックマークレットを使用すれば、いい感じにパスをコピーできる。
以下のスクリプトをChromeのブックマークに任意の名前で登録する。 ([ブックマークマネージャー] > [新しいブックマークを登録]) ブックマークバーとかに置いとくと良いかも。
javascript: (function () { let path = "~/Box/"; const dotButton = document.querySelectorAll( ".ItemListBreadcrumb > button")[0]; if (dotButton) { 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.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(); })();
2021-11-10 追記
MacOS Monterey、かつ Box Drive v2.24 以降の場合、マウントパスが ~/Box/
ではなく ~/Library/CloudStorage/Box-Box/
に変更される。
javascript: (function () { let path = "~/Library/CloudStorage/Box-Box/"; const dotButton = document.querySelectorAll( ".ItemListBreadcrumb > button")[0]; if (dotButton) { 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.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(); })();
javascript: (function () { let path = "%USERPROFILE%/Box/"; const dotButton = document.querySelectorAll( ".ItemListBreadcrumb > button")[0]; if (dotButton) { 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.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(); })();
// javascript:(function(){let path="~/Box/";const dotButton = document.querySelectorAll(".breadcrumb-item.no-shrink > button")[0];if(dotButton){dotButton.click();path+=[...document.querySelectorAll("a[data-resin-target='openfolder'].menu-item")].map(e=>e.innerText).reverse().join("/")+"/";};path+=[...document.querySelectorAll(".breadcrumb-item:nth-child(n+2):not(.no-shrink)")].map(v=>v.innerText).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でフォルダを表示している状態(最初の画像みたいな状態)で、登録したブックマークを呼び出すと、~/Box/miyamoto/box/to/local/path
の様な形式でクリップボードにコピーされる。
Finder で cmd + shift + g
でフォルダ移動のダイアログを呼び出し、貼り付けて移動する。
- macOS Catalina 10.15.4
- Chrome 83.0.4103.97
@since1899acm
こんにちは。残念ながら私の利用環境で分類ラベルを試す権限を持っておらず、試すことができません...