GetFileListFeishu

复制飞书文件列表,支持官方飞书

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         GetFileListFeishu
// @namespace    https://www.feishu.cn/
// @version      0.1
// @description  复制飞书文件列表,支持官方飞书
// @author       AustinYoung
// @match        https://*.feishu.cn/drive/*
// @icon         https://www.feishu.cn/favicon.ico
// @grant        GM_setClipboard
// @license MIT
// ==/UserScript==
window.searchCount = 0;
(function() {
    'use strict';

    // 添加悬浮框
    console.log('添加悬浮框')
    addFloat();
})();
function addFloat()
{
    window.searchCount++;
    console.log('查找搜索框:'+window.searchCount)
    let searchNote = document.querySelector(".explorer__page-header-with-navbar span")
    if(searchNote==null)
    {
        console.log('没有标题')
        if(window.searchCount<10)
        {
            setTimeout( addFloat,1000);
        }
        return;
    }
    let myFloat=document.createElement("div");
    myFloat.style.float ='right';
    myFloat.innerHTML ="<div id='myCopyDiv' style='cursor:pointer' title='复制列表到剪切板'>📋</div>"

    searchNote.appendChild(myFloat)
    document.getElementById('myCopyDiv').addEventListener('click',copyContainText);
}
const copyContainText = function()
{
    // 获取对象
    let containList = ['.explorer-file-list-virtualized__container','.explorer-grid-view-virtualized__container','.infinite-scroll']
    let contain;
    for(let v of containList)
    {
        contain = document.querySelector(v)
        if(contain != null)
        {
            break;
        }
    }
    console.log(contain)
    // 提取内容
    let arrTxt = [];
    // 预分析每行内容
    let lists = contain.querySelectorAll(".file-list-item");
    for(let v of lists)
    {
        // 替换为 CSV格式
        arrTxt.push( v.innerText.replace(/\n/g,'\t'))
    }
    // 复制到剪切板
    GM_setClipboard(arrTxt.join('\n'));
    myCopyDiv.innerText = '✔';
    // 重新显示复制按钮
    setTimeout(function(){myCopyDiv.innerText = '📋'},2000);
}