Shiny New MCStacker 2

Makes small changes to MCStacker so it's easier to write styles for. Needed for a userstyle by the same name to function optimally.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Shiny New MCStacker 2
// @version      1.0
// @description  Makes small changes to MCStacker so it's easier to write styles for. Needed for a userstyle by the same name to function optimally.
// @author       Ruby Rosario
// @grant        none
// @include      https://mcstacker.net/*
// @namespace https://greasyfork.org/users/139367
// ==/UserScript==
function scriptFunction() {
  
  function extend(f1, f2) {
    return function() {
      var _this = this;
      var _args = arguments;
      
      f1.apply(_this, _args);
      f2.apply(_this, _args);
    };
  }
  
  window.loadForm = extend(window.loadForm, function(form) {
    $('#executePane').removeClass('roundedDiv');
    wrapSelects();
    
    if (form === "summon") {
      // Move only the first set of passengers outside of their entity box.
      $('#entityPane0B').insertAfter('#rootEntity');
      movePassengers();
    }
  });
  
  window.entityChange = extend(window.entityChange, function() {
    wrapSelects();
    movePassengers();
  });

  window.createExecuteForm = extend(window.createExecuteForm, function(form) {
    $('#executePane').addClass('roundedDiv');
    wrapSelects();
  });

  window.removeExecute = extend(window.removeExecute, function(form) {
    $('#executePane').removeClass('roundedDiv');
  });
  
  function wrapSelects() {
    $("select").not(".selectLabel select").wrap("<label class='selectLabel'></label>");
  }

  window.showHide = function(container, hideButton){
    if($('#'+container).is(":visible")){
      $('#'+container+', #'+hideButton).addClass('hiding').removeClass('shown');
      $('#'+container).hide();
      $('#'+hideButton).html("<span>S</span>");
      $('#'+hideButton).prev().addClass('hiding').removeClass('shown');
    }else{
      $('#'+container+', #'+hideButton).addClass('shown').removeClass('hiding');
      $('#'+container).show();
      $('#'+hideButton).html("<span>H</span>");
      $('#'+hideButton).prev().addClass('shown').removeClass('hiding');
    }
  }
  
  function movePassengers() {
    // Move all of the passengers outside of their entity box.
    /*$('.entityWrapper > .entityB').each(function() {
      var $this = $(this);
      $this.insertAfter($this.closest('.roundedDiv'));
    });*/
    
    // Move add passenger buttons to the end.
    $('.greenPlus[href^="javascript:addPassenger"]').each(function() {
      var $this = $(this);
      $this.parent().append($this);
    });
    
    // Remove extra
    setTimeout(function() {
    	$('#rootEntity > .entityWrapper > .entityB').remove();
    }, 100);
  }

  window.addPassenger = extend(window.addPassenger, function(pane) {
    movePassengers();
  });

  window.removePassenger = extend(function(entityID, num) {
    $('#'+entityID+' + .entityB').remove();
  }, window.removePassenger);
}

var script = document.createElement('script'); 
script.type = "text/javascript"; 
script.innerHTML = scriptFunction.toString() + "\nscriptFunction();";
document.getElementsByTagName('head')[0].appendChild(script);