npmjs

npm下载量查看

  1. // ==UserScript==
  2. // @name npmjs
  3. // @description npm下载量查看
  4. // @namespace npm_script
  5. // @version 1.2.2
  6. // @author vizo
  7. // @require https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js
  8. // @include *://*npmjs.com/search*
  9. // @include *://*npmjs.com/package*
  10. // @run-at document-end
  11. // @grant GM_addStyle
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @noframes
  15.  
  16. // @grant GM_getResourceText
  17. // @grant GM_xmlhttpRequest
  18. // @connect *
  19.  
  20. // ==/UserScript==
  21.  
  22. 'use strict'
  23.  
  24. GM_addStyle(`
  25. .spr7s {
  26. color: #f00;
  27. font-size: 12px;
  28. font-weight: normal;
  29. margin-left: 10px;
  30. font-family: Arial;
  31. font-style: italic;
  32. }
  33. .i_mxs {
  34. font-style: italic;
  35. color: #b1b1b1;
  36. font-size: 12px;
  37. margin-left: 15px;
  38. font-weight: normal;
  39. }
  40. .code1s {
  41. display: block;
  42. border: 1px solid #0ad;
  43. padding: 5px;
  44. }
  45. .code1s * {
  46. font-family: Consolas, "Helvetica Neue", PingFang SC, sans-serif !important;
  47. font-size: 14px;
  48. font-weight: normal;
  49. }
  50. .code1s pre {
  51. margin-bottom: 0;
  52. }
  53. `)
  54.  
  55. let timer1s = null
  56.  
  57. $(function () {
  58. function initScript() {
  59. eachItem()
  60. }
  61. function reqItemDetail(url, domTit) {
  62. GM_xmlhttpRequest({
  63. url,
  64. method: 'get',
  65. onload: function(xhr) {
  66. try {
  67. let text = xhr.response
  68. let downNum = text.replace(/[\n\r\f]/g, '').replace(/.+pb1">(.+?)<\/p>.+/g, '$1')
  69. if (downNum.length > 20) return
  70. domTit.append(`<span class="spr7s">${downNum}</span><i class="i_mxs">流行度,质量,更新</i>`)
  71. } catch (e) {}
  72. },
  73. })
  74. }
  75. // 遍历item
  76. function eachItem() {
  77. let ns = $('.pt2-ns .pl1-ns')
  78. ns.each((i, v) => {
  79. let tis = $(v)
  80. let url = tis.find('.pr3 > a').attr('href')
  81. let h3 = tis.find('.pr3 > a > h3.fw6')
  82. let cts = h3.find('.spr7s')
  83. if (!cts.length && i < 4) {
  84. reqItemDetail(url, h3)
  85. }
  86. })
  87. }
  88. setTimeout(() => {
  89. $('.highlight pre').wrap('<code class="code1s"></code>')
  90. }, 1000)
  91. initScript()
  92. })

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址