Greasy Fork

Greasy Fork is available in English.

东方财富 期货内外盘比

增加内外盘比的自动计算

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         东方财富 期货内外盘比
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  增加内外盘比的自动计算
// @author       benwang
// @match        http://quote.eastmoney.com/qihuo/*.html
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    window.setTimeout(setWpNpRate, 1500);

    function setWpNpRate() {
        // 获取外盘数据
        var _wp = document.querySelector("span.price_num.wp.red").innerText;
        if (_wp[_wp.length - 1] == "万") {
            _wp = parseFloat(_wp.substring(0, _wp.length - 1)) * 10000;
        }else{
            _wp = parseFloat(_wp);
        }

        //获取内盘数据
        var _np = document.querySelector("span.price_num.np.green").innerText;
        if (_np[_np.length - 1] == "万") {
            _np = parseFloat(_np.substring(0, _np.length - 1)) * 10000;
        }else{
            _np = parseFloat(_np);
        }

        var _rate = _wp / (_wp + _np) * 100;
        var _span = document.createElement("span");
        _span.style.left = "20px";
        _span.innerText = "外内盘比:" + _rate.toFixed(2) + "%";
        if (_rate >= 50) {
            _span.className = 'price_num red';
        } else {
            _span.className = 'price_num green';
        }

        // 在行情报价 后面追加 比例
        document.querySelector("div.side.side_right h2.title.fl").appendChild(_span)
    }
})();