Avatar Builder+ Alternative

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

目前為 2022-04-05 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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));