↻ Refresh Script (QA Tool)

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

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