复制魅族云相册 Token

一键复制魅族云相册的 Token

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         复制魅族云相册 Token
// @namespace    moreant.mzStorage.getToken
// @version      0.1.1
// @description  一键复制魅族云相册的 Token
// @author       moreant
// @match        https://photos.flyme.cn/*
// @icon         https://www.google.com/s2/favicons?domain=flyme.cn
// @grant        GM.setClipboard
// ==/UserScript==
var observer = new MutationObserver(callback);
(function() {
    'use strict';

    // Your code here...
    observer.observe(document,{
        childList: true,
        subtree: true
    });

})();

function callback(){
    var button = document.createElement("button");

    let bar = document.querySelector("#root > div > header")
    if(bar!= null ||bar!=undefined){
        setTimeout(function () {
            console.log("ok")
            button.style.marginTop = '23px'
            button.append("复制 Token")
            button.addEventListener('click',function(){getCookie("_utoken")});
            bar.append(button);

        },0)
        observer.disconnect();
    }
}

function getCookie(name) {
    console.log("copy")
    var arr,
        reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
    if ((arr = document.cookie.match(reg))) {
        GM.setClipboard( decodeURIComponent(arr[2]))
    } else {
        return null
    }
}