// ==UserScript==
// @name TWeaker
// @description TWeaker by Vbyec
// @author Vbyec
// @license MIT
// @version 0.1.7
// @nocompat Chrome
// @grant none
// @include http://*.the-west.*/game.php*
// @history 0.1.4 Add Kick-o-matic autoload
// @history 0.1.5 Add English
// @history 0.1.6 Add Items controls and search
// @history 0.1.7 Add Spanish
// @namespace https://greasyfork.org/users/2707
// @downloadURL https://update.greasyfork.org/scripts/3611/TWeaker.user.js
// @updateURL https://update.greasyfork.org/scripts/3611/TWeaker.meta.js
// ==/UserScript==
function exec(fn) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + fn + ')();';
document.body.appendChild(script); // run the script
document.body.removeChild(script); // clean up
}
exec(function() {
Tweaker = {
"scriptName": "Tweaker",
"scriptId": "409876",
"version": '0.1.4'
};
Tweaker.langs = {
"ru_RU": {
"TotalDamage": "Урона за бой",
"LastHit": "Последний выстрел",
"KillShot": "Скальп",
"ChangeWith": "смена с"
},
"en_US": {
"TotalDamage": "Total damage",
"LastHit": "Last hit",
"KillShot": "Kill Shot",
"ChangeWith": "change with"
},
"es_ES": {
"TotalDamage": "Daño Total",
"LastHit": "Último tiro",
"KillShot": "Desmayo",
"ChangeWith": "cambiar con"
}
};
Tweaker.getLang = function() {
return Tweaker.langs.hasOwnProperty(Tweaker.getLocale()) ? Game.locale : "es_ES";
};
Tweaker.getLocale = function() {
return Game.locale;
};
var lang = Tweaker.getLang();
Tweaker.lang = Tweaker.langs[lang];
//add Auto load Kick-o-matic
if (localStorage.hasOwnProperty("AutoLoad_Kick-o-matic")) {
if (localStorage["AutoLoad_Kick-o-matic"]) {
var MyScript = TheWestApi.register('Kick-o-matic', 'Kick-o-matic', '2.08', '2.20', 'Macabre2077', 'http://userscripts-mirror.org/scripts/show/96262');
MyScript.loadScript('http://Vbyec.ru/96262.user.js');
}
} else {
localStorage.setItem('AutoLoad_Kick-o-matic', 1);
}
// local DataBase of items.
window.Items = {
room: '',
add_item: function(id, name) {
localStorage.setItem("ItemId_" + id, name);
return true;
},
get_name: function(id) {
return localStorage.getItem("ItemId_" + id);
},
search: function(query) {
localStorage.getItem("Item_count") ? "" : Items.init();
for (var key in localStorage) {
if (typeof key === 'string' && key.indexOf('ItemId') === 0) {
var index = key.split('_')[1];
if (Items.get_name(index).toLowerCase().indexOf(query.toLowerCase()) >= 0) {
Items.show_in_chat('item=' + index + " : " + '[item=' + index + ']');
}
}
}
},
check: function() {
var count = 0;
for (var i = 0; i < 999999; i++) {
var item = ItemManager.get(i);
if (item !== undefined) {
count++;
}
}
var prev_count = localStorage.getItem("Item_count") === null ? 0 : localStorage.getItem("Item_count");
if (prev_count < count) {
new UserMessage("Parece que hay ropa nueva", UserMessage.HINT).show();
Items.show_new();
}
else {
Items.show_in_chat('No new items');
}
},
show_new: function() {
for (var i = 0; i < 999999; i++) {
var item = ItemManager.get(i);
if (item !== undefined && Items.get_name(item.item_id) === null) {
Items.show_in_chat('item=' + item.item_id + " : " + '[item=' + item.item_id + ']');
}
}
},
init: function() {
if (localStorage.getItem("Item_count") === null) {
Items.add_all();
}
else {
Items.check();
}
},
add_all: function() {
var count = 0;
for (var i = 0; i < 999999; i++) {
var item = ItemManager.get(i);
if (item !== undefined && Items.get_name(item.item_id) === null) {
Items.add_item(item.item_id, item.name);
count++;
}
}
if (count > 0) {
var prev_count = localStorage.getItem("Item_count") === null ? 0 : localStorage.getItem("Item_count");
localStorage.setItem("Item_count", parseInt(prev_count) + count);
Items.show_in_chat("Items added:" + count);
}
else {
Items.show_in_chat("No item to add");
}
},
show_in_chat: function(text) {
Items.room.addMessage(Game.TextHandler.parse(text) + '
');
}};
Chat.Operations["^\/items$"] = {
cmd: "items",
shorthelp: "Configuración inicial de artículos en la base de datos local.",
help: "La configuración inicial de la base de datos local, si ya existe la base de datos, comprueba los artículos nuevos",
usage: "/Items",
func: function(room, msg) {
Items.room = room;
Items.init();
}};
Chat.Operations["^\/items\.s (.+)$"] = {
cmd: "items.s",
shorthelp: "Búsqueda por nombre de artículo",
help: "Buscar por nombre de artículo, minúsculas",
usage: "/items.s parte del nombre",
func: function(room, msg, search) {
Items.room = room;
Items.search(search[1]);
}};
Chat.Operations["^\/items\.add$"] = {
cmd: "items.add",
shorthelp: "Agregar nuevos artículos a la base de datos local",
help: "Agregar nuevos artículos a la base de datos local, los que no se muestran en el registro",
usage: "/items.add",
func: function(room, msg) {
Items.room = room;
Items.add_all();
}};
FortBattleWindow.showBattleOrigin = FortBattleWindow.showBattle;
FortBattleWindow.showBattle = function(response) {
FortBattle.cacheAll(response);
FortBattleWindow.showBattleOrigin.call(this, response);
};
// Add players on fort to localStorage
//rewrite by while
//@todo get fort position
FortBattle.cacheAll = function(resp) {
Ajax.remoteCallMode('players', 'get_data', {x: Character.position.x, y: Character.position.y, page: 0}, function(data) {
data.players.forEach(function(player) {
if (!localStorage.hasOwnProperty("PlayerId_" + player.player_id)) {
localStorage.setItem("PlayerId_" + player.player_id, player.name);
}
});
var count = data.pages;
for (var i = 1; i < count; i++) {
Ajax.remoteCallMode('players', 'get_data', {x: Character.position.x, y: Character.position.y, page: i}, function(data) {
data.players.forEach(function(player) {
if (!localStorage.hasOwnProperty("PlayerId_" + player.player_id)) {
localStorage.setItem("PlayerId_" + player.player_id, player.name);
}
});
});
}
});
};
// Show advance information about player
FortBattle.getCharDataSheetOrigin = FortBattle.getCharDataSheet;
FortBattle.getCharDataSheet = function(data) {
return FortBattle.getCharDataSheetOrigin(data) + "
" + Chat.Resource.Manager.getRooms()[room].topic + "
").appendTo("#ui_topbar"); } } }); }) ;