Avatar Builder+ Alternative

you can change your avatar/pfp to any image (animated images are not working)

当前为 2022-04-23 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Avatar Builder+ Alternative
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  you can change your avatar/pfp to any image (animated images are not working)
// @author       Vholran
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @match        https://*.drawaria.online/avatar/builder/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=drawaria.online
// @grant        none
// ==/UserScript==

(function ($, undefined) {
    $(function () {

        let wait;
        Start();

        function Start(){
            wait = setInterval(function(){
                if($('.Canvas').length === 1){
                    AvatarAlt();
                }
            }, 200);
        }

        function AvatarAlt(){
            clearInterval(wait);
             $('header').append('<label class="Button" for="image_input">Upload Image</label><input style="display:none" id="image_input" type="file" accept="accept="image/*">');

            let uploaded_image;
            $("#image_input").change(function() {
                const reader = new FileReader();

                reader.addEventListener('load', function (){
                    uploaded_image = reader.result;
                    ChangeAvatar(uploaded_image);

                });
                reader.readAsDataURL(this.files[0]);

            });

        }
        function ChangeAvatar(imageData) {
            var canvas=document.getElementsByClassName("main")[0];
            var ctx=canvas.getContext("2d");
            var img=new Image();
            img.onload = function(){
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.drawImage(img,0,0,canvas.width,canvas.width);
            };
            img.src=imageData;
        }

    });

})(window.jQuery.noConflict(true));