geoharo / Parse To GeoChecker And Navigate

// ==UserScript==
// @name Parse To GeoChecker And Navigate
// @namespace Parse To geocache.fi's GeoChecker and navigate
// @description Parsii geocache.fi:n GeoCheckerin captcha ruudusta kuusi numerojonoa lat1 lat2 lat2 ja lon1 lon2 lon3 -ruutuihin. Ratkaisun ollessa oikein avaa välilehteen Google Maps navigoinnin kohteeseen.
// @include https://www.geocache.fi/checker/*
// @include http://www.geocache.fi/checker/*
// @version 1
// @grant none
// ==/UserScript==

//User navigation config (driving/walking/bicycling/transit):
//var travelmode = "driving";


//Script:
var url = window.location.href;
if (url.slice(-9) === "index.php"){
    if (document.body.innerHTML.indexOf("color=\"#00AA00\"") != -1){ //&& travelmode != "off"
        var correct = document.body.innerHTML.match(/[NS].\d{2}..\d{2}.\d{3}.[EW].\d{2}..\d{2}.\d{3}/g)[0].replace(/ /g, '%20');
        var navi = 'https://www.google.com/maps/dir/?api=1&origin=(Home%20Location)&destination=' + correct; //+ '&travelmode=' + travelmode;
        window.open(navi);
    }
}else {
    var seccodeElem = document.querySelectorAll('input[name="seccode"]');
    seccodeElem[0].setAttribute('id','seccode');
    seccodeElem[0].setAttribute('size','30');
    document.getElementById('seccode').onchange = function(){
        parser(seccode.value);
    };
}

function parser(input){
    var coords = input.match(/(\d{1,3})/g);
    if (coords.length === 6){
        document.querySelectorAll('input[name="cachelat1"]')[0].setAttribute('value',coords[0]);
        document.querySelectorAll('input[name="cachelat2"]')[0].setAttribute('value',coords[1]);
        document.querySelectorAll('input[name="cachelat3"]')[0].setAttribute('value',coords[2]);
        document.querySelectorAll('input[name="cachelon1"]')[0].setAttribute('value',coords[3]);
        document.querySelectorAll('input[name="cachelon2"]')[0].setAttribute('value',coords[4]);
        document.querySelectorAll('input[name="cachelon3"]')[0].setAttribute('value',coords[5]);
        document.getElementById('seccode').value = "";
    }
}