Greasy Fork is available in English.

jisilux

在jsl与xueqiu同品种页面间跳转,不过从xueqiu转到jsl有地址不对的情况,因为jsl里lof\etf中包含的qdii、封基是分开的,没找到代码上的规律。凑合用啊~~

目前為 2021-11-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name         jisilux
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  在jsl与xueqiu同品种页面间跳转,不过从xueqiu转到jsl有地址不对的情况,因为jsl里lof\etf中包含的qdii、封基是分开的,没找到代码上的规律。凑合用啊~~
// @author       三川衡
// @license      https://www.apache.org/licenses/LICENSE-2.0
// @include      https://*jisilu.cn/data/*
// @include      https://*xueqiu.com/S/*
// @icon         https://www.jisilu.cn/favicon.ico
// @grant        none
// @run-at document-end
// ==/UserScript==

(function() {
    'use strict'
    var xqUrl = 'https://xueqiu.com/S/'
    var jslUrl = 'https://www.jisilu.cn/data/'
    var sh = /^(11|50|51|56|58|60|68|70|73|90)\d{4}$/ // 沪市证券
    var sz = /^(00|08|12|15|16|20|30)\d{4}$/ // 深市证券
    var bj = /^(83|87|88)\d{4}$/ //北交所
    var hk = /^\d{5}$/ //香港
    var cb = /^(110|113|123|127|128)\d{3}$/ // 可转债
    var etf = /^(15|51|56|58)\d{4}$/ //这个跳到jsl会有错漏,ETF中的qdii ,jsl是分开的。没有找到分开的规律。
    var stock = /^(600|601|603|688|000|002|300)\d{3}$/ //这个不知道有错漏没,没有包括北交所。
    var lof = /^(16|50)\d{4}$/ //这个错的最多,qdii 封闭基金 都有可能,没有找到规律。
    //prestart
    function purifyCode(code) {
        return code.replace(/[a-zA-Z]*/gi, '')
    }
    function addPrefix(code) {
        code = purifyCode(code)
        if (sh.test(code)) {
            return 'SH' + String(code)}
        else if (sz.test(code)) {
            return 'SZ' + String(code)}
        else if (bj.test(code)) {
            return 'BJ' + String(code)}
        else if (hk.test(code)) { //现在jsl好像还没有专门的香港股票页面
            return String(code)}
        else { return false }
    }
    function classify(code) {
        code = purifyCode(code)
        if (cb.test(code)) {
            return jslUrl.concat('convert_bond_detail/',code)
        } else if (etf.test(code)) {
            return jslUrl.concat('etf/detail/',code)
        } else if (stock.test(code)) {
            return jslUrl.concat('stock/detail/',code)
        } else if (lof.test(code)) {
            return jslUrl.concat('lof/detail/',code)
        } else {
            return false
        }
    }
    // start
    if (location.host.replace('www.', '') === 'jisilu.cn') {
        var addrJ = location.pathname
        var codeJ = addrJ.split('/').pop()
        var fullCode = addPrefix(codeJ)
        if (!fullCode) {
            return
        }
        var xqUrlDetail = xqUrl.concat(fullCode)
        var xq = `&emsp; <a href= ${xqUrlDetail} target='_blank'> <img src='https://xueqiu.com/favicon.ico'/></a>`
        if ( $('#compare_top').length > 0 ) {
            $('#compare_top > .left_title').append(xq)
        }
        if ( $('ol.breadcrumb').length > 0) {
            $('ol.breadcrumb > li.active').append(xq)
        }
    }
    if (location.host.replace('www.', '') === 'xueqiu.com') {
        var addrX = location.pathname
        var codeX = addrX.split('/').pop()
        var jslUrlDtail = classify(codeX)
        if (!jslUrlDtail) {
            return
        }
        var jsl = `&emsp; <a  href= ${jslUrlDtail} target='_blank'><img style='height: 1.5rem' src='https://www.jisilu.cn/favicon.ico' /></a>`
        $('#app .stock-name').eq(0).after(jsl)
    }
})()