Auto start LeetCode timer

Automatically start LeetCode official timer.

As of 2022-12-22. See the latest version.

  1. // ==UserScript==
  2. // @name Auto start LeetCode timer
  3. // @name:zh-tw 自動開始 LeetCode 計時器
  4. // @namespace https://github.com/zica87/self-made-userscipts
  5. // @version 1.0
  6. // @description Automatically start LeetCode official timer.
  7. // @description:zh-tw 自動開始 LeetCode 官方計時器。
  8. // @author zica
  9. // @match https://leetcode.com/problems/*
  10. // @grant none
  11. // @license GPL-2.0
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. if (document.URL.includes("/solutions/")) return;
  18.  
  19. const observer = new MutationObserver((records, observerInstance)=>{
  20. const timer = document.getElementsByClassName('hover:text-gray-7')[0];
  21. if (!timer) return;
  22. timer.click();
  23. observerInstance.disconnect();
  24. });
  25. observer.observe(document.body, {
  26. childList: true,
  27. subtree: true
  28. });
  29. })();