leetcode_acProblems_undisplay

undisplay ac problems in leetcode

  1. // ==UserScript==
  2. // @name leetcode_acProblems_undisplay
  3. // @namespace piscat
  4. // @description:en undisplay ac problems in leetcode
  5. // @include http://leetcode.com/*
  6. // @include https://leetcode.com/*
  7. // @version 1.0
  8. // @grant none
  9. // @description undisplay ac problems in leetcode
  10. // ==/UserScript==
  11. window.del = function () {
  12. try {
  13. if (thead.innerHTML == '★') a.innerHTML = '☆'
  14. else a.innerHTML = '★'
  15. } catch (e) {
  16. }
  17. try {
  18. tb = document.getElementById('problemList').children[1]
  19. } catch (e) {
  20. }
  21. if (typeof (tb) == 'undefined') tb = document.getElementById('question_list').children[1]
  22. l = tb.children.length
  23. for (i = 0; i < l; i++) {
  24. tr = tb.children[i];
  25. if (tr.children[0].children[0].className == 'ac') {
  26. if (tr.style.display == 'none') tr.style.display = ''
  27. else {
  28. tr.style.display = 'none'
  29. }
  30. }
  31. }
  32. }
  33. if (/\/problemset\//.test(window.location.href)) {
  34. a = document.getElementsByClassName('header-status') [1];
  35. a.innerHTML = '★'
  36. a.setAttribute('onclick', 'del();')
  37. window.thead = a
  38. }
  39. else if (/\/tag\//.test(window.location.href)) {
  40. a = document.getElementsByClassName('col-md-offset-1 col-md-10') [0].children[0];
  41. a.setAttribute('onclick', 'del();')
  42. }
  43. console.log('success')