批量删除gitee的代码库

先获取令牌,然后再console中执行。

(async function() {
    let resp = await fetch("https://gitee.com/api/v5/users/yourname/repos?access_token=#your_token_string#&type=all&sort=full_name&direction=asc&page=1&per_page=100", {
        "headers": {
            "accept": "application/json, text/plain, */*",
            "content-type": "application/json;charset=utf-8"
        },
        "referrer": "https://gitee.com/api/v5/swagger",
        "referrerPolicy": "strict-origin-when-cross-origin",
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
    });

    let list = await resp.json();
    let fetchurls = list.filter((v,i)=>v.full_name.indexOf('/cto-') > 0).map((v,i)=>'https://gitee.com/api/v5/repos/' + v.full_name + '?access_token=#your_token_string#');
    for (var i = 0, c = fetchurls.length; i < c; i++) {
        let url = fetchurls[i];
        await fetch(url, {
            method: 'DELETE',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            }
        })
    }
    console.log('ok')
}
)();

 

posted @ 2021-08-22 16:17  阿牛  阅读(485)  评论(0编辑  收藏  举报