Show Number of LeetCode Unsolved Problems

Show Number of LeetCode Unsolved Problems for the new style

Verze ze dne 15. 06. 2017. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name Show Number of LeetCode Unsolved Problems
  3. // @namespace https://greatest.deepsurf.us/en/users/114838-groundzyy
  4. // @version 0.1
  5. // @author groundzyy
  6. // @match https://leetcode.com/problemset/*
  7. // @description Show Number of LeetCode Unsolved Problems for the new style
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12. observeDomChange();
  13. })();
  14.  
  15. function observeDomChange() {
  16. var MutationObserver = window.MutationObserver;
  17. var myObserver = new MutationObserver (mutationHandler);
  18. var obsConfig = {
  19. childList: true, attributes: true,
  20. subtree: true, attributeFilter: ['list-group']
  21. };
  22. myObserver.observe(document, obsConfig);
  23. function mutationHandler (mutationRecords) {
  24. if ($('#welcome > span').length == 1) {
  25. info = $('#welcome > span > span:nth-child(1)').text().split(" ");
  26. num_finished = Number(info[0].split('/')[0]);
  27. num_questions = Number(info[0].split('/')[1]);
  28. $('#welcome').append('<br/><span>' + num_finished + "/" + num_questions + ' (' + (num_questions - num_finished) + ')</span>');
  29. }
  30. }
  31. }