您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a button on Box website that can copy explorer path of Box folder.
当前为
// ==UserScript== // @name Copy explorer path of Box folder // @description Add a button on Box website that can copy explorer path of Box folder. // @namespace https://github.com/kevinzch/Copy-explorer-path-of-Box-folder // @version 0.3 // @author Kevin // @include https://app.box.com/folder/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; const copyExplorerPath = () => { try { // Create button and set button style let copyBtn = document.createElement('button'); let searchBar = document.querySelector('.header-search.prevent-item-deselection.HeaderSearch-isNewQuickSearch'); // Make basis of url const apiUrl = 'app-api/enduserapp/folder/'; let appHost = Box.prefetchedData['/app-api/enduserapp/current-user'].preview.appHost; // Request let request = new XMLHttpRequest(); // Empty Variables which will be reused in click event let folderId = ''; let fullUrl = ''; let explorerPath = ''; let jsonObj = null; let length = 0; // Set button style copyBtn.textContent = 'フォルダパスをコピー'; copyBtn.style.backgroundColor = '#4baf4f'; copyBtn.style.color = 'white'; copyBtn.style.borderRadius = '8px'; copyBtn.style.padding = '0px 20px'; // Add button to document searchBar.appendChild(copyBtn); // Add button click listner copyBtn.addEventListener('click', function(){ // Reget folderID and remake full url folderId = document.URL.split('/').pop(); fullUrl = appHost + apiUrl + folderId; // Clear explorer path explorerPath = 'Box'; request.open('GET', fullUrl, false); request.send(); jsonObj = JSON.parse(request.responseText); length = jsonObj.folder.path.length; for (let i = 0; i < length; i++){ // Skip 'All files' if (i == 0){ continue; } else{ explorerPath += '\\' + jsonObj.folder.path[i].name; } } navigator.clipboard.writeText(explorerPath); alert("下記のパスをコピーしました:\r\n" + explorerPath); }) } catch (e) { setTimeout(() => { copyExplorerPath(); }, 500); } }; setTimeout(() => { copyExplorerPath(); }, 100); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址