Last active
November 30, 2021 01:06
-
-
Save WinterSilence/0c2456103a875f60b7aa1f816068d201 to your computer and use it in GitHub Desktop.
YandexInvest, Яндекс Инвестиции, Добавляет стоимость за 1 акцию в истории операций
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YandexInvest | |
// @namespace YandexInvest | |
// @version 1.1.0 | |
// @description Extend history pages on https://invest.yandex.ru | |
// @author [email protected] | |
// @include https://invest.yandex.ru/*/history/ | |
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js | |
// @grant unsafeWindow | |
// @run-at document-end | |
// ==/UserScript== | |
$(function() { | |
function updatePage() { | |
$('#root .K1JhB2kFCZlu8-e4NVAcn').each(function (index) { | |
if (timerId) { | |
clearInterval(timerId); | |
} | |
if ((index + 1) % 2 === 0) { | |
return; | |
} | |
var $row = $(this); | |
var $hint = $('._3BquIDOs8cORmWxCbW1e3Q', $row); | |
if ($hint.length > 0) { | |
// кол-во бумаг | |
var qty = parseInt($hint.text().split(/\s/)[0]); | |
if (qty) { | |
// стоимость бумаг | |
var $price = $('._2aEIx7iD1kmZfgFmJICmbx', $row); | |
var price = parseFloat($price.text().replace(/[^,\d]+/g, '').replace(',', '.')); | |
// коммиссия яндекса/втб | |
var $commission = $row.next('.K1JhB2kFCZlu8-e4NVAcn').find('._3R1716xSCftYMjWPd3-vzQ ._2aEIx7iD1kmZfgFmJICmbx'); | |
price += parseFloat($commission.text().replace(/[^,\d]+/g, '').replace(',', '.')); | |
// добавляем стоимость акции с учетом комиссионных(при покупке добавляется к цене, при продаже) | |
$price.html($price.text() + '<br><small>' + (price / qty).toFixed(2) + ' ₽</small>'); | |
} | |
} | |
}); | |
} | |
$('#root').on('click', '.rNJSKQuD22g0zhAfSCn8S + ._2jJmDXZIX5W8UONF1NYNwY', updatePage); | |
var timerId = setInterval(updatePage, 300); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment