Disable Reddit Wiki edit until fully loaded

Disables the "Edit" button when editing a wiki page on Reddit, until the page is fully loaded

  1. // ==UserScript==
  2. // @name Disable Reddit Wiki edit until fully loaded
  3. // @description Disables the "Edit" button when editing a wiki page on Reddit, until the page is fully loaded
  4. // @author qsniyg
  5. // @version 0.0.1
  6. // @namespace Violentmonkey Scripts
  7. // @match https://*.reddit.com/r/*/wiki/edit/*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. function finalize() {
  14. var editbtn = document.getElementById("wiki_save_button");
  15. editbtn.disabled = false;
  16. editbtn.value += " | OK";
  17. }
  18. if (document.readyState !== "complete") {
  19. var interval = setInterval(function() {
  20. var editbtn = document.getElementById("wiki_save_button");
  21. if (editbtn) {
  22. clearInterval(interval);
  23. interval = null;
  24. editbtn.disabled = true;
  25. }
  26. }, 10);
  27. document.onreadystatechange = function() {
  28. if (document.readyState === "complete") {
  29. if (interval)
  30. clearInterval(interval);
  31. finalize();
  32. }
  33. };
  34. } else {
  35. finalize();
  36. }
  37. })();