Greasy Fork 还支持 简体中文。

HotPot.ai Confirm Page Refresh

Ask for confirmation before refreshing the page, help to not lose all generated images data to reload page...

  1. // ==UserScript==
  2. // @name HotPot.ai Confirm Page Refresh
  3. // @namespace Wizzergod
  4. // @version 1.0.2
  5. // @description Ask for confirmation before refreshing the page, help to not lose all generated images data to reload page...
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=hotpot.ai
  7. // @license MIT
  8. // @author Wizzergod
  9. // @match *://hotpot.ai/art-generator*
  10. // @match *://hotpot.ai/remove-background*
  11. // @match *://hotpot.ai/anime-generator*
  12. // @match *://hotpot.ai/logo-generator*
  13. // @match *://hotpot.ai/headshot/train*
  14. // @match *://hotpot.ai/colorize-picture*
  15. // @match *://hotpot.ai/restore-picture*
  16. // @match *://hotpot.ai/enhance-face*
  17. // @match *://hotpot.ai/drive*
  18. // @match *://hotpot.ai/s/*
  19. // @match *://hotpot.ai/upscale-photo*
  20. // @match *://hotpot.ai/sparkwriter*
  21. // @match *://hotpot.ai/background-generator*
  22. // @match *://hotpot.ai/lunar-new-year-headshot*
  23. // @match *://hotpot.ai/ai-avatar*
  24. // @grant GM_setValue
  25. // @grant GM_getValue
  26. // @run-at document-start
  27. // ==/UserScript==
  28.  
  29. (function() {
  30. 'use strict';
  31.  
  32. function showConfirmation() {
  33. return window.confirm("Вы точно хотите обновить страницу?");
  34. }
  35.  
  36. window.addEventListener('beforeunload', function(event) {
  37. if (showConfirmation()) {
  38. // Keep this part if you want to perform additional actions before the page refresh
  39. } else {
  40. event.preventDefault();
  41. event.returnValue = '';
  42. }
  43. });
  44. })();