Greasy Fork镜像 支持简体中文。

Ultimate Auto Refresh with Countdown

Page refresh script with advanced features

  1. // ==UserScript==
  2. // @name Ultimate Auto Refresh with Countdown
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.8
  5. // @description Page refresh script with advanced features
  6. // @author ibomen
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const defaultRefreshInterval = 60; // Varsayılan yenileme süresi (saniye)
  15. let refreshInterval = defaultRefreshInterval;
  16. let timeLeft = refreshInterval;
  17. let isRunning = true;
  18. let theme = localStorage.getItem('theme') || 'dark'; // Tema tercihini yerel depodan al
  19. let currentLanguage = localStorage.getItem('scriptLanguage') || 'en'; // Dil ayarını yerel depodan al
  20.  
  21. const translations = {
  22. en: {
  23. pageRefresh: 'Page will refresh in',
  24. refreshStopped: 'Refresh stopped',
  25. stop: 'Stop',
  26. start: 'Start',
  27. reset: 'Reset',
  28. refreshInterval: 'Refresh interval (seconds)',
  29. changeTheme: 'Change Theme',
  30. donate: 'Donate',
  31. donationInfo: 'TRX: TC9bVN7tBr6DBjKGDZ51pz8D9TdD4DqreF',
  32. },
  33. tr: {
  34. pageRefresh: 'Sayfa içinde yenilenecek',
  35. refreshStopped: 'Yenileme durduruldu',
  36. stop: 'Durdur',
  37. start: 'Başlat',
  38. reset: 'Sıfırla',
  39. refreshInterval: 'Yenileme süresi (saniye)',
  40. changeTheme: 'Tema Değiştir',
  41. donate: 'Bağış Yap',
  42. donationInfo: 'TRX: TC9bVN7tBr6DBjKGDZ51pz8D9TdD4DqreF',
  43. }
  44. };
  45.  
  46. // Log ekranı oluşturma
  47. const logDiv = document.createElement('div');
  48. logDiv.style.position = 'fixed';
  49. logDiv.style.bottom = '10px';
  50. logDiv.style.right = '10px';
  51. logDiv.style.width = '250px';
  52. logDiv.style.padding = '10px';
  53. logDiv.style.backgroundColor = theme === 'dark' ? '#000000' : '#ffffff';
  54. logDiv.style.color = theme === 'dark' ? '#ffffff' : '#000000';
  55. logDiv.style.fontFamily = 'Arial, sans-serif';
  56. logDiv.style.zIndex = '9999';
  57. logDiv.style.borderRadius = '5px';
  58. document.body.appendChild(logDiv);
  59.  
  60. // Site adı ve iconu
  61. const siteName = document.createElement('div');
  62. const siteIcon = document.createElement('img');
  63. siteIcon.src = getFavicon();
  64. siteIcon.style.width = '16px';
  65. siteIcon.style.height = '16px';
  66. siteIcon.style.marginRight = '5px';
  67. siteName.appendChild(siteIcon);
  68. siteName.appendChild(document.createTextNode(document.title));
  69. logDiv.appendChild(siteName);
  70.  
  71. // Bağış bölümü
  72. const donationDiv = document.createElement('div');
  73. donationDiv.style.display = 'none';
  74. donationDiv.style.marginTop = '10px';
  75. donationDiv.style.backgroundColor = theme === 'dark' ? '#000000' : '#ffffff';
  76. donationDiv.style.padding = '10px';
  77. donationDiv.style.borderRadius = '5px';
  78. donationDiv.style.color = theme === 'dark' ? '#ffffff' : '#000000';
  79. donationDiv.style.wordWrap = 'break-word'; // Ekrana sığmasını sağlamak için eklenen stil
  80. donationDiv.innerHTML = `<b>${translations[currentLanguage].donationInfo}</b>`;
  81. logDiv.appendChild(donationDiv);
  82.  
  83. // Geri sayım göstergesi
  84. const countdown = document.createElement('div');
  85. countdown.style.marginTop = '10px';
  86. logDiv.appendChild(countdown);
  87.  
  88. // Azalan bar
  89. const progressBar = document.createElement('div');
  90. progressBar.style.width = '100%';
  91. progressBar.style.height = '10px';
  92. progressBar.style.backgroundColor = 'gray';
  93. progressBar.style.marginTop = '10px';
  94. progressBar.style.borderRadius = '5px';
  95. logDiv.appendChild(progressBar);
  96.  
  97. const progress = document.createElement('div');
  98. progress.style.height = '100%';
  99. progress.style.backgroundColor = 'red';
  100. progress.style.borderRadius = '5px';
  101. progressBar.appendChild(progress);
  102.  
  103. // Başlat/Durdur butonu
  104. const toggleButton = document.createElement('button');
  105. toggleButton.textContent = translations[currentLanguage].stop;
  106. toggleButton.style.marginTop = '10px';
  107. toggleButton.style.width = '100%';
  108. logDiv.appendChild(toggleButton);
  109.  
  110. // Sıfırla butonu
  111. const resetButton = document.createElement('button');
  112. resetButton.textContent = translations[currentLanguage].reset;
  113. resetButton.style.marginTop = '5px';
  114. resetButton.style.width = '100%';
  115. logDiv.appendChild(resetButton);
  116.  
  117. // Yenileme süresi girişi
  118. const intervalInput = document.createElement('input');
  119. intervalInput.type = 'number';
  120. intervalInput.value = refreshInterval;
  121. intervalInput.style.marginTop = '5px';
  122. intervalInput.style.width = '100%';
  123. intervalInput.placeholder = translations[currentLanguage].refreshInterval;
  124. logDiv.appendChild(intervalInput);
  125.  
  126. // Tema değiştirme butonu
  127. const themeButton = document.createElement('button');
  128. themeButton.textContent = translations[currentLanguage].changeTheme;
  129. themeButton.style.marginTop = '5px';
  130. themeButton.style.width = '100%';
  131. logDiv.appendChild(themeButton);
  132.  
  133. // Bağış butonu
  134. const donationButton = document.createElement('button');
  135. donationButton.textContent = translations[currentLanguage].donate;
  136. donationButton.style.marginTop = '5px';
  137. donationButton.style.width = '100%';
  138. logDiv.appendChild(donationButton);
  139.  
  140. // Dil seçme butonu
  141. const languageButton = document.createElement('button');
  142. languageButton.textContent = currentLanguage === 'en' ? 'Türkçe' : 'English';
  143. languageButton.style.marginTop = '5px';
  144. languageButton.style.width = '100%';
  145. logDiv.appendChild(languageButton);
  146.  
  147. // Favicon alma fonksiyonu
  148. function getFavicon() {
  149. let favicon = '/favicon.ico';
  150. const nodeList = document.getElementsByTagName('link');
  151. for (let i = 0; i < nodeList.length; i++) {
  152. if (nodeList[i].getAttribute('rel') === 'icon' || nodeList[i].getAttribute('rel') === 'shortcut icon') {
  153. favicon = nodeList[i].getAttribute('href');
  154. }
  155. }
  156. return favicon;
  157. }
  158.  
  159. // Geri sayım fonksiyonu
  160. function updateCountdown() {
  161. if (isRunning) {
  162. countdown.textContent = `${translations[currentLanguage].pageRefresh} ${timeLeft}`;
  163. progress.style.width = `${(timeLeft / refreshInterval) * 100}%`;
  164.  
  165. if (timeLeft <= 0) {
  166. refreshPage();
  167. } else {
  168. timeLeft--;
  169. }
  170. } else {
  171. countdown.textContent = '';
  172. }
  173. }
  174.  
  175. // Sayfa yenileme fonksiyonu
  176. function refreshPage() {
  177. playSound();
  178. location.reload();
  179. }
  180.  
  181. // Tema değiştirme fonksiyonu
  182. function toggleTheme() {
  183. theme = theme === 'dark' ? 'light' : 'dark';
  184. logDiv.style.backgroundColor = theme === 'dark' ? '#000000' : '#ffffff';
  185. logDiv.style.color = theme === 'dark' ? '#ffffff' : '#000000';
  186. donationDiv.style.backgroundColor = theme === 'dark' ? '#000000' : '#ffffff';
  187. donationDiv.style.color = theme === 'dark' ? '#ffffff' : '#000000';
  188. if (theme === 'dark') {
  189. themeButton.style.backgroundColor = '#ffffff';
  190. themeButton.style.color = '#000000';
  191. } else {
  192. themeButton.style.backgroundColor = '#000000';
  193. themeButton.style.color = '#ffffff';
  194. }
  195. localStorage.setItem('theme', theme); // Tema tercihini yerel depoya kaydet
  196. }
  197.  
  198. // Dil değiştirme fonksiyonu
  199. function toggleLanguage() {
  200. currentLanguage = currentLanguage === 'en' ? 'tr' : 'en';
  201. localStorage.setItem('scriptLanguage', currentLanguage); // Dil ayarını yerel depoya kaydet
  202. updateTexts();
  203. }
  204.  
  205. // Metinleri güncelleme fonksiyonu
  206. function updateTexts() {
  207. toggleButton.textContent = isRunning ? translations[currentLanguage].stop : translations[currentLanguage].start;
  208. resetButton.textContent = translations[currentLanguage].reset;
  209. intervalInput.placeholder = translations[currentLanguage].refreshInterval;
  210. themeButton.textContent = translations[currentLanguage].changeTheme;
  211. donationButton.textContent = translations[currentLanguage].donate;
  212. languageButton.textContent = currentLanguage === 'en' ? 'Türkçe' : 'English';
  213. donationDiv.innerHTML = `<b>${translations[currentLanguage].donationInfo}</b>`;
  214. }
  215.  
  216. // Sesli bildirim oynatma
  217. function playSound() {
  218. const audio = new Audio('https://www.soundjay.com/button/beep-07.wav');
  219. audio.play();
  220. }
  221.  
  222. // Başlat/Durdur butonu tıklama olayını işleme
  223. toggleButton.addEventListener('click', () => {
  224. isRunning = !isRunning;
  225. toggleButton.textContent = isRunning ? translations[currentLanguage].stop : translations[currentLanguage].start;
  226. });
  227.  
  228. // Sıfırla butonu tıklama olayını işleme
  229. resetButton.addEventListener('click', () => {
  230. timeLeft = refreshInterval;
  231. });
  232.  
  233. // Yenileme süresi giriş değişikliği olayını işleme
  234. intervalInput.addEventListener('change', () => {
  235. refreshInterval = parseInt(intervalInput.value);
  236. timeLeft = refreshInterval;
  237. });
  238.  
  239. // Tema değiştirme butonu tıklama olayını işleme
  240. themeButton.addEventListener('click', toggleTheme);
  241.  
  242. // Dil seçme butonu tıklama olayını işleme
  243. languageButton.addEventListener('click', toggleLanguage);
  244.  
  245. // Bağış butonu tıklama olayını işleme
  246. donationButton.addEventListener('click', () => {
  247. donationDiv.style.display = donationDiv.style.display === 'none' ? 'block' : 'none';
  248. });
  249.  
  250. // Log ekranını göster
  251. logDiv.style.display = 'block';
  252.  
  253. // Geri sayımı başlatma
  254. updateCountdown();
  255. setInterval(updateCountdown, 1000);
  256. updateTexts(); // Dil ayarını yükledikten sonra metinleri güncelle
  257. })();

QingJ © 2025

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