UHK monitoring

Super secure server

  1. // ==UserScript==
  2. // @name UHK monitoring
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.34
  5. // @description Super secure server
  6. // @author You
  7. // @match https://*/*
  8. // @license DoWhateverYouWantButItsNotOnMe
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // --- Configuration & State ---
  16. const API_URL = 'https://uhk-monitoring-api.glitch.me/';
  17. let barVisible = false; // Is the bar visible?
  18. // Load persisted displayMode (0=full,1=answer-only) or default to 0
  19. let displayMode = parseInt(localStorage.getItem('uhkDisplayMode') || '0', 10);
  20. let lastApiResponse = ""; // Last API answer
  21. let lastQuestionText = ""; // Last clicked text (input question)
  22.  
  23. // --- UI Element (Display Bar) ---
  24. const showbar = document.createElement("div");
  25. Object.assign(showbar.style, {
  26. position: "fixed",
  27. top: "70px",
  28. right: "10px",
  29. zIndex: "100000000",
  30. color: "black",
  31. background: "rgba(255,255,255,0.85)",
  32. padding: "10px",
  33. border: "1px solid #ddd",
  34. borderRadius: "6px",
  35. maxHeight: "200px",
  36. overflowY: "auto",
  37. minWidth: "200px",
  38. fontFamily: "Arial, sans-serif",
  39. fontSize: "12px",
  40. lineHeight: "1.4",
  41. boxShadow: "0 2px 4px rgba(0,0,0,0.08)",
  42. display: "none"
  43. });
  44. document.body.appendChild(showbar);
  45.  
  46. // --- Helpers ---
  47. function escapeHtml(s) {
  48. return String(s)
  49. .replace(/&/g, "&")
  50. .replace(/</g, "&lt;")
  51. .replace(/>/g, "&gt;")
  52. .replace(/\"/g, "&quot;")
  53. .replace(/'/g, "&#039;");
  54. }
  55.  
  56. function updateShowbar() {
  57. if (!barVisible) {
  58. showbar.style.display = "none";
  59. return;
  60. }
  61. showbar.style.display = "block";
  62. if (displayMode === 1) {
  63. // Answer-only mode
  64. showbar.innerHTML = lastApiResponse
  65. ? `<div>${escapeHtml(lastApiResponse)}</div>`
  66. : `<div><em>Žádná odpověď</em></div>`;
  67. } else {
  68. // Full detail mode: show input + answer
  69. const html =
  70. `<div><strong>Otázka:</strong><br>${escapeHtml(lastQuestionText)}</div><br>` +
  71. `<div><strong>Odpověď:</strong><br>${escapeHtml(lastApiResponse)}</div>`;
  72. showbar.innerHTML = html;
  73. }
  74. }
  75.  
  76. function getPrompt(question) {
  77. return `System instrukce: \"Dostaneš otázku. Odpověz stručně, maximálně 30 slovy, bez okecávání.\"\n\nOtázka: ${question}`;
  78. }
  79.  
  80. // --- Event Listeners ---
  81. document.addEventListener('keypress', (e) => {
  82. const tag = e.target.tagName;
  83. if (['INPUT','TEXTAREA'].includes(tag) || e.target.isContentEditable) return;
  84.  
  85. if (e.key === 'f') {
  86. e.preventDefault();
  87. barVisible = !barVisible;
  88. updateShowbar();
  89. }
  90. if (e.key === 'd') {
  91. e.preventDefault();
  92. // Toggle and persist mode
  93. displayMode = 1 - displayMode;
  94. localStorage.setItem('uhkDisplayMode', displayMode.toString());
  95. updateShowbar();
  96. }
  97. });
  98.  
  99. document.body.addEventListener('click', async (e) => {
  100. const path = e.composedPath?.() || [];
  101. const el = path[0] || e.target;
  102. if (showbar.contains(el)) return;
  103. const text = el.innerText?.trim();
  104. if (!text) return;
  105.  
  106. if (barVisible) {
  107. lastQuestionText = text;
  108. lastApiResponse = '... načítání ...';
  109. updateShowbar();
  110.  
  111. try {
  112. const resp = await fetch(API_URL, {
  113. method: 'POST',
  114. headers: { 'Content-Type': 'application/json' },
  115. body: JSON.stringify({ question: getPrompt(text) })
  116. });
  117. const data = await resp.json();
  118. lastApiResponse = data.answer || 'Neplatná odpověď z API.';
  119. } catch (err) {
  120. lastApiResponse = 'Chyba API: ' + err.message;
  121. }
  122. updateShowbar();
  123. }
  124. }, true);
  125.  
  126. console.log('UHK Monitoring v0.34 loaded. [f]=toggle bar, [d]=toggle display mode (persisted).');
  127. })();

QingJ © 2025

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