欢迎光临 - 我的站长站,本站所有资源仅供学习与参考,禁止用于商业用途或从事违法行为!

浏览器插件

Alist快速添加云盘分享存储油猴脚本
2023-02-01 我的站长站

Alist快速添加云盘分享存储油猴脚本

  • 软件编号:1503
  • 软件分类:浏览器插件
  • 点击次数:29
  • 软件语言:简体中文
  • 软件大小:9.25 KB
  • 下载权限:免费下载
  • 软件授权:试用
  • 软件售价:免费下载
  • 下载次数:0
立即下载

Alist添加存储的时候,每次都要来回切换复制粘贴id,挺费劲的,写了个简易的脚本方便操作,分享一下完整的脚本。

添加脚本的时候,复制下面的代码,把前面四个变量替换成自己的就可以了。(手机上Via浏览器用起来还是很方便的)

// ==UserScript==
// @name         快速上传Alist
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  简单就完了
// @AuThor       52pojie
// @match       *://*.aliyundrive.com/*
// @Icon         https://www.google.com/s2/favicons?sz=64&domain=aliyundrive.com
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_log
// @grant        GM_getValue
// @grant        GM_setValue
// @connect      *
// @run-at document-end
// ==/UserScript==
(function() {
    'use strict';
    const baseUrl = 'http://xxxxxxxx:5244'
    const adminUser = '管理员用户名'
    const adminPwd = '管理员密码'
    const refresh_token = '自行获取云盘的refresh_token(可以通过mt管理器查看日志)'
    const headerPost = async (url, data, headers, type) => {
        return new Promise((resolve, reject) => {
            let option = {
                method: "POST",
                url: url,
                headers: headers,
                data: data,
                responseType: type || 'json',
                onload: (res) => {
                    if (type === 'blob') {
                        resolve(res)
                    } else {
                        const _re = res.response || res
                        .responseText
                        typeof _re === 'string' ? resolve(JSON.parse(_re)) : resolve(_re)
                        }
                },
                onerror: (err) => {
                    reject(err);
                },
            }
            try {
                let req = GM_xmlhttpRequest(option);
            } catch (error) {
                console.error(error);
            }
        });
    };
    async function addStorage({mount_path, share_id, share_pwd = "", root_folder_id = "root", order_by = "", order_direction = ""}){
        return await headerPost(baseUrl + '/api/admin/storage/create',JSON.stringify({
            mount_path: mount_path,
            order: 0,
            remark: '',
            cache_expiration: 30, // 缓存过期时间(分钟)
            web_proxy: false, // 是否开启web代{过}{滤}理
            webdav_policy: "302_redirect", // Webdav策略: 302重定向
            down_proxy_url: "",
            extract_folder: "",
            driver: "AliyundriveShare",
            addition: JSON.stringify({
                refresh_token: refresh_token,
                share_id,
                share_pwd,
                root_folder_id,
                order_by,
                order_direction
            })
        }), {
            "Authorization": GM_getValue('token'),
            "Content-Type": "application/json;charset=UTF-8"
        })
    };
    async function login() {
        const res = await headerPost(baseUrl + '/api/auth/login', JSON.stringify({username: adminUser, password: adminPwd, "otp_code":""}), {"Content-Type": "application/json;charset=UTF-8"})
        if (res.code === 200) {
            GM_setValue('token', res.data.token)
        } else {
            toast("登录失败")
        }
    }
    function toast(msg) {
        const t = (() => {
            if (document.querySelector('#J_single_toast')) {
                return document.querySelector('#J_single_toast')
            } else {
                const _t = document.createElement('div')
                _t.id = 'J_single_toast'
                document.body.appendChild(_t)
                return _t
            }
        })()
        t.innerText = msg
        t.classList.toggle('show')
        setTimeout(() => {t.classList.toggle('show')}, 1500)
    }
    function createCustomDom() {
        let mount_path = `/xx云盘分享_${+new Date}`
        const cBtn = document.createElement('div')
        cBtn.innerText = "创建Alist存储"
        cBtn.className = "cBtn"
        document.body.appendChild(cBtn)
        const dialog = document.createElement('div')
        dialog.className = "mount-path-dialog"
        dialog.innerHTML = `
            <div class="mask"></div>
            <div class="input-wrap">
                <div class="input-item">
                    <p>请输入Alist挂载路径:</p>
                    <input name="mount_path" value=${mount_path}>
                </div>
                <div class="input-item">
                    <p>请输入分享密码:</p>
                    <input name="share_pwd">
                </div>
                <div class="btn-group">
                    <div class="cancel btn">取消</div>
                    <div class="confirm btn">确认</div>
                </div>
            </div>`
        document.body.appendChild(dialog)
        cBtn.addEventListener('click', () => {
            dialog.style.display = 'block';
            dialog.querySelector('[name="mount_path"]').focus();
            dialog.querySelector('[name="mount_path"]').setSelectionRange(1, 999);
        })
        dialog.addEventListener('click', function(e){
            if (Array.from(dialog.querySelectorAll('.mask, .cancel')).includes(e.target)) {
                closeDialog()
            }
            if (e.target === dialog.querySelector('.confirm')) {
                const arr = window.location.pathname.split('/')
                addStorage({
                    mount_path: dialog.querySelector('[name="mount_path"]').value,
                    share_pwd: dialog.querySelector('[name="share_pwd"]').value,
                    share_id: arr[2],
                    root_folder_id: arr[4]
                }).then(res => {
                    if (res.code === 200) {
                        dialog.style.display = 'none'
                        toast('创建成功')
                    } else {
                        toast(res.message)
                    }
                })
            }
        })
        function closeDialog() {
            dialog.style.display = 'none'
        }
    }
    async function init() {
        GM_addStyle(`
        #J_single_toast {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1001;
            display: none;
            background: rgba(0,0,0,0.8);
            color: var(--basic_white);
            padding: 10px;
            max-width: 300px;
            border-radius: 4px;
        }
         #J_single_toast.show {
            display: block;
        }
        .cBtn {
            position: fixed;
            left: 50%;
            transform: translateX(-50%);
            bottom: 80px;
            z-index: 999;
            bottom: calc(constant(safe-area-inset-bottom) + 80px);
            bottom: calc(env(safe-area-inset-bottom) + 80px);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--basic_white);
            background: var(--theme_primary);
            height: 44px;
            padding: 0 16px;
            font-size: 16px;
            border-radius: 22px;
        }
        .mount-path-dialog {
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            z-index: 1000;
            display: none;
            margin: auto;
        }
        .mount-path-dialog .mask {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            background: rgba(0,0,0,0.6)
        }
        .mount-path-dialog .input-wrap {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 300px;
            height: 280px;
            background: #fff;
            border-radius: 10px;
            box-sizing: boder-box;
        }
        .mount-path-dialog .input-wrap .input-item {
            margin-bottom: 8px;
        }
        .mount-path-dialog .input-wrap p {
            font-size: 14px;
            margin-bottom: 5px;
        }
        .mount-path-dialog .input-wrap input{
            display: block;
            width: 240px;
            height: 40px;
            margin: 0 auto 15px;
            font-size: 12px;
            border: 1px solid #ccc;
            padding-left: 8px;
            border-radius: 4px;
        }
        .mount-path-dialog .input-wrap .btn-group {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 260px;
            margin: 0 auto;
        }
        .mount-path-dialog .input-wrap .btn-group .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 1;
            margin: 0 10px;
            height: 40px;
            background: var(--theme_primary);
            color: var(--basic_white);
            font-size: 16px;
            border-radius: 4px;
        }
        .mount-path-dialog .input-wrap .btn-group .cancel {
            background: #fff;
            color: #333;
            border: 1px solid #ccc;
        }
        `)
        await login()
        createCustomDom()
    }
    window.addEventListener ("load", init);
})();


