Greasy Fork

Greasy Fork is available in English.

雪球调仓时输入小数

雪球调仓时可以输入小数

当前为 2024-01-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         雪球调仓时输入小数
// @namespace    http://xueqiu.com/
// @version      0.1.3
// @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
        SNB.cubeData.forEach(i => i.weight = 0)
		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.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)
})();