Refresh Script (QA Tool)

🔸Use with creating scripts: Creates a button to refresh your Script without having to reload website server.

Tính đến 29-04-2025. Xem phiên bản mới nhất.

  1. // ==UserScript==
  2. // @name Refresh Script (QA Tool)
  3. // @namespace https://bowHip.org/foster
  4. // @version 1.0
  5. // @description 🔸Use with creating scripts: Creates a button to refresh your Script without having to reload website server.
  6. // @author jAdkins
  7. // @match https://*/*
  8. // @grant none
  9. // @License Free usage, use this QA Tool however you like.
  10. // @Email adkinscc@gmail.com
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 🟨🟨 START YOUR SCRIPT HERE 🟨🟨 //
  17.  
  18. function scriptName() {
  19. const div = document.createElement('div');
  20. div.textContent = 'Hello, world!';
  21. return div;
  22. }
  23.  
  24. // << END YOUR SCRIPT HERE >>
  25. //_____________________________________________________________________________________________________________
  26.  
  27.  
  28. // This code below adds " ↻ " icon at top of Browser that refreshes the your script.
  29.  
  30. function setup() {
  31. const wrap = document.createElement('div');
  32. wrap.id = '↻-refresh';
  33. const content = myScript(); //🟨 << ADD NAME OF SCRIPT HERE
  34. wrap.appendChild(content);
  35. document.body.appendChild(wrap);
  36. }
  37.  
  38. function cleanup() {
  39. document.getElementById('↻-refresh')?.remove();
  40. }
  41.  
  42. function refreshScript() {
  43. cleanup();
  44. setup();
  45. }
  46.  
  47. function injectButton() {
  48. if (!document.getElementById('refresh-icon')) {
  49. const refreshIcon = document.createElement('div');
  50. refreshIcon.id = 'refresh-icon';
  51. refreshIcon.textContent = '↻';
  52. refreshIcon.title = 'Refreshes your script';
  53. refreshIcon.style.position = 'fixed';
  54. refreshIcon.style.top = '10px';
  55. refreshIcon.style.left = '50%';
  56. refreshIcon.style.right = '25px';
  57. refreshIcon.style.width = '32px';
  58. refreshIcon.style.height = '32px';
  59. refreshIcon.style.lineHeight = '28px'; // vertical centering
  60. refreshIcon.style.fontSize = '14px'; // shrink text too
  61. refreshIcon.style.padding = '0';
  62. refreshIcon.style.borderRadius = '55%';
  63. refreshIcon.style.fontWeight = '200';
  64. refreshIcon.style.background = '#444';
  65. refreshIcon.style.color = '#fff';
  66. refreshIcon.style.fontSize = '18px';
  67. refreshIcon.style.textAlign = 'center';
  68. refreshIcon.style.userSelect = 'none';
  69. refreshIcon.style.cursor = 'pointer';
  70. refreshIcon.style.zIndex = '9999';
  71. refreshIcon.style.padding = '0'; // <- Important: no padding!
  72.  
  73. document.body.appendChild(refreshIcon);
  74.  
  75. let rotation = 0;
  76.  
  77. refreshIcon.addEventListener('click', () => {
  78. rotation += 360;
  79. refreshIcon.style.transition = 'transform 0.5s';
  80. refreshIcon.style.transform = `rotate(${rotation}deg)`;
  81.  
  82. setTimeout(() => {
  83. }, 400);
  84. });
  85. }
  86. }
  87.  
  88. const tryAdd = setInterval(() => {
  89. if (!document.getElementById('refresh-icon')) {
  90. injectButton();
  91. } else {
  92. clearInterval(tryAdd); // Stop once it's added
  93. }
  94. }, 500); // Check faster but only until it succeeds
  95.  
  96. // First launch
  97. setup();
  98.  
  99. })();