hpc_job

self mode

  1. // ==UserScript==
  2. // @name hpc_job
  3. // @version 0.0.6
  4. // @include http://219.217.238.193/job
  5. // @include http://h/job
  6. // @include http://hh/job
  7. // @description self mode
  8. // @run-at document-start
  9. // @namespace https://gf.qytechs.cn/users/164996
  10. // ==/UserScript==
  11. const head = `<meta charset="UTF-8" />
  12. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  13. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  14. <title>job</title>
  15. <style>
  16. body {
  17. user-select: none;
  18. margin: 0;
  19. }
  20. #table {
  21. display: grid;
  22. grid-template-columns: repeat(9, auto);
  23. grid-column-gap: 1em;
  24. }
  25. #node{
  26. margin: 0;
  27. }
  28. .other {
  29. color: #bbb;
  30. }
  31. #disconnect{
  32. display: none;
  33. color: #bbb;
  34. position: fixed;
  35. left: 50%;
  36. transform: translateX(-50%);
  37. }
  38. </style>`
  39. const body = `<div id="app">
  40. <div id='disconnect'>disconnect</div>
  41. <pre id="node"></pre>
  42. <div id="table"></div>
  43. </div>`
  44. document.head.innerHTML = head
  45. document.body.innerHTML = body
  46. const timeout = 5000
  47. const usr = 'bilabila'
  48. const app = document.querySelector('#app')
  49. const node = document.querySelector('#node')
  50. const table = document.querySelector('#table')
  51. const disconnect = document.querySelector('#disconnect')
  52. const parse = s => {
  53. const t = document.implementation.createHTMLDocument()
  54. t.body.innerHTML = s
  55. return t
  56. }
  57. const fetchWithTimeout = (url, options) => {
  58. return Promise.race([
  59. fetch(url, options),
  60. new Promise((_, reject) =>
  61. setTimeout(() => reject(new Error('timeout')), timeout)
  62. )
  63. ])
  64. }
  65. const main = async () => {
  66. let a
  67. try {
  68. a = await fetchWithTimeout(window.location.href + 's')
  69. a = await a.text()
  70. } catch (error) {
  71. disconnect.style.display = 'block'
  72. return
  73. }
  74. disconnect.style.display = 'none'
  75. a = parse(a)
  76. let b = [...a.querySelectorAll('tr')].map(i =>
  77. [...i.children].map(j => j.textContent.trim())
  78. )
  79. let c = b.reduceRight(
  80. (a, c) =>
  81. c[1] === usr
  82. ? c.map(i => '<div>' + i + '</div>').join('') + a
  83. : a + c.map(i => '<div class=other>' + i + '</div>').join(''),
  84. ''
  85. )
  86. let d = a.querySelector('table').nextSibling.textContent.trim()
  87. d = d.slice(d.indexOf('\n') + 1, d.lastIndexOf('\n'))
  88. requestAnimationFrame(() => {
  89. node.innerHTML = d
  90. table.innerHTML = c
  91. })
  92. }
  93.  
  94. main()
  95. let timer = setInterval(main, timeout)
  96. let changeTimer
  97.  
  98. document.addEventListener(
  99. 'visibilitychange',
  100. () => {
  101. clearTimeout(changeTimer)
  102. if (document.hidden) {
  103. changeTimer = setTimeout(() => clearInterval(timer), timeout)
  104. } else {
  105. main()
  106. clearInterval(timer)
  107. timer = setInterval(main, timeout)
  108. }
  109. },
  110. )

QingJ © 2025

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