jisilux

辅助选股小工具,方便查看相关信息。

目前为 2024-03-07 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name jisilux
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.07
  5. // @description 辅助选股小工具,方便查看相关信息。
  6. // @author scl
  7. // @license https://www.apache.org/licenses/LICENSE-2.0
  8. // @match https://*.jisilu.cn/data/*
  9. // @match https://*.xueqiu.com/*
  10. // @connect 192.168.196.9 //配套服务器,查询个股指标用,非作者不能使用。
  11. // @icon https://www.jisilu.cn/favicon.ico
  12. // @grant GM_xmlhttpRequest
  13. // @run-at document-end
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict'
  18. const xqUrl = 'https://xueqiu.com/S/'
  19. const jslUrl = 'https://www.jisilu.cn/data/'
  20. const server = 'http://192.168.196.9:9096/indicator'
  21. const sh = /^(11|50|51|56|58|60|68|70|73|90)\d{4}$/ // 沪市证券
  22. const sz = /^(00|08|12|15|16|20|30)\d{4}$/ // 深市证券
  23. const bj = /^(43|83|87|88)\d{4}$/ //北交所
  24. const cb = /^(110|113|123|127|128)\d{3}$/ // 可转债
  25. const etf = /^(15|51|56|58)\d{4}$/ //这个跳到jsl会有错漏,ETF中的qdii ,jsl是分开的。没有找到分开的规律。
  26. const stock = /^(600|601|603|605|688|900|000|001|002|300|301|200|430|830|831|871)\d{3}$/ //20240306更新了部分新代码
  27. const lof = /^(16|50)\d{4}$/ //这个错的最多,qdii 封闭基金 都有可能,没有找到规律。
  28. console.log('jisulux is starting')
  29. //preSet
  30. function purifyCode(code) {
  31. return code.replace(/[a-z]*/gi, '')
  32. }
  33. function addPrefix(code) {
  34. code = purifyCode(code)
  35. if (sh.test(code)) {
  36. return 'SH' + String(code)}
  37. else if (sz.test(code)) {
  38. return 'SZ' + String(code)}
  39. else if (bj.test(code)) {
  40. return 'BJ' + String(code)}
  41. else {
  42. return false
  43. }
  44. }
  45. function classify(code) {
  46. code = purifyCode(code)
  47. if (cb.test(code)) {
  48. return jslUrl.concat('convert_bond_detail/',code)
  49. } else if (etf.test(code)) {
  50. return jslUrl.concat('etf/detail/',code)
  51. } else if (stock.test(code)) {
  52. return jslUrl.concat('stock/detail/',code)
  53. } else if (lof.test(code)) {
  54. return jslUrl.concat('lof/detail/',code)
  55. } else {
  56. return false
  57. }
  58. }
  59. function fetchIndicator(code){ //#0077dd 蓝色最好 #009933 绿色普通 #dd2200 红色警惕
  60. let url = server + '?stocks='+ String(code)
  61. GM_xmlhttpRequest({
  62. method: 'GET',
  63. url: url,
  64. onload: function(response) {
  65. let indicator, roeColor, alrColor
  66. let res = JSON.parse(response.response)
  67. let EPS = parseFloat(/^-?\d+\.\d+/.exec($('#app .quote-info td:contains("每股收益")>span')[0].innerText)[0])
  68. let BVPS = parseFloat(/^-?\d+\.\d+/.exec($('#app .quote-info td:contains("每股净资产")>span')[0].innerText)[0])
  69. let roe = (EPS/BVPS*100).toFixed(1)
  70. if(roe>15){roeColor='#0077dd'}else if(roe<=5){roeColor='#dd2200'}else{roeColor='#009933'}
  71. if (res) {
  72. console.log('市销率ttm',res.ps,'毛利率',res.gpm)
  73. let alr = res.alr.toFixed(1)
  74. if(alr>50){alrColor='#dd2200'}else if(alr<=20){alrColor='#0077dd'}else{alrColor='#009933'}
  75. indicator = `<a class="stock-relation"><span>Roe </span><span style='color:${roeColor}'>${roe}% </span><span >负债 </span><span style='color:${alrColor}'>${alr}% </span></a>`
  76. } else {
  77. indicator = `<a class="stock-relation"><span>Roe </span><span style='color:${roeColor}'>${roe}% </span></a>`
  78. }
  79. ////
  80. let total_share = parseFloat(/\d+\.\d+/.exec($('#app .quote-info td:contains("总股本")>span')[0].innerText)[0])
  81. let dividend_yield = $('#app .quote-info td:contains("股息率")>span')[0].innerText.replace(new RegExp('%', 'g'), '')
  82. if (isNaN(dividend_yield)){dividend_yield = false} else if(parseFloat(/\d+\.\d+/.exec(dividend_yield )[0])>= 5){dividend_yield = 5}else{dividend_yield = false}
  83. if (total_share >= 5 && total_share <= 300 ){$('td:contains("总股本")>span')[0].style = 'color:#07d'}
  84. if (dividend_yield){$('td:contains("股息率")>span')[0].style = 'color:#07d'}
  85. $('#app .stock-info').eq(0).after(indicator)
  86. new MutationObserver((recordList) => {
  87. if (recordList[0].removedNodes.length!=0){
  88. $('#app .stock-info').eq(0).after(indicator)
  89. if (total_share >= 5 && total_share <= 300 ){$('td:contains("总股本")>span')[0].style = 'color:#07d'}
  90. if (dividend_yield){$('td:contains("股息率")>span')[0].style = 'color:#07d'}
  91. }
  92. }).observe( document.querySelector( 'div.quote-container' ), {
  93. childList: true
  94. })
  95. },
  96. onerror: function(error) {
  97. console.error("Request failed:", error)
  98. }
  99. })
  100. }
  101. // start
  102. window.addEventListener('load', function() {
  103. let code = location.pathname.split('/').pop()
  104. if (location.hostname.replace('www.', '') === 'jisilu.cn') {
  105. let fullCode = addPrefix(code)
  106. if (!fullCode) { return }
  107. let xqUrlDetail = xqUrl.concat(fullCode)
  108. let xq = `<div style="flex:1 1 auto;"><a href= ${xqUrlDetail} target='_blank'> <img src='https://xueqiu.com/favicon.ico' width="20px" /></a></div>`
  109. let xq2 = `<li><a href= ${xqUrlDetail} target='_blank'> <img src='https://xueqiu.com/favicon.ico' width="18px" /></a></li>`
  110. if ( $('#compare_top').length > 0 ) {
  111. $('#compare_top > .left_title').after(xq)
  112. }
  113. if ( $('ol.breadcrumb').length > 0) {
  114. $('ol.breadcrumb > li.active').after(xq2)
  115. }
  116. }
  117. //
  118. if (location.hostname.replace('www.', '') === 'xueqiu.com') {
  119. if (location.pathname.match(/^\/[0-9]{10}\/[0-9]{8}/)) {
  120. [...document.querySelectorAll('div.article__container')].forEach(item=>{
  121. item.oncopy = function(e) {
  122. e.stopPropagation()
  123. }
  124. })
  125. $('.article__bd__detail h-char').removeClass('bd-hangable')
  126. } else if (location.pathname.match(/^\/S\//)) {
  127. if (code.match('S[HZ]')&&stock.test(purifyCode(code))){
  128. fetchIndicator(code)
  129. }
  130. let jslUrlDtail = classify(code)
  131. if (!jslUrlDtail) { return }
  132. let jsl = `&emsp; <a href= ${jslUrlDtail} target='_blank'><img style='height: 1.5rem' src='https://www.jisilu.cn/favicon.ico' /></a>`
  133. $('#app .stock-name').eq(0).after(jsl)
  134. }
  135. }
  136. })
  137. })()