阿里云盘签到

阿里云盘每天自动签到 本脚会提交你的token到服务端 作者承诺只做阿里云盘的签到使用 介意勿装

As of 2023-02-02. See the latest version.

// ==UserScript==
// @name         阿里云盘签到
// @namespace    https://yiso.fun
// @version      0.0.2
// @author       yiso
// @match        https://www.aliyundrive.com/*
// @icon         https://img.alicdn.com/imgextra/i1/O1CN01JDQCi21Dc8EfbRwvF_!!6000000000236-73-tps-64-64.ico
// @description  阿里云盘每天自动签到 本脚会提交你的token到服务端 作者承诺只做阿里云盘的签到使用 介意勿装
// @run-at       document-body
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// @connect      yiso.fun
// @antifeature tracking 阿里云盘每天自动签到 本脚会提交你的token到服务端 作者承诺只做阿里云盘的签到使用 介意勿装
// ==/UserScript==
(function() {
    'use strict';
    unsafeWindow = unsafeWindow || window;
    var $ = $ || window.$;
    //当前浏览器的地址
    let url = window.location.href
    var visitorId;
    if (url.includes('https://www.aliyundrive.com/drive', 0)) {
        setTimeout(function() {
            getVisitorId();
            aliHomeButtonHeader();

        },
                   1000)
    }

    /**
     *alihome页导航栏按钮
     */
    function aliHomeButtonHeader() {
        let header = document.querySelector('.nav-menu--1wQUw');
        if (header == null) {
            setTimeout(function() {
                aliHomeButtonHeader();
            },
                       1000)
        }
        setAliYunSign(header);
    }



    /**
     * 阿里云签到初始化
     */
    function setAliYunSign(header) {
        // Initialize the agent at application startup.


        let div = document.createElement('div');
        div.innerHTML = '<li class="nav-menu-item--2oDIG"><input id="emailInput" value="" type="text" style="width: 260px;height: 38px; border:1px" placeholder="输入邮箱自动签到失败会通知你"/></br></li>'
            +'<li class="nav-menu-item--2oDIG"> '
            +'<span class="nav-menu-item-icon--23nDR">'
            +'<span data-role="icon" data-render-as="svg" data-icon-type="PDSFavorite" class="icon--d-ejA ">'
            +'<svg t="1675234646771" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1469" width="64" height="64"><path d="M704 170.666667H320v53.333333a21.333333 21.333333 0 0 1-42.666667 0V170.666667h-42.666666a106.666667 106.666667 0 0 0-106.666667 106.666666v85.333334h768v-85.333334a106.666667 106.666667 0 0 0-106.666667-106.666666h-42.666666v53.333333a21.333333 21.333333 0 0 1-42.666667 0V170.666667z m42.666667-42.666667h42.666666a149.333333 149.333333 0 0 1 149.333334 149.333333v512a149.333333 149.333333 0 0 1-149.333334 149.333334H234.666667a149.333333 149.333333 0 0 1-149.333334-149.333334V277.333333a149.333333 149.333333 0 0 1 149.333334-149.333333h42.666666V96a21.333333 21.333333 0 0 1 42.666667 0V128h384V96a21.333333 21.333333 0 0 1 42.666667 0V128z m149.333333 277.333333H128v384a106.666667 106.666667 0 0 0 106.666667 106.666667h554.666666a106.666667 106.666667 0 0 0 106.666667-106.666667V405.333333zM327.210667 642.304a21.333333 21.333333 0 0 1 28.245333-32l98.048 86.549333a21.333333 21.333333 0 0 0 29.866667-1.642666l179.882666-197.568a21.333333 21.333333 0 0 1 31.552 28.714666l-179.861333 197.568a64 64 0 0 1-89.664 4.906667l-98.069333-86.528z" fill="#d81e06" p-id="1470"></path></svg>'
            +'</span>'
            +'</span>'
            +'<div class="name-wrapper--2dumt">'
            +'<span class="sign" style="color:red">自动签到</span>'
            +'</div>'
            +'</li>';
        header.insertBefore(div, header.children[0]);
        let sign = document.querySelector('.sign');
        sign.addEventListener('click',() =>{
            var RegEmail = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            let emailNotify = document.getElementById("emailInput").value;
            if(!RegEmail.test(emailNotify)){
                alert('邮箱不合法') ;
                return;
            }
            let tokenInfo= localStorage.getItem('token');
            let visitorId= localStorage.getItem('alising_visitorId');
            if(visitorId==null||visitorId==undefined||visitorId == ''){
                getVisitorId();
                visitorId= localStorage.getItem('alising_visitorId');
            }
            let tokenInfoJson=JSON.parse(tokenInfo);
            let user_id=tokenInfoJson.user_id;
            let lastdata='aliUserId='+tokenInfoJson.user_id+'&token='+tokenInfoJson.access_token+'&userName='+tokenInfoJson.user_name+'&nickName='+tokenInfoJson.nick_name+'&email='+emailNotify;
            GM_xmlhttpRequest({
                method: "post",
                url: 'https://yiso.fun/api/ali/sign',
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded"
                },
                data:lastdata,
                onload: function(r) {

                    let resultJson = JSON.parse(r.response);
                    if (resultJson.code != null) {
                        if (resultJson.msg != "SUCCESS") {
                            alert(resultJson.msg);
                            return;
                        }else{
                            alert('自动签到提交成功');
                        }
                    } else {
                        alert('系统异常,请稍微再试');
                    }
                }
            });

        });
    }

    /**
     * 获取浏览器唯一标识
     */
    function getVisitorId(){
        // Initialize the agent at application startup.
        const fpPromise = import('https://openfpcdn.io/fingerprintjs/v3')
        .then(FingerprintJS => FingerprintJS.load())

        // Get the visitor identifier when you need it.
        fpPromise
            .then(fp => fp.get())
            .then(result => {
            // This is the visitor identifier:
            const visitorId = result.visitorId;
            localStorage.setItem('alising_visitorId',visitorId);
        })
    }

    // Your code here...
})();