// ==UserScript== // @name TheWest Tool Importer // @version 1.10 // @description WikiTheWest Tool // @author Thathanka Iyothanka & mlot // @include http*://*.the-west.*/game.php* // @include http*://*.the-west.*.*/game.php* // @grant none // @namespace https://greasyfork.org/users/105168 // @downloadURL none // ==/UserScript== (function (fn) { var script = document.createElement('script'); script.setAttribute('type', 'application/javascript'); script.textContent = '(' + fn + ')();'; document.body.appendChild(script); document.body.removeChild(script); }) (function () { WTWTI = { scriptName: "WikiTheWest Tool Importer", version: "1.10", gameMAX: Game.version.toString(), author: "Thathanka Iyothanka & mlot", gameMIN: "1.36", website:"https://greasyfork.org/fr/scripts/18817", updateURL:"https://phasma.fhb-ht.org/last_version.js", }; WTWTI.initialize=function(){ //Check Updates $.getScript( WTWTI.updateURL, function() { if(WTWTIUpdateVersion > WTWTI.version){ var updatedialog = new west.gui.Dialog('WikiTheWest Tool Importer', 'Une nouvelle mise à jour est disponible' + ' (v' + WTWTIUpdateVersion + ')', west.gui.Dialog.SYS_WARNING).addButton('Download', function () { updatedialog.hide(); location.href = WTWTI.website + '/code.user.js'; }).addButton('cancel').show(); } }); WTWTI.launch(); /* Ajout du bouton de redirection */ var url = "https://phasma.fhb-ht.org/index.php"; QuestEmployerView.showQuestOrigin=QuestEmployerView.showQuest; QuestEmployerView.showQuest=function(quest){QuestEmployerView.showQuestOrigin(quest);$('.quest_button_area_'+quest.id).append(getLink(quest.id));}; eval("Quest.updateQuest="+Quest.updateQuest.toString().slice(0,-1)+"$('.quest_button_area_'+this.id).append(getLink(this.id));}"); function getLink(id){return $('').on('click',function(){ WTWTI.import(function(res){ if (res.slice(0, 3)!=='Ok:'){ new MessageError(res).show(); } else { showlink(url+'?redirect_quest='+id+'&key='+res.slice(3)); } }); });} }; WTWTI.import=function(callback_function){ var data_inv = ''; var inv = {}; for(var item_id in Bag.items_by_id) { inv[item_id]=$.extend(true, {}, Bag.items_by_id[item_id]); } for(var type in Wear.wear) { var itemid = Wear.wear[type].obj.item_id; if (inv[itemid]){ inv[itemid].count++; } else { inv[itemid]={count:1}; } } for(var id in inv) { data_inv+= id + ':' + inv[id].count + ','; } data_inv=data_inv.slice(0,-1); var data_skills=''; for(var att in CharacterSkills.attributes) { data_skills+= CharacterSkills.attributes[att].points + ','; } for(var apt in CharacterSkills.skills) { data_skills+= CharacterSkills.skills[apt].points + ','; } var completed_quests = ''; Ajax.remoteCallMode('building_quest','get_solved_groups',{},function(json){ for (var i in json.solved){ for (var id in json.solved[i].quests){ if ($.isNumeric(id)) completed_quests+=id+',';} } completed_quests=completed_quests.slice(0,-1); $.post( "https://phasma.fhb-ht.org/import.php", {name:Character.name, world:Game.worldName, data:data_inv, skills:data_skills.slice(0,-1),level:Character.level,quests:completed_quests},function(res){callback_function(res);},'text'); }); }; WTWTI.launch=function(){ var icon = $('
').attr({ 'class': 'menulink', 'title': 'Importe tes données' }).css({ 'background': 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAEeklEQVR4nO2V32pd1xHGf7P2PkdSJR1Hsq0EOariKsap8/8iJqYktKGQQoJz10JD3iEXhfYJSi+SXBT8BHVLCS3tRSCB5gkCCo1T7DqJExlHPoltyTpHkqW911rz9WLvcyRMIS+QBYs9bGbPzDfzfbPh+/Mdx0bGF+//9ncTvaXfWDkxbxYwK8AC1b1tNm9eoyw7FEWBECkl5hdP0Z2cRji4Izko47narIfrb6384vd/GCf47L03X+/OnviT1zsGwkJHFkqzULJ9d0PXL39knW6XoiiRpJSiLT9+TtO9OZNnpCR5MnkETEVnmnqn/8apV97+cwBAOu/1Dsp1i0djiJKTUiTWNXVVUdcVKcam4pGvRheUa3LcMfDzAGXr1M1xFwulDpwl5Lg7sa7l7pgFQLi73DOSN1GbO7Y93pOk7kECCZRBhSEfBTcUkCfVdWVFzpgZgNzdlLOQm+RILt1no6YLZQPSQcLk0A5LMpDhORHrihwSZtbW6rgnpAye22/uu/hBAtzBMlIQCiDHlIUbOSfqqpKFMEKAJHmOyLNQphl0lpRpUGTJDyVoKjGwYMjAEWAE8BxV1fsWLIwQSJLlHIUna4Jm4dnwDN7aygCEUYIWruRtJZ4kT/IcSTEqlB1V1b7KstMMPcWxjzw1tpKkNEZzqEWpJVzTBIEwGYico54591ObO7bAh//8K8///FXdvnnDPEfJo41agnKjCc9yRYtFdaDky+++/g8L5WsWOmahhFDIrDALBTm7yrJrWGB7sMXskQcEWKz3VXY6RsscPJuUSFT6fOWm7U7tXa1971wzgxbBgcgEJpATLCCPYMbM7HRjA2XRvle7JjwTreLqo33Wy8uQ/PRkufD3NkEci0W0dA2FZAVmARE0YlAKmdILiQMxSpk61Lqy8i3rdhmyC2A3337vEAIhsGAFWMMUQwjJzE0ybhzd4Mtj3+jH/SU7vjUlJBNOFWr950e37aZfRW4yClveOPbBr362+s4YgeRM//Bl7pRPMxgMGAy2mJycYnHxBJubG7Cwzr/DH6l2hwyPbvNY9yQn+z+gKhKfPLLJevwcFDDg6f4iS3d7+4d0ICDDxLwuffwJa2tfcX3tK/V6PX7ywotc/e8VTRzfIz1bkLsFddzWx93PuLO8rL1Q0d9fAwoZxtlvHmRpOKPRMgxAQ04Jdzcf7RRkkszdccmK3WN2629P2kPF81R1abt7iSt712xt92ur6pJYdezs1w/Zw8OZNqQd3kX0AeLGp5xePsPi/ApPPHqcyclJFhammJ86SdnpcGqpx5lhzepwjdWZLUYLu8R4aXOepWqq6Uaj+P44QZ9nLzxon/463l7tzbHKHEAHkYE+zDYaBKBehyeZ0dH9Dv+aGao25+XtBzhRdxtmAZlycIvHL8D72MWLF58DftnV9tk5XXuqpJpoBVhw6Jf6/869ICpz5nLRDhElJqq7tnKpttmPJP2lBC4B6xUzR74Nz8wAPUmlmR0BOpLGW3RECDNrnhgIdk3RzAZAkjQ0sx1gAGz8D3JhVPPfHpieAAAAAElFTkSuQmCC)', 'background-position': '0px 0px' }).click(function () { WTWTI.import(function(res){ if (res.slice(0, 3)!=='Ok:'){ new MessageError(res).show(); } else { new MessageSuccess('Succès !').show(); showlink('https://phasma.fhb-ht.org/index.php?key='+res.slice(3), '_blank'); } }); }); var bottom = $('
').attr({ 'class': 'menucontainer_bottom' }); $('#ui_menubar .ui_menucontainer:last').after($('
').attr({ 'class': 'ui_menucontainer', 'id': 'Import' }).append(icon).append(bottom)); }; WTWTI.initialize(); });