Greasy Fork 支持简体中文。

双低转债轮动评分

按照 转债现价 + 转股溢价率 * 100 计算评分, 并将结果渲染在已有的数据表格上, 并支持按照评分字段进行排序

目前為 2019-10-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         双低转债轮动评分
// @namespace    http://tampermonkey.net/
// @version      0.3.1
// @description  按照 转债现价 + 转股溢价率 * 100 计算评分, 并将结果渲染在已有的数据表格上, 并支持按照评分字段进行排序
// @author       kirk91
// @match        *://www.jisilu.cn/data/cbnew/
// @match        *://jisilu.cn/data/cbnew/
// @grant        none
// @run-at document-end
// ==/UserScript==

function insertScoreHeader() {
    var header_html = '<th style="width: 70px; white-space: nowrap;" title="转债现价 + 转股溢价率 * 100" class="header">轮动评分</th>';
    $('#flex_cb thead th[title|="纯债价值,税前"]').before(header_html);
}

function insertScoreData() {
    $("#flex_cb tbody tr").each(function(index){
        var bond_id = $(this).find("td[data-name|=bond_id] a").text()
        var bond_name = $(this).find("td[data-name|=bond_nm]").text()
        var price_text = $(this).find("td[data-name|=price]").text();
        var premium_rt_text = $(this).find("td[data-name|=premium_rt]").text();
        var score = (parseFloat(price_text) + parseFloat(premium_rt_text)).toFixed(3);
        var score_html = '<td data-name="score" style="width:40px;white-space: nowrap">' + score + '</td>';
        $(this).find("td[data-name|=_bond_value]").before(score_html);
    });
}

(function() {
    'use strict';

    // only match #cb page
    if (location.hash != "#cb") {
        return;
    }

    // TODO: replace it with flex_cb table data ready event.
    setTimeout(function(){
        insertScoreHeader();
        insertScoreData();
        
        // attach sorter to the new header
        // unbind the old click event handler
        $("#flex_cb thead th").unbind("click");
        // rebuild the table sorter
        $('#flex_cb').tablesorter({widgets: ['zebra']});
    }, 1500);

    $('#flex_cb').on("reload", insertScoreData);
})();