Shartak Treasure Map Safety

Default action for Non-active Treasure Maps set to identify

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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
})();