быстрая установка цены. origin: http://userscripts-mirror.org/scripts/show/82582
当前为
// ==UserScript==
// @name Virtonomica: быстрая установка цены
// @namespace virtonomica
// @description быстрая установка цены. origin: http://userscripts-mirror.org/scripts/show/82582
// @version 2.6
// @include http://virtonomic*.*/*/main/unit/view/*/sale
// ==/UserScript==
var run = function() {
var win = (typeof(unsafeWindow) != 'undefined' ? unsafeWindow : top.window);
$ = win.$;
function getRealm(){
var svHref = window.location.href;
var matches = svHref.match(/\/(\w+)\/main\/unit\/view\//);
return matches[1];
}
function getUnitType(){
var unitTypeImg = $('#unitImage > img').attr('src');
var matches = unitTypeImg.match(/\/units\/(\w+)_/);
return matches[1];
}
function getLastPart(svHref){
var matches = svHref.match(/\/(\d+)/);
return matches[1];
}
//warehouse, workshop
var unitType = getUnitType();
console.log('unitType = ' + unitType);
var regionID = getLastPart($('#headerInfo > div.officePlace > a[href*="/main/geo/citylist/"]').attr('href'));
console.log('regionID = ' + regionID);
var realm = getRealm();
var tax = 1;
$.getJSON('http://cobr123.github.io/by_trade_at_cities/'+realm+'/regions.json', function (data) {
$.each(data, function (key, val) {
if (val.i == regionID) {
tax = parseFloat(val.itr, 10) / 100;
console.log('tax = ' + tax);
}
});
});
var agCtie = [];
if(unitType !== 'warehouse'){
$.getJSON('http://cobr123.github.io/industry/'+realm+'/region_ctie/'+regionID+'.json', function (data) {
$.each(data, function (key, val) {
agCtie[val.pi] = parseFloat(val.r, 10);
});
});
}
var panel = $('form:has(table)');
var butAllByOne = $('<button>всё по $1</button>');
var butAllByCost = $('<button>всё по сс</button>');
var butAllByTaxPlus = $('<select><option value=""></option>'
+'<option value=5>всё по +5% +Налоги</option>'
+'<option value=10>всё по +10% +Налоги</option>'
+'<option value=15>всё по +15% +Налоги</option>'
+'<option value=20>всё по +20% +Налоги</option>'
+'<option value=30>всё по +30% +Налоги</option>'
+'</button>');
butAllByOne.click(function() {
$('button[class="sell_by_one_dollar"]').each(function() {
$(this).click();
});
});
butAllByCost.click(function() {
$('button[class="sell_by_cc"]').each(function() {
$(this).click();
});
});
butAllByTaxPlus.change(function() {
var value = $(this).val() || 0;
$('select[class="sell_by_tax_plus"]').val(value).change();
});
panel.first().before(butAllByTaxPlus).before(butAllByCost).before(butAllByOne);
$('table.grid > tbody > tr[class]').each(function() {
var sel = $('select', this).first();
var price = $('input.money', this).first();
price.attr('oldValue', price.val());
var ss = parseFloat($('> td:nth-child(4) > table > tbody > tr:nth-child(3) > td:nth-child(2)', this).text().replace('$','').replace(/\s+/,''));
if (isNaN(ss)) {
ss = 0;
} else {
ss += 0.01;
}
var productID = '';
if(unitType === 'warehouse'){
productID = getLastPart($('> td:nth-child(3) > a:has(img)', this).attr('href'));
} else {
productID = getLastPart($('> td:nth-child(2) > a:has(img)', this).attr('href'));
}
//console.log("ss = " + ss);
var butByOne = $('<button class="sell_by_one_dollar">$1</button>');
var butByCost = $('<button class="sell_by_cc">сс</button>');
var butByTaxPlus = $('<select class="sell_by_tax_plus"><option value=""></option>'
+'<option value=5>+5% +Налоги</option>'
+'<option value=10>+10% +Налоги</option>'
+'<option value=15>+15% +Налоги</option>'
+'<option value=20>+20% +Налоги</option>'
+'<option value=30>+30% +Налоги</option>'
+'</button>');
sel.before(butByTaxPlus).before(butByCost).before(butByOne);
butByOne.click(function() {
price.val(1);
return false;
});
butByCost.click(function() {
price.val(ss);
return false;
});
butByTaxPlus.change(function() {
var markup = $(this).val();
if (markup == null || markup == ''){
price.val(price.attr('oldValue'));
} else {
var diff = ss * (markup/100);
if(unitType === 'warehouse'){
price.val((ss * (markup/100 + 1) + diff * tax).toFixed(2));
} else {
var ctieTax = agCtie[productID];
console.log("ctieTax = " + ctieTax);
var ctie = ss * (ctieTax/100) * (markup/100);
console.log("ctie = " + ctie);
price.val((ss * (markup/100 + 1) + diff * tax + ctie).toFixed(2));
}
}
return false;
});
});
}
if(window.top == window) {
var script = document.createElement("script");
script.textContent = '(' + run.toString() + ')();';
document.documentElement.appendChild(script);
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址