collectGC-Codes

Collect GC-Codes from Searchresult Pages

Fra 03.10.2014. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           collectGC-Codes
// @author          Confectrician
// @namespace      https://github.com/Confectrician/collect_gc_codes/
// @description    Collect GC-Codes from Searchresult Pages
// @include        http://www.geocaching.com/seek/nearest.aspx*
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_registerMenuCommand
// @grant           unsafeWindow
// @version        2.0
// ==/UserScript==


var stored;
var gccodes = new Array();
var codehash = new Array();

function clearCollection() {
  GM_setValue("gccodeshashed","");
  alert("GC-Codes cleared");
}

// main()

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

try {
    stored = GM_getValue("gccodeshashed");
    gccodes = stored.split('|');
//  alert(gccodes.length);
    for(var i=0 ; i < gccodes.length ; i++)
    {
        codehash[gccodes[i]]=i;
    }
}
catch (err){
}

try
{
    var b=document.getElementsByTagName("table")[1].getElementsByTagName("tr");
    var anzahl=b.length;
    for(var i=1 ; i < anzahl ; i++)
    {
        var spans = b[i].getElementsByTagName("span");
        var gc=spans[3].innerHTML.split('|')[1].trim();
//      alert(gc);
        codehash[gc]=0;
    }

    stored="";
    var i=0;
    for (var st in codehash) {
     if(i++)
         stored = stored + '|';
     stored = stored + st;
  } 
    GM_setValue("gccodeshashed",stored);
    var Element=document.getElementById('ctl00_divContentSide');
//  Element.innerHTML=Element.innerHTML+'<p>'+stored.replace(/\|/gi,"<br />")+'</p>';
    Element.innerHTML=Element.innerHTML+"<textarea id=\"gm_tb_ta\" cols=\'40\' rows=\'30\'>" +stored.replace(/\|/gi,";")+ '</textarea></div>';
}
catch (err){
}