Greasy Fork is available in English.

Virtonomica: Обновление главного окна после закрытия дочернего

Обновление главного окна после закрытия дочернего

À partir de 2016-11-02. Voir la dernière version.

// ==UserScript==
// @name           Virtonomica: Обновление главного окна после закрытия дочернего
// @namespace      virtonomica
// @include        http*://*virtonomic*.*/*/main/unit/view/*
// @description    Обновление главного окна после закрытия дочернего
// @version        1.5
// ==/UserScript==

var run = function() {

	var win = (typeof(unsafeWindow) != 'undefined' ? unsafeWindow : top.window);
	$ = win.$;

    var _popup = null;
	function waitfor(msec, count) {
		// Check if condition met. If not, re-check later (msec).
        console.log("popup_opened = " + (_popup !== null && !_popup.closed));
		while (_popup !== null && !_popup.closed)  {
			count++;
			setTimeout(function() {
				waitfor(msec, count);
			}, msec);
			return;
		}
        _popup = null;
		// Condition finally met. callback() can be executed.
        console.log("count = " + count);
        location.reload();
	}

    $('a[onclick^="return doWindow(this"]').unbind().click(function(){
		var matches = $(this).attr('onclick').match(/doWindow\(this[^\d]+(\d+),\s*(\d+)\)/);
var url = $(this).attr('href');
        _popup = popup(url, matches[1], matches[2]);
if (/\/\w+\/window\/unit\/supply\/create\/\d+\/step1\/\d+/.test(url) || /\/\w+\/window\/unit\/equipment\/\d+/.test(url)) {
        waitfor(500, 0);
} else {
        _popup = null;
}
    });

};

if(window.top == window) {
    var script = document.createElement("script");
    script.textContent = '(' + run.toString() + ')();';
    document.documentElement.appendChild(script);
}