// ==UserScript==
// @name         Green Acfun
// @namespace    http://Acfun.cn/*
// @version      1.0.1
// @description  Change Ac avatar to greeen
// @author       Rekkles
// @match        *://acfun.*/*
// @grant        none
// @downloadURL none
// ==/UserScript==
(function () {
    'use strict';
    var bool = false;
    var isset = true;
    function MakeGreen() {
        if (isset) {
            $(".edui-btn-emotion").click(function () {
                if (!bool) {
                    var arr = [
                        [],
                        [54, '', '绿娘', 'https://pan.baidu.com/s/1i5gd8gt', 'jgad', 'png'],
                        [40, '10', '匿名绿娘', 'https://pan.baidu.com/s/1hr8VHVQ', 'v8cs', 'png'],
                        [55, '20', '新娘绿娘', 'https://pan.baidu.com/s/1hr8VHVQ', 'v8cs', 'png'],
                        [41, 'ColorG', '动态彩娘', 'https://pan.baidu.com/s/1gfLzAtt', 'ttki', 'gif'],
                        [114, 'AcColor', '旧版彩娘', 'https://pan.baidu.com/s/1gfLzAtt', 'ttki', 'png'],
                    ];
                    for (var s = 1; s <= arr.length - 1; s++) {
                        var num = 0;
                        var index = $('.edui-emotion-Jtabnav .edui-tab-item').length;
                        $('.edui-tab-item:last').after("
" + arr[s][2] + "");
                        var html = '';
                        html += '
';
                        var baseURL = 'http://yimeicrm.cn/umeditor/dialogs/emotion/images/ac/' + arr[s][1];
                        for (var i = 1; i <= arr[s][0]; i++) {
                            if (i == 1 || (i + num) % 12 === 0) {
                                html += '';
                            }
                            var posflag = 1;
                            var str = i < 10 ? '0' : '';
                            var url = baseURL + str + i + '.' + arr[s][5];
                            var po = posflag < 5 ? 0 : 1;
                            html += '  | ';
                            if (i % 11 === 0) {
                                html += '
';
                                num++;
                            }
                            if (i == 11 || i == 22 || i == 33 || i == 44 || i == 55) {
                                posflag = 1;
                            }
                            posflag++;
                        }
                        html += " 
当前页绿娘表情包下载!!! 密码: " + arr[s][4] + "喜欢的可以捐助 ";
                        $('.edui-tab-pane:last').after(html);
                        $('.edui-tab-item:last').click();
                    }
                    bool = true;
                }
            });
            isset = false;
        }
    }
    function setImgClass() {
        $('img').each(function () {
            if ($(this).attr('src') !== '' && $(this).attr('src') !== null && $(this).attr('src') !== undefined) {
                var str = $(this).attr('src');
                if (str.indexOf('http://yimeicrm.cn') >= 0) {
                    $(this).attr('class', 'emotion');
                }
            }
        });
        $('.name').css('color', 'green');
        $('.btn-quote').css('color', 'green');
        $('.index-comment').css('color', 'red');
        $('.btn-report').css('color', 'red');
        $('#area-comment-inner .avatar').each(function () {
            if ($(this).next('img').length > 0) {
                $(this).next('img').attr('src', 'http://i2.muimg.com/567571/221d33169d92b9ad.png').attr('class', 'avatar-bg-sp2017');
            } else {
                $(this).after('
');
            }
        });
        $('#area-comment-inner  .avatar').css('border-radius', '50%');
        if (window.location.href == 'http://www.acfun.cn/member/#area=mention') {
            $('.btn-img').each(function () {
                var href = $(this).attr('href');
                if (href.indexOf('http://yimeicrm.cn') >= 0) {
                    $(this).after('
');
                    $(this).remove();
                }
            });
        }
    }
    window.setInterval(MakeGreen, 2000);
    window.setInterval(setImgClass, 1500);
})();