// ==UserScript== // @name 雪球助手 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 方便跳转到理性仁网站查看个股数据 // @author Simon // @include /^https:\/\/xueqiu\.com.*/ // @grant none // @downloadURL none // ==/UserScript== /*eslint-disable*/ (function () { 'use strict'; function getMarketCode(code) { var len = code.toString().length; if ([5, 6].indexOf(len) === -1) { console.warn('股票代码未知:' + code); return; } if (len === 5) return 'hk'; if (code.indexOf('00') === 0) { return 'sz'; } if (code.indexOf('60') === 0) { return 'sh'; } return; } function getLixingrenStockPageUrl(marketCode, stockCode) { return 'https://www.lixinger.com/analytics/company/' + marketCode + '/' + stockCode + '/detail/fundamental/value'; } /** * 主页自选股跳转到理性仁 */ var linkSelector = '#optional tr.sortable a.code'; $(document.body).on('click', linkSelector, function(e) { var href = $(this).attr('href').toLowerCase(); if (href.indexOf('www.lixinger.com') > -1) { return; } var code = href.match(/\d+/); if (code.length === 0) { console.warn('未知信息:' + href); return; } code = code[0]; var marketCode = getMarketCode(code); $(this).attr('href', getLixingrenStockPageUrl(marketCode, code)); }); /** * 股票页跳转到理性仁 */ var titleSelector = '.stock-name'; $(titleSelector).after('
'); $('.lxr-icon').one('mouseenter', function() { var code = location.href.match(/\d+/)[0]; var marketCode = getMarketCode(code); $(this).attr('href', getLixingrenStockPageUrl(marketCode, code)); }); })();