阿里云盘refresh_token

一键复制阿里云盘refresh_token

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         阿里云盘refresh_token
// @namespace    https://www.aliyundrive.com/
// @version      0.7
// @description  一键复制阿里云盘refresh_token
// @author       生瓜太保
// @match        https://www.aliyundrive.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=aliyundrive.com
// @homepage     https://greasyfork.org/zh-CN/scripts/449160
// @supportURL   https://greasyfork.org/zh-CN/scripts/449160
// @grant        GM_setClipboard
// @grant        GM_registerMenuCommand
// @connect      *
// @grant        unsafeWindow
// @grant        GM_notification
// @compatible   chrome
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    GM_registerMenuCommand('📋 复制refresh_token', copyToken)
    GM_registerMenuCommand('👁 显示refresh_token', showToken)

    function getToken() {
        try {
            return JSON.parse(unsafeWindow.localStorage.token).refresh_token
        } catch (e) {
            console.error(e)
            alert(`获取refresh_token失败:"${e.toString()}"!请确认已登录。如已登录,请按F12查看Console。`)
        }
        return ''
    }

    function copyToken() {
        const token = getToken()
        if (token) {
            GM_setClipboard(token)
            GM_notification({
                text: '已复制refresh_token',
                timeout: 3e3
            })
        }
    }

    function showToken() {
        const token = getToken()
        if (token) {
            prompt('refresh_token:', token)
        }
    }
})()