Greasy Fork is available in English.

AMALL

makes giving back Llamas on deviantart.com way easer

// ==UserScript==
// @name				AMALL
// @namespace			AMALL
// @description			makes giving back Llamas on deviantart.com way easer
// @match				*://*.deviantart.com/notifications/*
// @match       		*://*.deviantart.com/modal/badge/*
// @author				http://dediggefedde.deviantart.com ,http://nuckchorris0.deviantart.com
// @version				1.05
// @grant				unsafeWindow
// ==/UserScript==
(function(){
try {
	var statuses="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAPCAYAAACshzKQAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89%2BbN%2FrXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz%2FSMBAPh%2BPDwrIsAHvgABeNMLCADATZvAMByH%2Fw%2FqQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf%2BbTAICd%2BJl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA%2Fg88wAAKCRFRHgg%2FP9eM4Ors7ONo62Dl8t6r8G%2FyJiYuP%2B5c%2BrcEAAAOF0ftH%2BLC%2BzGoA7BoBt%2FqIl7gRoXgugdfeLZrIPQLUAoOnaV%2FNw%2BH48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl%2FAV%2F1s%2BX48%2FPf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H%2FLcL%2F%2Fwd0yLESWK5WCoU41EScY5EmozzMqUi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RrNZUQ2mD2vliz5XW6M%2BhWrpMZqiz65uds7WwReh3EazrBaSvxul1H%2FlJVao61Fndzsna0tvE6HNAznK%2Fhe10NIw41hRhgJhDK49RqB77K9dipqUQXfXV5FKcnx4DqTaEguJK5bJwg6rK3vVKIWVfB%2BsIPRGXH0LmEYkmaGZqPGynKDpZVPVKIWVfCrnQ2kFvTDDwjDEJkp3EYdv9vizNq5StSiCr6zsYEWgvCDks2UolGv0221WDt3rhI1U8F%2FdG3Y7TSRypDmGt9z8Zr1Kk33WhsGnS7GaLI0puUHMzXYvdaGnr%2BBNaJcGzaWqLt%2BlaZ7rQ2X2z2klqQixvcCPNer0nSvtWG710NLiYhjvCDA9bwqTQvXhv9%2F6nDvpw7%2FGwBsFTy4%2FVM01wAAAABJRU5ErkJggg%3D%3D";


	if (unsafeWindow.location.href.indexOf('notifications') !== -1) {
		var contentEval = function(source) {
			if ('function' == typeof source) {
				source = '(' + source + ')();';
			}
			var script = document.createElement('script');
			script.setAttribute("type", "application/javascript");
			script.textContent = source;
			document.body.appendChild(script);
			document.body.removeChild(script);
		};
		var sty=document.createElement("style");
		sty.type="text/css";
		sty.innerHTML='span.amall-give { background-image: url(' + statuses + ') !important; background-position: 0 0 !important; } span.amall-working { background-position: -15px 0 !important; } span.amall-already { background-position: -30px 0 !important; } span.amall-success { background-position: -45px 0 !important; } span.amall-error { background-position: -60px 0 !important; }';
		document.head.appendChild(sty);

		contentEval(()=>{

			DWait.ready(["jms/pages/messagebox.js"],()=>{

				var Llamacheckall=function(){
					$(".amall-give:not([pruf])").each(function(){
						if(typeof $(this).attr("pruf")!="undefined")return;

						var u=$(this).parent().find("a.u").html();
						if(u===null)return;
						$(this).attr("pruf",u);

						DiFi.pushPost("User","getGiveMenu",[u],(success, data)=>{
							if (success&&data.response.content.html.indexOf("Give a <span>Llama Badge")===-1)
								$(".amall-give[pruf="+u+"]").addClass('amall-already').removeClass('amall-working');
						});
					});
					DiFi.send();
				};
				setInterval(()=>{
					if ($('.mcbox.mcbox-list.mcbox-list-generic .mcdx:hidden:not([amall])').length > 0){
						$('.mcbox.mcbox-list.mcbox-list-generic .mcdx:hidden:not([amall])').each(function(){
							$(this).attr("amall","1");
							$(this).addClass('amall-give').css({
								'display': 'block',
								'background-position': '0 -15px'
							}).attr('onclick','').unbind('click').bind('click',function(e){
								Llama($(this).parent().find("a.u").html(),$(this));
								return false;
							}).bind('mousedown',function(){
								return false;
							});
						});
						Llamacheckall();
					}
				},1000);
				var Llama = function(u,s){
					if(u===null)return;
					s.addClass('amall-working');
					DiFi.pushPost("User","getGiveMenu",[u],(success, data)=>{
						if (success) {
							if (data.response.content.html.indexOf("Give a <span>Llama Badge")===-1){
								// [STATUS] ALREADY GAVE A LLAMA
								s.addClass('amall-already').removeClass('amall-working');
							} else if(data.response.content.html.indexOf("give Llama")==-1){
								var userNum= /data-userid="(\d+)"/gi.exec(data.response.content.html)[1];
								//var userNum = /Badges\.buildModal\(\'llama\', (\d+)\)/.exec(clicky)[1];
								var el=$('<embed>').attr('src',
								'https://www.deviantart.com/modal/badge/give?badgetype=llama&to_user='+userNum+'&referrer=http://my.deviantart.com&amall=1').css({'height': 0, 'width': 0});
                 var retfunc=function(){
							    s.addClass('amall-success').removeClass('amall-working');
                  $("span.amall-give[pruf='"+s.attr("pruf")+"']").addClass('amall-already').removeClass('amall-working');
									// DOUBLE CHECK THAT IT SENT
                  DiFi.pushPost("User","getGiveMenu",[u],(success, data)=>{
                    if (success) {
                      if (data.response.content.html.indexOf("Give a <span>Llama Badge")!==-1){
                        s.addClass('amall-error').removeClass('amall-working');
                      }
                    }
                  });
				  setTimeout(()=>{
                    DiFi.send();
                  },1000); //time for server to register llama.
									//$(this).remove();
								};
                el.get(0).onload=retfunc;
                el.appendTo("body");
							}else{
								s.addClass('amall-error').removeClass('amall-working');
							}
						} else {
							// [STATUS] ERROR
							s.addClass('amall-error').removeClass('amall-working');
						}
					});
					DiFi.send();
				};
			});
		});
	} else if(unsafeWindow.location.href.indexOf('badgetype=llama') !== -1 && unsafeWindow.location.href.indexOf('amall=1') !== -1) {
		document.getElementsByTagName('form')[0].submit();
	}
} catch (e){
}
})();