WME Add Uturns from node

Add uturns from node

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

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 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.

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

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         WME Add Uturns from node
// @version      0.1
// @description  Add uturns from node
// @author       ixxvivxxi
// @include      https://www.waze.com/editor/*
// @include      https://www.waze.com/*/editor/*
// @include      https://editor-beta.waze.com/editor/*
// @include      https://editor-beta.waze.com/*/editor/*
// @grant        none
// @namespace    https://greasyfork.org/ru/scripts/16950-wme-add-uturns-from-node

// ==/UserScript==

function Uturns_bootstrap()
{
	var bGreasemonkeyServiceDefined = false;

	try
	{
		if ("object" === typeof Components.interfaces.gmIGreasemonkeyService)
		{
			bGreasemonkeyServiceDefined = true;
		}
	}
	catch (err)
	{
		//Ignore.
	}
	if ( "undefined" === typeof unsafeWindow  ||  ! bGreasemonkeyServiceDefined)
	{
		unsafeWindow    = ( function ()
		{
			var dummyElem   = document.createElement('p');
			dummyElem.setAttribute ('onclick', 'return window;');
			return dummyElem.onclick ();
		} ) ();
	}
	/* begin running the code! */
	setTimeout(startUturns,999);
}
function startUturns() {

    Waze.selectionManager.events.register("selectionchanged", null, showButton);
    var wazeActionModifyConnection= require("Waze/Action/ModifyConnection")
  

    function showButton() {
        if(Waze.selectionManager.selectedItems.length == 0 || Waze.selectionManager.selectedItems.length > 1) return;
        if(Waze.selectionManager.selectedItems[0].model.type == "node") {

           $('.side-panel-section:first-child').append('<button id="addUturns" class="btn btn-default">add uturns</button>');
        }

    }

  $('#sidebar').on('click', '#addUturns', function(event) {
      var node = Waze.selectionManager.selectedItems[0].model;
      var segIDs = node.attributes.segIDs;
      
      for (var i = 0; i < segIDs.length; i++) {
          var segment = Waze.model.segments.objects[segIDs[i]];
          
          if (segment.attributes.fromNodeID == node.attributes.id) {
              console.log('А', segment.attributes.id);
              
              segment.attributes.fromConnections[segment.attributes.id] = true;
              Waze.model.actionManager.add(new wazeActionModifyConnection(segment.attributes.id, segment.getFromNode(), segment.attributes.id,segment.getFromNode()));
          } else {
              console.log('B', segment.attributes.id);
              segment.attributes.toConnections[segment.attributes.id] = true;
              Waze.model.actionManager.add(new wazeActionModifyConnection(segment.attributes.id, segment.getToNode(), segment.attributes.id, segment.getToNode()));
          }

      }

  });


}

Uturns_bootstrap();