secundum

Active Member
Reaction score
12
Author
secundum
Contributors
suilenroc
Quickbar Entry
javascript:
// SL can be configured by ading or removing commandFilter elements.
// It matches the link of images displayed on a command and hides the command.
var commandFilter = ['/return_', '/back.png', '/farm.png', '/support.png', '/attack_small.png'];
// /snob.png /attack_medium.png
var commandFilterRegex = 'img[src*="' + commandFilter.join('"], img[src*="') + '"]';
var mapElement = new MapObject();
if (window.location.href.match("screen=map"))
mapElement.changeMap();
else if (window.location.href.match('screen=info_village'))
removeUndesiredCommands($('tr.command-row'));
else if (window.location.href.match('mode=command'))
removeUndesiredCommands($('#commands_table tr'));
/* Process Map movement */
function MapObject() {
var self = this;
/* Adds custom handeling to MouseMove*/
this.changeMap = function() {
this.twmap = window.TWMap;
this.twmap.popup.saveConsentHandleMouseMove = this.twmap.popup.handleMouseMove;
this.twmap.popup.handleMouseMove = this.handleMouseMove;
}
;
/* Filters commandsAfter popup handeling*/
this.handleMouseMove = function(event) {
self.twmap.popup.saveConsentHandleMouseMove(event);
removeUndesiredCommands($('tr.command-row'));
}
;
}
// Helper : Removes all commands from tr
// $('tr.command-row') used on map and inf village
// $('#commands_table tr') used on outgoing commands page
function removeUndesiredCommands(tr) {
tr.filter((_,el)=>$(el).find(commandFilterRegex, el).length > 0).remove();
}
Public?
Public
It is hard to have a good overview if there are a lot returning attacks and fakes per village. Therefor i created this script to reduce bloat commands.

JavaScript:
javascript:
// SL can be configured by ading or removing commandFilter elements.
// It matches the link of images displayed on a command and hides the command.
var commandFilter = ['/return_', '/back.png', '/farm.png', '/support.png', '/attack_small.png'];
// /snob.png /attack_medium.png
var commandFilterRegex = 'img[src*="' + commandFilter.join('"], img[src*="') + '"]';
var mapElement = new MapObject();
if (window.location.href.match("screen=map"))
    mapElement.changeMap();
else if (window.location.href.match('screen=info_village'))
    removeUndesiredCommands($('tr.command-row'));
else if (window.location.href.match('mode=command'))
    removeUndesiredCommands($('#commands_table tr'));
/* Process Map movement */
function MapObject() {
    var self = this;
    /* Adds custom handeling to MouseMove*/
    this.changeMap = function() {
        this.twmap = window.TWMap;
        this.twmap.popup.saveConsentHandleMouseMove = this.twmap.popup.handleMouseMove;
        this.twmap.popup.handleMouseMove = this.handleMouseMove;
    }
    ;
    /* Filters commandsAfter popup handeling*/
    this.handleMouseMove = function(event) {
        self.twmap.popup.saveConsentHandleMouseMove(event);
        removeUndesiredCommands($('tr.command-row'));
    }
    ;
}
// Helper : Removes all commands from tr
// $('tr.command-row') used on map and inf village
// $('#commands_table tr') used on outgoing commands page
function removeUndesiredCommands(tr) {
    tr.filter((_,el)=>$(el).find(commandFilterRegex, el).length > 0).remove();
}

Hides commands according to your prefereces.
Works on the map , village Info and on the commands page.


Attention!!!
The tooltip on the map only shows 6 comands max, hiding commands does not result in loading commands that would be hiden otherwise.

Line 4 can be changed to fit your filter criteria:
Exampel configurations:

var commandFilter = ['/return_', '/back.png'];
var commandFilter = ['/return_', '/back.png', '/attack_small.png']
var commandFilter = ['/farm.png', '/support.png']
var commandFilter = ['/attack_small.png', '/attack_medium.png']

1675896450596.png1675896470567.png
 
Last edited:
Upvote 0
Top