NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name CA - Send Gifts // @namespace CA Send Gifts // @description Send gifts to certain people on web3 castle age // @include https://web3.castleagegame.com/castle_ws/* // @exclude https://web3.castleagegame.com/castle_ws/connect_login.php // @require http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js // @version 1 // @grant GM_registerMenuCommand // @grant GM_xmlhttpRequest // ==/UserScript== var gNames = []; var gID = []; var friends = ["17508595","529963647"]; var insertt = '<div id=\'innert\'><center><select id="gifter">'; $.get( "gift.php", function( data ) { if(/padding\:10px 0 0 0;">+(.*)<\/div>/gi.test(data)) { var reName = /padding\:10px 0 0 0;">+(.*)<\/div>/gi; var reNum = /'gift\.php\?giftSelection\=+(.*)'\); return/gi; var m; while ((m = reName.exec(data)) != null) { if (m.index === reName.lastIndex) reName.lastIndex++; gNames.push(m[1]); } while ((m = reNum.exec(data)) != null) { if (m.index === reNum.lastIndex) reNum.lastIndex++; gID.push(m[1]); } } }); function getgifts(){ for(var i = 0; i<gID.length;i++){ insertt += '<option value="'+gID[i]+'">'+gNames[i]+'</option>'; } insertt += '</select> <button id=\'sento\'>Send</button></center></div>'; $(insertt).insertBefore("#app_body"); $( "#sento" ).click(function() { var hm =document.getElementById("gifter").value; var t = document.getElementById('gifter'); console.log(hm); var giftName = t[t.selectedIndex].innerHTML; var url = "https://web3.castleagegame.com/castle_ws/gift.php?"; for(var i = 0; i < friends.length; i++){ if(i==0) url += "selected_army%5B%5D=" + friends[i]; else url += "&selected_army%5B%5D=" + friends[i]; } url += "&action=send_non_facebook_gift&giftSelection="+hm; $.post(url, function(data,status){ if(/You have sent /.test(data)) { document.getElementById('innert').innerHTML = "<center>You sent <b>" + giftName + "</b> to your army member friends.</center>"; } else{ document.getElementById('innert').innerHTML = "<center>You failed to send <b>" + giftName + "</b> to your army member friends.</center>"; } }); }); } GM_registerMenuCommand('CA - Send Gift to Friend', getgifts);