随手记

账号汇总

目前為 2021-05-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name           随手记
// @description    账号汇总
// @author         018([email protected])
// @contributor    Rhilip
// @connect        *
// @grant          GM_xmlhttpRequest
// @grant          GM_setClipboard
// @grant          GM_addStyle
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_listValues
// @grant          GM_deleteValue
// @grant          GM_registerMenuCommand
// @require        https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require        https://greasyfork.org/scripts/420063-018-js/code/018js.js?version=890174
// @include        https://www.sui.com/account/account.do
// @include        https://www.sui.com/tally/new.do
// @version        0.1.0
// @icon           https://res.sui.com/favicon.ico
// @run-at         document-end
// @namespace      http://018.ai
// ==/UserScript==

// This Userscirpt can't run under Greasemonkey 4.x platform
if (typeof GM_xmlhttpRequest === 'undefined') {
    alert('不支持Greasemonkey 4.x,请换用暴力猴或Tampermonkey')
    return
}

;(function () {
    'use strict';

    $(document).ready(function () {
        $('#mainContent').css('margin', '-371px auto 0px 60px')
        $('.footer').hide()
        refresh();
    })

    function refresh() {
        if (window.location.href === 'https://www.sui.com/account/account.do') {
            handle(document)
        } else {
            $('#bg1-c').html('<dir style="padding: 30px 0 0 1090px;">...</div>')
            loadDoc('https://www.sui.com/account/account.do', {}, function(doc, responseDetail, meta) {
                handle(doc)
            })
        }
    }

    function handle(doc) {
        var html = '<table>'
        $(doc).find('.j-acc-show').each(function() {
            html += '<tr><td>' + $(this).find('.acc-name').text() + '</td><td><span style="font-weight: bold;">' + $(this).find('.child-r1 .child-r1-money').text() + '</span><td></tr>'
        });

        html += '</tr></table>'
        $('#bg1-c').html('<dir style="padding: 30px 0 0 1090px;">' + html + '<button id="btn-refresh">刷新</button></div>')

        $('#btn-refresh').click(function(){
            if (window.location.href === 'https://www.sui.com/account/account.do') {
                location.reload()
            } else {
                refresh()
            }
        })

    }
})()