雪球助手

方便跳转到理性仁网站查看个股数据

目前为 2017-12-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 雪球助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description 方便跳转到理性仁网站查看个股数据
  6. // @author 小紫baby
  7. // @include /^https:\/\/xueqiu\.com.*/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /*eslint-disable*/
  12. (function () {
  13. 'use strict';
  14.  
  15. function getMarketCode(code) {
  16. var len = code.toString().length;
  17. if ([5, 6].indexOf(len) === -1) {
  18. console.warn('股票代码未知:' + code);
  19. return;
  20. }
  21.  
  22. if (len === 5) return 'hk';
  23. if (code.indexOf('00') === 0) {
  24. return 'sz';
  25. }
  26.  
  27. if (code.indexOf('60') === 0) {
  28. return 'sh';
  29. }
  30.  
  31. return;
  32. }
  33.  
  34. function getLixingrenStockPageUrl(marketCode, stockCode) {
  35. return 'https://www.lixinger.com/analytics/company/' + marketCode + '/' + stockCode + '/detail/fundamental/value';
  36. }
  37.  
  38. /**
  39. * 主页自选股跳转到理性仁
  40. */
  41. var linkSelector = '#optional tr.sortable a.code';
  42. $(document.body).on('click', linkSelector, function(e) {
  43. var href = $(this).attr('href').toLowerCase();
  44. if (href.indexOf('www.lixinger.com') > -1) {
  45. return;
  46. }
  47.  
  48. var code = href.match(/\d+/);
  49. if (code.length === 0) {
  50. console.warn('未知信息:' + href);
  51. return;
  52. }
  53. code = code[0];
  54. var marketCode = getMarketCode(code);
  55. $(this).attr('href', getLixingrenStockPageUrl(marketCode, code));
  56. });
  57.  
  58. /**
  59. * 股票页跳转到理性仁
  60. */
  61. var titleSelector = '.stock-name';
  62. $(titleSelector).after('<div style="float: left;width: 16px; height: 16px;margin: 0 16px;">' +
  63. '<a class="lxr-icon" target="_blank"><img src="https://www.lixinger.com/static/img/favicon.ico" style="vertical-align: middle;" /></a></div>');
  64. $('.lxr-icon').one('mouseenter', function() {
  65. var code = location.href.match(/\d+/)[0];
  66. var marketCode = getMarketCode(code);
  67. $(this).attr('href', getLixingrenStockPageUrl(marketCode, code));
  68. });
  69. })();