Virtonomica:old-interface

Добавляет признак старого интерфейса в ссылки

// ==UserScript==
// @name           Virtonomica:old-interface
// @description    Добавляет признак старого интерфейса в ссылки
// @namespace      virtonomica
// @version        1.092
// @grant          none
// @include        *virtonomic*.*/*/main/*
// @author         tux
// ==/UserScript==

var run = function () {
    var re_off = /(\?|\#).+$/;
    var re_on = [/сompany\/view\/\d+/,
             /company\/view\/\d+\/unit_list$/,
             /unit\/view\/\d+$/,
             /unit\/view\/\d+\/supply$/,
             /unit\/view\/\d+\/sale$/,
             /user\/privat\/persondata\/knowledge/,
             /unit\/create\/\d+$/
            ];
    $("a[href^='https:\/\/virtonomica\.']").on('click',function(){
        if(event.ctrlKey){            
            return true;
        }
        var str = this.href;
        if (str.search(re_off) == -1){
            var can_add = false;
            for(var i=0;i<re_on.length;i++){
                if(str.search(re_on[i]) != -1){
                    can_add = true;
                }
            }
            if(can_add){
                str += '?old';
                location.href=str;
                return false;
                //console.log(str + ' changed to old');
            }
        }
        return true;
    });
    $("a[href^='https:\/\/virtonomica\.']").each(function(){
        var str = this.action;
        if(this.href.match(/\/window\/company\//)){
            this.href = this.href.replace(/\/window\/company\//,'/main/company/');
            //console.log(this.href + ' changed to main');
        }
    });
    /*
    $("form[action^='https:\/\/virtonomica\.']").each(function(){
        var str = this.action;
        //console.log(str + ' form found');
        if (str.search(re_off) == -1){
            if(str.search(/unit\/view\/\d+\/supply$/) != -1){
                this.action += '?old';
                //console.log(str + ' form changed to old');
            }
        }
    });
    */
}
if (window.top == window) {
  var script = document.createElement('script');
  script.textContent = '(' + run.toString() + ')();';
  document.documentElement.appendChild(script);
}