Greasy Fork

Greasy Fork is available in English.

jisilux

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         jisilux
// @namespace    http://tampermonkey.net/
// @version      0.33
// @description  在jsl与xueqiu同品种页面间跳转,不过从xueqiu转到jsl有地址不对的情况,因为jsl里lof\etf中包含的qdii、封基是分开的,没找到代码上的规律。凑合用啊~~
// @author       [email protected]
// @license      https://www.apache.org/licenses/LICENSE-2.0
// @include      https://*jisilu.cn/data/*
// @include      https://*xueqiu.com/*
// @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 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-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 {
            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.hostname.replace('www.', '') === 'jisilu.cn') {
        var codeJ = location.pathname.split('/').pop()
        var fullCode = addPrefix(codeJ)
        if (!fullCode) { return }
        var xqUrlDetail = xqUrl.concat(fullCode)
        var xq = `<div style="flex:1 1 auto;"><a href= ${xqUrlDetail} target='_blank'> <img src='https://xueqiu.com/favicon.ico' width="20px" /></a></div>`
        if ( $('#compare_top').length > 0 ) {
            $('#compare_top > .left_title').after(xq)
        }
        if ( $('ol.breadcrumb').length > 0) {
            $('ol.breadcrumb > li.active').append(xq)
        }
    }
    if (location.hostname.replace('www.', '') === 'xueqiu.com') {
        if (location.pathname.match(/^\/[0-9]{10}\/[0-9]{8}/)) {
            [...document.querySelectorAll('div.article__container')].forEach(item=>{
                item.oncopy = function(e) {
                    e.stopPropagation()
                }
            })
            $('.article__bd__detail h-char').removeClass('bd-hangable')
        } else if (location.pathname.match(/^\/S\//)) {
            var codeX = location.pathname.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)
        }

    }
})()