Turambar

Active Member
Reaction score
41
Author
N/A
Contributors
Turambar
Quickbar Entry
javascript:
//customize script
var templateName = "YourTemplateName";
coords = '999|998 999|999';
// ---------------------------------------------------------
var doc = document;
if (window.frames.length > 0 && window.main != null) doc = window.main.document;
url = doc.URL;
if (url.indexOf('screen=place') == -1) alert('Use the script in the rally point page!');
coords = coords.split(' ');
index = 0;
tura_template_cookie = document.cookie.match('(^|;) ?tura_template_cookie=([^;]*)(;|$)');
if (tura_template_cookie!= null) index = parseInt(tura_template_cookie[2]);
if (index >= coords.length) alert('All villages were extracted, now start from the first!');
if (index >= coords.length) index = 0;
coords = coords[index];
coords = coords.split('|');
index = index + 1;

var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000*24*7);

document.cookie = 'tura_template_cookie=' + index + ';expires=' +
expire.toGMTString();
doc.forms[0].x.value = coords[0];
doc.forms[0].y.value = coords[1];
$('#place_target').find('input').val(coords[0] + '|' + coords[1]);

var allTemplates = TroopTemplates.current;

for (templateId in allTemplates){
console.log(templateId);

var template = allTemplates[templateId];

if ( template.name == templateName ){
TroopTemplates.useTemplate(templateId)
}
}
Public?
Public
Hi , just another small tweak on a code it is not mine ( no idea who is the author).

This script will select a desired template and select a target from your coord list.

I am assuming that it does not requires aprooval since it only fills forms and the rules states the following:
The only exception to this is if a script only fills out / selects form input fields. This is automatically legal and does not require approval.

Code:
javascript: 
    //customize script
    var templateName = "YourTemplateName";
    coords = '999|998 999|999';
    // ---------------------------------------------------------
    var doc = document;
    if (window.frames.length > 0 && window.main != null) doc = window.main.document;
    url = doc.URL;
    if (url.indexOf('screen=place') == -1) alert('Use the script in the rally point page!');
    coords = coords.split(' ');
    index = 0;
    tura_template_cookie = document.cookie.match('(^|;) ?tura_template_cookie=([^;]*)(;|$)');
    if (tura_template_cookie!= null) index = parseInt(tura_template_cookie[2]);
    if (index >= coords.length) alert('All villages were extracted, now start from the first!');
    if (index >= coords.length) index = 0;
    coords = coords[index];
    coords = coords.split('|');
    index = index + 1;

        var today = new Date();
        var expire = new Date();
        expire.setTime(today.getTime() + 3600000*24*7);

    document.cookie = 'tura_template_cookie=' + index + ';expires=' + 
    expire.toGMTString();
    doc.forms[0].x.value = coords[0];
    doc.forms[0].y.value = coords[1];
    $('#place_target').find('input').val(coords[0] + '|' + coords[1]);

    var allTemplates = TroopTemplates.current;

    for (templateId in allTemplates){  
        console.log(templateId); 
        
        var template = allTemplates[templateId];
        
        if ( template.name == templateName ){
            TroopTemplates.useTemplate(templateId)
        }
    }

Basically this script is to send a desired template once on each coord of the list
 
Changelog
13/07/2021 - Fixed bug on expire date and changed cookie name to avoid conflicts
Last edited:
Upvote 0

Turambar

Active Member
Reaction score
41
TBH , Being random kinda defeats the purpose of this script. The idea of this script is making sure that every village in the list gets one attack of the desired template. It's best use probably is for fangs and nukes and there better scripts out there for faking.
 
Top