Greasy Fork is available in English.

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

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

2016-11-02 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name           Virtonomica: Обновление главного окна после закрытия дочернего
// @namespace      virtonomica
// @include        http*://*virtonomic*.*/*/window/unit/equipment/*
// @include        http*://*virtonomic*.*/*/main/unit/view/*
// @description    Обновление главного окна после закрытия дочернего
// @version        1.3
// ==/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+)\)/);
        _popup = popup($(this).attr('href'), matches[1], matches[2]);
        waitfor(100, 0);
    });

};

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