yarl / Map Maker +

// ==UserScript==
// @name        Map Maker +
// @description 
// @namespace	Yashkin Kot
// @include		http://*google.com/mapmaker*
// @include		http://*google.com.ua/mapmaker*
// @include		https://*google.com/mapmaker*
// @include		https://*google.com.ua/mapmaker*
// @version		1.9
// @require		https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
// @grant		none
// ==/UserScript==
//http://userscripts.org/scripts/source/163747.user.js

	var cs=document.createElement('link');
	cs.href="https://sites.google.com/site/gmmtesting2013/files/style.css";
        cs.type="text/css"
        cs.rel="stylesheet";
	document.getElementsByTagName('head')[0].appendChild(cs);


//$("#topbar").remove();
$(".message-bar-container").css('top','80px');
$(".message-bar-container").css('z-index','999');
$("#kd-browse-line-features").text("Лінійні об'єкти");
$(".release-announcement").css('display','block');



// ==Активація Enter на синю кнопку ==
// name        Map Maker - Enter clicks blue button
// description Pressing Enter key clicks the last blue (submit/save/next) button visible on the page
// namespace	bozar
$(document).bind("keydown", bindHotkey2);
function bindHotkey2(e){  
    if(e.keyCode == 13){      
        e.preventDefault();
        var b = $(".kd-button-submit:visible");           
        //console.log(b.length + " buttons found. clicking last!");
        b.last().click();     
    }
}

// ==Активація Delete для видалення точок дороги ==
// name        Map Maker "delete point" hotkey
// description Allows quick removal of selected point in the line or shape. Just right click the point and press DELETE. 
// namespace	bozar
// menu item search routine
$("#map").bind("contextmenu",function(e){
	var intervalID;
	var found = false;
	intervalID = setInterval(function(){
	// console.log("timeout elapsed");
	if(found) return;
		var item = $(".menuitem[cad='src:gw-contextmenu-findfeature']").parent().children().first();
		if(item.length == 1){
			found = true;
			// console.log("menu item found");
			$(document).bind("keydown", bindHotkey);
			// console.log("hotkey bound");
			clearInterval(intervalID);
		}
	}, 50);
});
// console.log("mouse event bound");

// handler for the delete key
function bindHotkey(e){
	// console.log("key pressed: " + e.keyCode);
	if(e.keyCode == 46){
		$(".menuitem[cad='src:gw-contextmenu-findfeature']").parent().children().first().click();
		// console.log("target clicked");
	}
	$(document).unbind("keydown", bindHotkey);
	// console.log("hotkey unbound");
}
   
// ==Активація Space key  ==
$(document).keypress(keypress);

function keypress(e){
    //console.log(e.charCode);
    if(e.charCode == 32){    	
        var type = document.activeElement.nodeName;        
        if(type == "BODY"){                      
            if( $("#maptypenormal:visible").length == 1 ){
                $("#maptypenormal").click();                
            }else if( $("#maptypehybrid:visible").length == 1 ){
                $("#maptypehybrid").click();                
            }
        }        
    }    
}