DeletedUser45218
Гость
скрипт не рабочий
javascript:
var win = window, loc = win.location;
loc.contains = function(search_value) {
return window.document.URL.search(search_value) != -1;
};
var NoteCleaner = {
map: {
init: function() {
TWMap.get_village_note = function (village_id) {
var icon = TWMap.villageIcons[village_id];
if(icon != undefined && icon.note != undefined) {
return icon.note;
}
return false;
};
TWMap.clear_note = function (village_id, image_source) {
TribalWars.post('info_village', { ajaxaction: 'edit_notes', id: village_id }, {note: ''}, function(result) {
$('img[id=map_icons_' + village_id + ']').each(function(index, element) {
var $element = $(element);
if($element.attr('src') == image_source) {
$element.remove();
}
});
delete TWMap.villageIcons[village_id].note;
});
};
TWMap.mapHandler.onClick = function(x, y, e) {
var village = TWMap.villages[x * 1000 + y];
var note = TWMap.get_village_note(village.id);
if(note) {
TWMap.clear_note(village.id, note.img);
}
return false;
};
}
},
combined_view: {
clear_note: function ( event ) {
TribalWars.post('info_village', { ajaxaction: 'edit_notes', id: event.data.village_id }, {note: ''}, function(result) {
event.data.element.find('span[class*=village_note]').remove();
});
},
init: function() {
$('tr.nowrap:has( span[class*=village_note] )').each( function(index) {
var j_element = $(this);
var data_id = j_element.find('.quickedit-vn').attr('data-id');
$(this).find('span[class*=village_note]').on('click', { village_id : data_id, element : j_element }, NoteCleaner.combined_view.clear_note);
});
}
},
init: function () {
if(loc.contains(/screen=map/)) {
this.map.init();
} else {
this.combined_view.init();
}
}
};
NoteCleaner.init();
javascript: var win = window,
loc = win.location;
loc.contains = function(search_value) {
return window.document.URL.search(search_value) != -1;
};
var NoteCleaner = {
map: {
init: function() {
TWMap.get_village_note = function(village_id) {
var icon = TWMap.villageIcons[village_id];
if (icon != undefined && icon.note != undefined) {
return icon.note;
}
return false;
};
TWMap.clear_note = function(village_id, image_source) {
TribalWars.post('info_village', {
ajaxaction: 'edit_notes',
id: village_id
}, {
note: ''
}, function(result) {
$('img[id=map_icons_' + village_id + ']').each(function(index, element) {
var $element = $(element);
if ($element.attr('src') == image_source) {
$element.remove();
}
});
delete TWMap.villageIcons[village_id].note;
});
};
TWMap.mapHandler.onClick = function(x, y, e) {
var village = TWMap.villages[x * 1000 + y];
var note = TWMap.get_village_note(village.id);
if (note) {
TWMap.clear_note(village.id, note.img);
}
return false;
};
TWMap.clear_ally = function() {
var min, max, xMin, xMax, yMin, yMax;
sx = Math.floor(TWMap.size[0] / 2);
sy = Math.floor(TWMap.size[1] / 2);
min_x = TWMap.pos[0] - sx;
max_x = TWMap.pos[0] + sx;
min_y = TWMap.pos[1] - sy;
max_y = TWMap.pos[1] + sy;
playerids = [];
for (var i in TWMap.players) {
if (TWMap.players[i].ally == game_data.player.ally) playerids.push(i);
}
villids = [];
for (var i in TWMap.villages) {
if (playerids.indexOf(TWMap.villages[i].owner) >= 0) {
vill = TWMap.villages[i];
x = Math.floor(vill.xy / 1000);
y = vill.xy % 1000;
if (x >= min_x && x <= max_x && y >= min_y && y <= max_y) villids.push(TWMap.villages[i].id);
}
}
for (var i in TWMap.villageIcons) {
if (villids.indexOf(i) >= 0 && TWMap.villageIcons[i].note && (TWMap.villageIcons[i].note.img == '/graphic/map/village_notes_1.png' || TWMap.villageIcons[i].note.img == '/graphic/map/village_notes_3.png')) {
var note = TWMap.get_village_note(i);
if (note) TWMap.clear_note(i, note.img);
TWMap.waitmepls(200);
}
}
};
TWMap.waitmepls = function(ms) {
var start = new Date().getTime();
var end = start;
while (end < start + ms) {
end = new Date().getTime();
}
};
var srcHTML = '<div id="outscr" style="z-index: 99; position: fixed; top: 55px; left: 10px; width: auto; height: auto; background: grey; border:2px solid; visibility: visible; cursor:pointer"><center><br/><input id="btnclear" class="btn edit_link" type=button value="clear notes on ally villiges" onClick=TWMap.clear_ally()></center><br/></div>';
$('body').append(srcHTML);
$(document).keypress(function(event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode == '99') $('#btnclear').click();
});
}
},
combined_view: {
clear_note: function(event) {
TribalWars.post('info_village', {
ajaxaction: 'edit_notes',
id: event.data.village_id
}, {
note: ''
}, function(result) {
event.data.element.find('span[class*=village_note]').remove();
});
},
init: function() {
$('tr.nowrap:has( span[class*=village_note] )').each(function(index) {
var j_element = $(this);
var data_id = j_element.find('.quickedit-vn').attr('data-id');
$(this).find('span[class*=village_note]').on('click', {
village_id: data_id,
element: j_element
}, NoteCleaner.combined_view.clear_note);
});
}
},
init: function() {
if (loc.contains(/screen=map/)) {
this.map.init();
} else {
this.combined_view.init();
}
}
};
NoteCleaner.init();
трям
1. ещё раз хочется сказать спасибо автору за прекрасную работу
2. добавил от себя кнопку(или нажатие латинской "c") для очистки заметок с деревушек своего племени на видемой области карты
Код:javascript: var win = window, loc = win.location; loc.contains = function(search_value) { return window.document.URL.search(search_value) != -1; }; var NoteCleaner = { map: { init: function() { TWMap.get_village_note = function(village_id) { var icon = TWMap.villageIcons[village_id]; if (icon != undefined && icon.note != undefined) { return icon.note; } return false; }; TWMap.clear_note = function(village_id, image_source) { TribalWars.post('info_village', { ajaxaction: 'edit_notes', id: village_id }, { note: '' }, function(result) { $('img[id=map_icons_' + village_id + ']').each(function(index, element) { var $element = $(element); if ($element.attr('src') == image_source) { $element.remove(); } }); delete TWMap.villageIcons[village_id].note; }); }; TWMap.mapHandler.onClick = function(x, y, e) { var village = TWMap.villages[x * 1000 + y]; var note = TWMap.get_village_note(village.id); if (note) { TWMap.clear_note(village.id, note.img); } return false; }; TWMap.clear_ally = function() { var min, max, xMin, xMax, yMin, yMax; sx = Math.floor(TWMap.size[0] / 2); sy = Math.floor(TWMap.size[1] / 2); min_x = TWMap.pos[0] - sx; max_x = TWMap.pos[0] + sx; min_y = TWMap.pos[1] - sy; max_y = TWMap.pos[1] + sy; playerids = []; for (var i in TWMap.players) { if (TWMap.players[i].ally == game_data.player.ally) playerids.push(i); } villids = []; for (var i in TWMap.villages) { if (playerids.indexOf(TWMap.villages[i].owner) >= 0) { vill = TWMap.villages[i]; x = Math.floor(vill.xy / 1000); y = vill.xy % 1000; if (x >= min_x && x <= max_x && y >= min_y && y <= max_y) villids.push(TWMap.villages[i].id); } } for (var i in TWMap.villageIcons) { if (villids.indexOf(i) >= 0 && TWMap.villageIcons[i].note && (TWMap.villageIcons[i].note.img == '/graphic/map/village_notes_1.png' || TWMap.villageIcons[i].note.img == '/graphic/map/village_notes_3.png')) { var note = TWMap.get_village_note(i); if (note) TWMap.clear_note(i, note.img); TWMap.waitmepls(200); } } }; TWMap.waitmepls = function(ms) { var start = new Date().getTime(); var end = start; while (end < start + ms) { end = new Date().getTime(); } }; var srcHTML = '<div id="outscr" style="z-index: 99; position: fixed; top: 55px; left: 10px; width: auto; height: auto; background: grey; border:2px solid; visibility: visible; cursor:pointer"><center><br/><input id="btnclear" class="btn edit_link" type=button value="clear notes on ally villiges" onClick=TWMap.clear_ally()></center><br/></div>'; $('body').append(srcHTML); $(document).keypress(function(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == '99') $('#btnclear').click(); }); } }, combined_view: { clear_note: function(event) { TribalWars.post('info_village', { ajaxaction: 'edit_notes', id: event.data.village_id }, { note: '' }, function(result) { event.data.element.find('span[class*=village_note]').remove(); }); }, init: function() { $('tr.nowrap:has( span[class*=village_note] )').each(function(index) { var j_element = $(this); var data_id = j_element.find('.quickedit-vn').attr('data-id'); $(this).find('span[class*=village_note]').on('click', { village_id: data_id, element: j_element }, NoteCleaner.combined_view.clear_note); }); } }, init: function() { if (loc.contains(/screen=map/)) { this.map.init(); } else { this.combined_view.init(); } } }; NoteCleaner.init();