AutoComplete Course

Mask as done all your Udemy's classes. Will be shown a blue button to complete the opened course.

  1. // ==UserScript==
  2. // @name AutoComplete Course
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.5
  5. // @description Mask as done all your Udemy's classes. Will be shown a blue button to complete the opened course.
  6. // @author Marcello Cavazza
  7. // @match https://www.udemy.com/course/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=udemy.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var button = document.createElement('button');
  16.  
  17. button.textContent = 'Complete course';
  18. button.style.zIndex = '99999999';
  19. button.style.position = 'fixed';
  20. button.style.top = '20px';
  21. button.style.left = '20px';
  22. button.style.background = '#007bff';
  23. button.style.color = '#fff';
  24. button.style.border = 'none';
  25. button.style.padding = '10px 20px';
  26. button.style.borderRadius = '5px';
  27. button.style.cursor = 'pointer';
  28.  
  29. document.body.appendChild(button);
  30.  
  31. button.addEventListener('click', function() {
  32. try{
  33. const mainContentList = document.getElementById("ct-sidebar-scroll-container");
  34. if(mainContentList != undefined && mainContentList.childNodes.length > 0){
  35. let chapters = mainContentList.children[0].children[0].childNodes;
  36. if(chapters != undefined) {
  37. //marking as complete each class
  38. chapters.forEach((child) => {
  39. const isChapterOpen = child.children[0].dataset.checked === "checked";
  40. if(!isChapterOpen) {
  41. child.children[1].click();
  42. }
  43. const canIFindContentForThisChapter = child.children[child.childNodes.length-1].children[0].childNodes.length > 0;
  44. if(canIFindContentForThisChapter){
  45. const classesOfCurrentChapter = child.children[child.childNodes.length-1].children[0].children[0].childNodes;
  46. if(classesOfCurrentChapter != undefined){
  47. classesOfCurrentChapter.forEach((classOfChapter)=>{
  48. const buttonToConcludeClass = classOfChapter.children[0].children[0].children[0];
  49. const isAlreadyChecked = buttonToConcludeClass.childNodes[0].checked;
  50.  
  51. if(!isAlreadyChecked){
  52. buttonToConcludeClass.click();
  53. }
  54. });
  55. }
  56. }
  57. });
  58. //now it will enter on the last class and make udemy identify as completed the course
  59. const lastChapter = chapters[chapters.length-1];
  60. const isChapterOpen = lastChapter.children[0].dataset.checked === "checked";
  61. if(!isChapterOpen) {
  62. lastChapter.children[1].click();
  63. }
  64. const amountOfClasses = lastChapter.children[lastChapter.childNodes.length-1].children[0].children[0].childNodes.length;
  65. const canIFindContentForThisChapter = amountOfClasses > 0;
  66. if(canIFindContentForThisChapter){
  67. const classOfCurrentChapter = lastChapter.children[lastChapter.childNodes.length-1].children[0].children[0].childNodes[amountOfClasses - 1];
  68. classOfCurrentChapter.click();
  69. }
  70.  
  71. window.alert("Completed all course!\nPage will be refreshed!\nIf doesn't complete everything, just click the button again.");
  72. location.reload(true)
  73. }
  74. }
  75. }catch(ex){
  76. console.error(ex);
  77. }
  78. });
  79. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址