Shartak Treasure Map Safety

Default action for Non-active Treasure Maps set to identify

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 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        Shartak Treasure Map Safety
// @namespace   http://userscripts.org/users/125692
// @description Default action for Non-active Treasure Maps set to identify
// @include     http://www.shartak.com/game.cgi
// @include     http://shartak.com/game.cgi
// @include     https://shartak.com/game.cgi
// @include     https://www.shartak.com/game.cgi
// @version     1
// @run-at document-start
// @grant       none
// ==/UserScript==
(function() {
  
function addNamedGlobalStyle(css,idname) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.id=idname;
	style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}  
  
//first we make maps unclickable with css injecting style early.
//nodot inventory
//this one is named so can be toggled.
addNamedGlobalStyle("ul.inventory{display:none!important;}","hideinventory");
//then we wait till dom ready then alter then reset css  
  
//set eventlistener for when page has maps ready for altering.  
document.addEventListener ("DOMContentLoaded", DOM_ContentReady);

function DOM_ContentReady () {
   var treasuremaps=document.evaluate( "//input[starts-with(@value,'2Y(')]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
   if(treasuremaps.snapshotLength>0){//we have at least one activated map
      for(var i=0,j=0;j=treasuremaps.snapshotItem(i);i++){
         j.parentNode.firstElementChild.selectedIndex=1;
      }
   }
   document.getElementById('hideinventory').disabled=true;
}
  
  
//EOF
})();