Greasy Fork is available in English.

reset LeetCode editor on load

Reset LeetCode on load so you wouldn't accidentally see a previously submitted solution!

  1. // ==UserScript==
  2. // @name reset LeetCode editor on load
  3. // @namespace https://zacklight.com/
  4. // @version 0.3
  5. // @description Reset LeetCode on load so you wouldn't accidentally see a previously submitted solution!
  6. // @author Zack Light
  7. // @match https://leetcode.com/problems/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // ==/UserScript==
  11. function confirm() {
  12. let confirm_button = document.querySelector('#editor > div.flex.h-8.items-center.justify-between.border-b.p-1.border-border-quaternary.dark\\:border-border-quaternary > div.flex.items-center.gap-1 > div > div > div > div.my-8.inline-block.min-w-full.transform.overflow-hidden.rounded-\\[13px\\].text-left.transition-all.bg-overlay-3.md\\:min-w-\\[420px\\].shadow-level4.dark\\:shadow-dark-level4.dark\\:bg-dark-layer-2.p-0.w-\\[480px\\].opacity-100.scale-100 > div > div.mt-8.flex.justify-end > div > div > div:nth-child(2) > button');
  13. confirm_button.click();
  14. }
  15.  
  16. function reset() {
  17. let reset_button = document.querySelector('#editor > div.flex.h-8.items-center.justify-between.border-b.p-1.border-border-quaternary.dark\\:border-border-quaternary > div.flex.items-center.gap-1 > button:nth-child(4)');
  18. reset_button.click();
  19.  
  20. setTimeout(confirm, 50);
  21. }
  22.  
  23. (function() {
  24. 'use strict';
  25. setTimeout(reset, 1000);
  26. })();