collectTB-Codes

Collect TB-Codes from TB Listing

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name            collectTB-Codes
// @namespace       https://github.com/Confectrician/collect_tb_codes
// @author          Confectrician
// @description     Collect TB-Codes from TB Listing
// @include         https://www.geocaching.com/track/details.aspx*
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_registerMenuCommand
// @grant           unsafeWindow
// @version         2.03
// ==/UserScript==


var stored;
var tbcodes = [];
var codehash = [];


function clearCollection() {
  GM_setValue("tbcodeshashed","");
  TA = document.getElementById('gm_tb_ta');
  TA.innerHTML = "";
  alert("TB-Codes cleared");
}

// main()

GM_registerMenuCommand( "TB-Codes clear", clearCollection );

try {
	stored = GM_getValue("tbcodeshashed");
	//console.log("stored = " + stored);
	tbcodes = stored.split('|');
	//console.log("tbcodes = " + tbcodes);
	//console.log("tbcodes length = " + tbcodes.length);
    //alert("Stored " + tbcodes.length + " TB-Codes");
	for(var i=0 ; i < tbcodes.length ; i++)
	{
		codehash[tbcodes[i]]=i;
		//console.log("codehash["+tbcodes[i]+"] Nr. " + i  + " = " + codehash[tbcodes[i]]);
	}
}
catch (err){
}

try
{
	var GCElement = document.getElementById('ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode');
	var GCCode    = GCElement.innerHTML;
	codehash[GCCode]=0;

	stored="";
	var i= 0;
	for (var st in codehash) {
	    //console.log("forschleife " + st + " " + i);
	    if(i++){
	        //console.log("ifbedingung true");
            stored = stored + '|';
        }
        stored = stored + st;    
  }
    output = stored;
	if(stored[stored.length -1] == ";"){
	    output = stored.substr(0,stored.length -1);
	}
	//console.log("stored length = " + stored.length);
	GM_setValue("tbcodeshashed",stored);
	var Element=document.getElementById('divContentSide');
	Element.innerHTML=Element.innerHTML + "<div style='width: 250px;'>" + tbcodes.length + ' TB-Codes Stored<br />(Refresh could be necessary)<br /><textarea id=\"gm_tb_ta\" cols=\'40\' rows=\'30\'>' + output.replace(/\|/gi,";") + '</textarea></div>';
    //.replace(/\|/gi,";")
}
catch (err){
}