下载地址

· 积分下载:下载扣除对应积分,不扣除下载次数
· VIP免费:VIP会员免费下载,扣除下载次数
· 下载即代表您已阅读并同意 [服务条款]

相关推荐
  • 油猴脚本
  • Alist
  • 利用油猴脚本突破百度网盘下载限速方法

    教程介绍分享一篇自用利用油猴脚本突破百度网盘下载限速方法,手机安卓版,PC版现在已经很难破解了,下载可以达到svip会员效果。油猴脚本百度网盘不限速截图准备软件①Firefox Nightly②idm+③(Tampermonkey)油猴④软件小妹的脚本《百度网盘简易下载助手》...

    经验分享 1757 2年前
  • 油猴脚本去除csdn登录才能复制限制
    油猴脚本去除csdn登录才能复制限制

    作为程序猿,应该会经常去csdn参(chao)考(xi)代码,今天在复制一篇文章的代码的时候,突然发现需要登录才能复制,但是我用github授权登录的时候居然失败了!突发奇想,写个脚本解除这个限制吧!稍微看一下文档结构...

    浏览器插件 126 1年前
  • 百度网盘提取码自动填写油猴脚本
    百度网盘提取码自动填写油猴脚本

    插件介绍百度网盘提取码自动填写油猴脚本,新上线的网盘油猴脚本,它可以实现识别网页中的网盘提取码并自动填写的功能。这款油猴脚本支持自动填充百度云、360盘等的提取码,还额外带有淘宝天猫找优惠...

    浏览器插件 679 3年前
  • B站免登录视频解析下载油猴脚本
    B站免登录视频解析下载油猴脚本

    插件说明B站免登录视频解析下载油猴脚本是一款可以帮助用户在电脑端快速下载哔哩哔哩B站视频的工具,能够帮助用户下载任何自己喜欢的视频内容,使用起来非常方便,无需登陆账户即可使用,有需要的用户不...

    浏览器插件 348 3年前
  • Motrix百度网盘直链下载浏览器脚本v0.0.7
    Motrix百度网盘直链下载浏览器脚本v0.0.7

    脚本说明Motrix百度网盘直链下载浏览器脚本是一款非常好用的百度网盘直链下载工具,搭配Motrix下载软件使用,能够不限速下载。注意事项:此脚本默认会临时分享指定下载的文件,这样才能通过svip账号解析...

    浏览器插件 385 3年前
  • Alist网盘挂载管理工具桌面版v1.0
    Alist网盘挂载管理工具桌面版v1.0

    软件介绍Alist是一款可以支持多种网盘存储的文件列表程序,可以轻松的将各种网盘全部挂载到网页端上,以文件列表的形式呈现,而且可以自动解析网盘下载链接,无需分享网盘链接或登录就可以实现直接下载...

    软件分享 14 3个月前
  • alist+RaiDrive本地硬盘挂载教程

    alist+RaiDrive优势为什么我的站长站要用alist+RaiDrive的组合了?大部分网友都用的CloudDrive,网上一搜本地硬盘挂载基本也都是CloudDrive的教程,但是CloudDrive也有不少问题。1、不开源,所有用户数据全部上传到作者的云上,介意个人隐私泄漏的我就有些不...

    经验分享 684 1年前
  • Alist网盘遍历文件并调用Aria2的API进行批量下载

    import requestsfrom urllib import parseimport jsonfrom Aria2_RPC import Aria2Downloadimport time class AlistDownload: def __init__(self, url): self.headers = { "Accept": "application/json, text/plain, */*",...

    python教程 38 6个月前
  • Alist本地共享系统批处理脚本
    Alist本地共享系统批处理脚本

    脚本介绍Alist本地共享系统批处理脚本,本脚本是方便Alist搭建网盘,可以配置阿里云,123PAN,百度云等网盘挂载为本地,以WEBDAV的形式挂载。比网上的教程要方便好用。本脚本的特色自动下载最新的Alist,并...

    浏览器插件 76 1年前
  • Alist快速添加云盘分享存储油猴脚本
    Alist快速添加云盘分享存储油猴脚本

    alist添加存储的时候,每次都要来回切换复制粘贴id,挺费劲的,写了个简易的脚本方便操作,分享一下完整的脚本。添加脚本的时候,复制下面的代码,把前面四个变量替换成自己的就可以了。(手机上Via浏览器用起...

    浏览器插件 29 1年前