Last active
July 19, 2023 15:33
-
-
Save ahmedazhar05/861d742560bcf6d4cf5a49e4fa4695ac to your computer and use it in GitHub Desktop.
Revisions
-
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,4 @@ javascript:(function forwarder(toggle_script_execution = false) { const start_alert = () => console.log("%c Forwarder script started running...", "color: green"); const stop_alert = () => console.log("%c Forwarder script stopped running!", "color: red"); @@ -33,7 +31,7 @@ javascript:(function forwarder(toggle_script_execution = false) { forwarder(); } else { setTimeout(() => { document.querySelector('[data-purpose="go-to-next"].item-link')?.click(); forwarder(); }, EXERCISE_LOAD_TIME); } @@ -65,9 +63,9 @@ javascript:(function forwarder(toggle_script_execution = false) { const icon_type = icon_element.getAttribute('xlink:href'); const current_element_is_completed = currentItem.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.checked; const current_element_is_not_a_lecture = !icon_type && icon_element?.nodeName.toUpperCase() == 'SPAN'; if(current_element_is_completed || current_element_is_not_a_lecture) { goToNextItem(!current_element_is_not_a_lecture); return; } if(icon_type.endsWith('video')){ -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,19 @@ javascript:(function forwarder(toggle_script_execution = false) { console.log("getCurrentItem()"); const start_alert = () => console.log("%c Forwarder script started running...", "color: green"); const stop_alert = () => console.log("%c Forwarder script stopped running!", "color: red"); /* toggling the execution of this whole script */ if(toggle_script_execution && 'ff_set' in window) { window.ff_set = !window.ff_set; if(window.ff_set) start_alert(); } else if(!('ff_set' in window)) { window.ff_set = true; start_alert(); } if(!window.ff_set) { if(toggle_script_execution) stop_alert(); return; } @@ -22,7 +24,7 @@ javascript:(function forwarder(toggle = false) { /* the duration to read the article, for it to be considered 'read', before moving to the next item in the course */ const ARTICLE_READ_TIME = 12000; /* time to wait for the exercise(non-lecture) to load before moving to the next item in the course */ const EXERCISE_LOAD_TIME = 3000; function goToNextItem(is_gotoNext_button_available = true) { if (!window.ff_set) return; @@ -41,7 +43,7 @@ javascript:(function forwarder(toggle = false) { const get_li = () => document.querySelector('li[class*="curriculum-item-link--is-current"]'); const fix1 = () => document.querySelector('div[data-purpose="curriculum-section-container"]')?.querySelectorAll('.ud-accordion-panel-toggler').forEach(x => x.click()); const fix2 = () => document.querySelector('button[class*="course-content-toggle"].ud-heading-md')?.click(); let li = get_li(); if(li) return li; /* else */ @@ -63,7 +65,7 @@ javascript:(function forwarder(toggle = false) { const icon_type = icon_element.getAttribute('xlink:href'); const current_element_is_completed = currentItem.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.checked; const current_element_is_an_exercise = !icon_type && icon_element?.nodeName.toUpperCase() == 'SPAN'; if(current_element_is_completed || current_element_is_an_exercise) { goToNextItem(!current_element_is_an_exercise); return; @@ -72,6 +74,7 @@ javascript:(function forwarder(toggle = false) { setTimeout(() => { if (!window.ff_set) return; let video = document.querySelector('video'); if(video.paused) video.play(); const video_time = "0:" + document.querySelector('span[data-purpose="duration"]').textContent; const last_second_of_the_video = video_time.split(":").slice(-3).map(Number).reverse().reduce((t, x, i) => t + x * Math.pow(60, i), 0); video.currentTime = last_second_of_the_video - (VIDEO_WATCH_TIME + 2000) / 1000; -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 42 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,55 +1,81 @@ javascript:(function forwarder(toggle = false) { const start_alert = () => console.log("%c Forwarder script started running...", "color: green"); const stop_alert = () => console.log("%c Forwarder script stopped running!", "color: red"); /* toggling the execution of this whole script */ if(toggle && 'ff_set' in window) { window.ff_set = !window.ff_set; if(window.ff_set) start_alert(); } else if(!('ff_set' in window)) { window.ff_set = true; start_alert(); } if(!window.ff_set) { if(toggle) stop_alert(); return; } /* time to wait for the video to load before moving to the end of the video */ const VIDEO_LOAD_TIME = 9000; /* the duration to watch the video, for it to be considered 'watched', before moving to the next item in the course */ const VIDEO_WATCH_TIME = 3000; /* the duration to read the article, for it to be considered 'read', before moving to the next item in the course */ const ARTICLE_READ_TIME = 12000; /* time to wait for the exercise(non-lecture) to load before moving to the next item in the course */ const EXERCISE_LOAD_TIME = 5000; function goToNextItem(is_gotoNext_button_available = true) { if (!window.ff_set) return; if(is_gotoNext_button_available) { document.getElementById('go-to-next-item')?.click(); forwarder(); } else { setTimeout(() => { document.querySelector('[data-purpose="go-to-next"].item-link.ud-heading-sm')?.click(); forwarder(); }, EXERCISE_LOAD_TIME); } } function getCurrentItem(){ const get_li = () => document.querySelector('li[class*="curriculum-item-link--is-current"]'); const fix1 = () => document.querySelector('div[data-purpose="curriculum-section-container"]')?.querySelectorAll('.ud-accordion-panel-toggler').forEach(x => x.click()); const fix2 = () => document.querySelector('button[class*="course-content-toggle"].ud-heading-md')?.click(); let li = get_li(); if(li) return li; /* else */ fix1(); li = get_li(); if(li) return li; /* else */ fix2(); li = get_li(); if(li) return li; /* else */ fix1(); li = get_li(); return li; } const currentItem = getCurrentItem(); const icon_element = currentItem.firstElementChild.lastElementChild.lastElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild; const icon_type = icon_element.getAttribute('xlink:href'); const current_element_is_completed = currentItem.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.checked; const current_element_is_an_exercise = !icon_type && icon_element?.nodeName.toUpperCase() == 'SPAN' if(current_element_is_completed || current_element_is_an_exercise) { goToNextItem(!current_element_is_an_exercise); return; } if(icon_type.endsWith('video')){ setTimeout(() => { if (!window.ff_set) return; let video = document.querySelector('video'); const video_time = "0:" + document.querySelector('span[data-purpose="duration"]').textContent; const last_second_of_the_video = video_time.split(":").slice(-3).map(Number).reverse().reduce((t, x, i) => t + x * Math.pow(60, i), 0); video.currentTime = last_second_of_the_video - (VIDEO_WATCH_TIME + 2000) / 1000; console.log('video-item forwarded at:', last_second_of_the_video + "s"); }, VIDEO_LOAD_TIME); setTimeout(goToNextItem, VIDEO_LOAD_TIME + VIDEO_WATCH_TIME); } else { -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ javascript:(function forwarder(toggle = false) { const ARTICLE_READ_TIME = 12000; function goToNextItem() { if (!window.ff_set) return; document.getElementById('go-to-next-item')?.click(); forwarder(); } @@ -43,6 +44,7 @@ javascript:(function forwarder(toggle = false) { const icon_type = currentItem.firstElementChild.lastElementChild.lastElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.getAttribute('xlink:href'); if(icon_type.endsWith('video')){ setTimeout(() => { if (!window.ff_set) return; let video = document.querySelector('video'); const video_time = "0:" + document.querySelector('span[data-purpose="duration"]').textContent; const last_second_of_the_video = video_time.split(":").slice(-3).map(Number).reverse().reduce((t, x, i) => t + x * Math.pow(60, i), 0); -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,16 @@ javascript:(function forwarder(toggle = false) { /* toggling the execution of this whole script */ if(toggle && 'ff_set' in window) { window.ff_set = !window.ff_set; if(window.ff_set) console.log("%c Forwarder script started running...", "color: green"); } else if(!('ff_set' in window)) { window.ff_set = true; console.log("%c Forwarder script started running...", "color: green"); } if(!window.ff_set) { if(toggle) console.log("%c Forwarder script stopped running!", "color: red"); return; } /* time to wait for the video to load before moving to the end of the video */ const VIDEO_LOAD_TIME = 9000; -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 49 additions and 49 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,56 +1,56 @@ javascript:(function forwarder(toggle = false) { // toggling the execution of this whole script if(toggle && 'ff_set' in window) { window.ff_set = !window.ff_set; if(!window.ff_set) { console.log("%c Forwarder script stopped running!", "color: red"); return; } console.log("%c Forwarder script started running...", "color: green"); } else if(!('ff_set' in window)) { window.ff_set = true; console.log("%c Forwarder script started running...", "color: green"); } /* time to wait for the video to load before moving to the end of the video */ const VIDEO_LOAD_TIME = 9000; /* watching time of the video before moving to the next item in the course */ const VIDEO_WATCH_TIME = 3000; /* reading time of the article before moving to the next item in the course */ const ARTICLE_READ_TIME = 12000; function goToNextItem() { document.getElementById('go-to-next-item')?.click(); forwarder(); } function getCurrentItem(){ let li = document.querySelector('li[class*="curriculum-item-link--is-current"]'); if(li) return li; /* else */ document.querySelector('div[data-purpose="curriculum-section-container"]')?.querySelectorAll('.ud-accordion-panel-toggler').forEach(x=>x.click()); li = document.querySelector('li[class*="curriculum-item-link--is-current"]'); return li; } const currentItem = getCurrentItem(); const current_element_is_completed = currentItem.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.checked; if(current_element_is_completed) { goToNextItem(); return; } const icon_type = currentItem.firstElementChild.lastElementChild.lastElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.getAttribute('xlink:href'); if(icon_type.endsWith('video')){ setTimeout(() => { let video = document.querySelector('video'); const video_time = "0:" + document.querySelector('span[data-purpose="duration"]').textContent; const last_second_of_the_video = video_time.split(":").slice(-3).map(Number).reverse().reduce((t, x, i) => t + x * Math.pow(60, i), 0); video.currentTime = last_second_of_the_video - (VIDEO_WATCH_TIME + 2000) / 1000; console.log('video forwarded! played at', last_second_of_the_video + "s"); }, VIDEO_LOAD_TIME); setTimeout(goToNextItem, VIDEO_LOAD_TIME + VIDEO_WATCH_TIME); } else { setTimeout(goToNextItem, ARTICLE_READ_TIME); } })(true); -
ahmedazhar05 revised this gist
Jul 19, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ javascript:(function forwarder(toggle = false) { // toggling the execution of this whole script if(toggle && 'ff_set' in window) { window.ff_set = !window.ff_set; -
ahmedazhar05 created this gist
Jul 19, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ (function forwarder(toggle = false) { // toggling the execution of this whole script if(toggle && 'ff_set' in window) { window.ff_set = !window.ff_set; if(!window.ff_set) { console.log("%c Forwarder script stopped running!", "color: red"); return; } console.log("%c Forwarder script started running...", "color: green"); } else if(!('ff_set' in window)) { window.ff_set = true; console.log("%c Forwarder script started running...", "color: green"); } /* time to wait for the video to load before moving to the end of the video */ const VIDEO_LOAD_TIME = 9000; /* watching time of the video before moving to the next item in the course */ const VIDEO_WATCH_TIME = 3000; /* reading time of the article before moving to the next item in the course */ const ARTICLE_READ_TIME = 12000; function goToNextItem() { document.getElementById('go-to-next-item')?.click(); forwarder(); } function getCurrentItem(){ let li = document.querySelector('li[class*="curriculum-item-link--is-current"]'); if(li) return li; /* else */ document.querySelector('div[data-purpose="curriculum-section-container"]')?.querySelectorAll('.ud-accordion-panel-toggler').forEach(x=>x.click()); li = document.querySelector('li[class*="curriculum-item-link--is-current"]'); return li; } const currentItem = getCurrentItem(); const current_element_is_completed = currentItem.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.checked; if(current_element_is_completed) { goToNextItem(); return; } const icon_type = currentItem.firstElementChild.lastElementChild.lastElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild.getAttribute('xlink:href'); if(icon_type.endsWith('video')){ setTimeout(() => { let video = document.querySelector('video'); const video_time = "0:" + document.querySelector('span[data-purpose="duration"]').textContent; const last_second_of_the_video = video_time.split(":").slice(-3).map(Number).reverse().reduce((t, x, i) => t + x * Math.pow(60, i), 0); video.currentTime = last_second_of_the_video - (VIDEO_WATCH_TIME + 2000) / 1000; console.log('video forwarded! played at', last_second_of_the_video + "s"); }, VIDEO_LOAD_TIME); setTimeout(goToNextItem, VIDEO_LOAD_TIME + VIDEO_WATCH_TIME); } else { setTimeout(goToNextItem, ARTICLE_READ_TIME); } })(true);