雪球调仓时输入小数

雪球调仓时可以输入小数

// ==UserScript==
// @name         雪球调仓时输入小数
// @namespace    http://xueqiu.com/
// @version      0.1.4
// @description  雪球调仓时可以输入小数
// @author       xiaolin
// @match        https://xueqiu.com/*
// @grant        none
// @license MIT
// ==/UserScript==
;(function() {
	function blurHandler(event) {
		let cash = 10000
        const trs = $('#cube-stock tr.stock')
        const length = trs.length
		for (let i = 0; i < length; i++) {
            const tr = $(trs[i])
			const weight = Number(tr.find('input.weight').val().replace('%', ''))
            const data = SNB.cubeData.find(n => n.stock_id == tr.attr('data-id'))
			if (data && data.weight != weight) {
				data.proactive = true
				data.weight = weight
			}
			cash -= weight * 100
		}
		cash = +(cash / 100).toFixed(2)
		$('.cash .stock-weight input').val(cash)
		$('.cash .stock-weight span.weight').text(cash + '%')
		SNB.cashWeight = cash
		event.stopPropagation()
		return false
	}

	setInterval(function(){
   		$('input.weight').off('blur').blur(blurHandler)
   	}, 50)
})();