Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

58
Script to Skip the Vector LMS Trainings
Post Body

I decided to finally complete the mandatory woke-corp trainings to get the registration hold off my account. I just spent 3 hours working on this script instead of watching the videos and now I want to share it with y'all if anyone still needs to complete those trainings.

Paste this into the developer console (F12) when you are on the Vector LMS course page (with the list of videos). If you leave the tab open in the background, it should do the rest of the work for you and complete all the videos one by one, without any wasted bandwidth or time.

Here's a video of it working (yes, it's sped up): https://streamable.com/03u2z7

//Vector LMS Auto Task Completion Script. Sequentially runs tracking_start and tracking_finish for each course_item (i.e. video) on the page.

function asyncWaitSeconds(seconds) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve();
    }, seconds * 1000);
  });
}
async function main(){
  let TOC_items = document.getElementsByClassName("TOC_item");

  let TOC_unwatched_videos = [];

  //scrape the /training/launch/course_work/COURSEID page for video data
  for (let i = 0; i < TOC_items.length; i  ){
    let data_entry = {}
    data_entry.element = TOC_items[i];
    data_entry.isVideo = TOC_items[i].querySelector(".fa-play") != null;
    data_entry.href = TOC_items[i].getAttribute("href");
    data_entry.title = TOC_items[i].querySelector(".lead").innerText;
    let len = TOC_items[i].getAttribute("href").split("?")[0].split("/").length;
    data_entry.work_id = TOC_items[i].getAttribute("href").split("?")[0].split("/")[len-1];
    data_entry.item_id = TOC_items[i].getAttribute("href").split("?")[0].split("/")[len-2];
    if(!data_entry.isVideo){
      continue;
    }
    data_entry.time_min = parseInt(TOC_items[i].querySelector(".span_link").innerText.split(" ")[1])   .5;
    data_entry.completed = false;
    TOC_unwatched_videos.push(data_entry);
  } 

  for (let i = 0; i < TOC_unwatched_videos.length; i  ){

    let unwatched_video = TOC_unwatched_videos[i];

    //request the tracking start
    let tracking_start_url = "https://calpolystudents-ca.safecolleges.com/rpc/v2/json/training/tracking_start?course_item_id="    unwatched_video.item_id "&course_work_id=" unwatched_video.work_id;
    const tracking_start_response = await fetch(tracking_start_url);
    let tracking_start_data = await tracking_start_response.json();
    unwatched_video.work_hist_id = tracking_start_data.course_work_hist_id;
    console.log("Video time tracking started for video: "   unwatched_video.title);

    //delay for video length
    console.log("Waiting for the length of the video, "   unwatched_video.time_min*60   " seconds...");
    await asyncWaitSeconds(unwatched_video.time_min*60);

    //request the tracking finish
    let tracking_finish_url = "https://calpolystudents-ca.safecolleges.com/rpc/v2/json/training/tracking_finish?course_work_hist_id="  unwatched_video.work_hist_id   "&_="  (Date.now()   unwatched_video.time_min*60*1000).toString();
    const tracking_finish_response = await fetch(tracking_finish_url);
    let tracking_finish_data = await tracking_finish_response.json()
    unwatched_video.completed = !(tracking_finish_data.tracking_status); //0 is completed, 1 is not completed, 2 is previously completed (but we filtered those)

    if(unwatched_video.completed){
      console.log("Completed Video: "   unwatched_video.title);
      unwatched_video.element.querySelector(".IconSquare").innerHTML = '<div style="height: 33px; width: 33px" class="IconSquare u-border-radius-4 u-overflow-hidden u-pos-relative" aria-hidden="true"><span><div class="color-overlay u-bg-tertiary-light"></div></span><div class="u-absolute-center u-text-center "><span class="fa fa-check fa-fw u-color-tertiary"></span></div></div>'; //Set Completed Checkbox
      unwatched_video.element.querySelector(".hidden-xs").innerHTML = '<div class="badge u-text-capitalize u-border-radius-10 u-m-0 u-bg-tertiary-light u-color-tertiary-darker">Completed</div>'; //Set Completed Badge
    }
    else{
      console.log("Failed to Complete Video: "   unwatched_video.title);
    }
  }
}
main().then();

Here's the same script, but compressed into one line for EZ pasting:

function asyncWaitSeconds(i){return new Promise((e,t)=>{setTimeout(()=>{e()},1e3*i)})}async function main(){let i=document.getElementsByClassName("TOC_item"),o=[];for(let t=0;t<i.length;t  ){let e={};e.element=i[t],e.isVideo=null!=i[t].querySelector(".fa-play"),e.href=i[t].getAttribute("href"),e.title=i[t].querySelector(".lead").innerText;var r=i[t].getAttribute("href").split("?")[0].split("/").length;e.work_id=i[t].getAttribute("href").split("?")[0].split("/")[r-1],e.item_id=i[t].getAttribute("href").split("?")[0].split("/")[r-2],e.isVideo&&(e.time_min=parseInt(i[t].querySelector(".span_link").innerText.split(" ")[1]) .5,e.completed=!1,o.push(e))}for(let t=0;t<o.length;t  ){let e=o[t];var s="https://calpolystudents-ca.safecolleges.com/rpc/v2/json/training/tracking_start?course_item_id=" e.item_id "&course_work_id=" e.work_id;const n=await fetch(s);s=await n.json();e.work_hist_id=s.course_work_hist_id,console.log("Video time tracking started for video: " e.title),console.log("Waiting for the length of the video, " 60*e.time_min " seconds..."),await asyncWaitSeconds(60*e.time_min);s="https://calpolystudents-ca.safecolleges.com/rpc/v2/json/training/tracking_finish?course_work_hist_id=" e.work_hist_id "&_=" (Date.now() 60*e.time_min*1e3).toString();const l=await fetch(s);s=await l.json();e.completed=!s.tracking_status,e.completed?(console.log("Completed Video: " e.title),e.element.querySelector(".IconSquare").innerHTML='<div style="height: 33px; width: 33px" class="IconSquare u-border-radius-4 u-overflow-hidden u-pos-relative" aria-hidden="true"><span><div class="color-overlay u-bg-tertiary-light"></div></span><div class="u-absolute-center u-text-center "><span class="fa fa-check fa-fw u-color-tertiary"></span></div></div>',e.element.querySelector(".hidden-xs").innerHTML='<div class="badge u-text-capitalize u-border-radius-10 u-m-0 u-bg-tertiary-light u-color-tertiary-darker">Completed</div>'):console.log("Failed to Complete Video: " e.title)}}main().then();

Author
Account Strength
20%
Account Age
2 years
Verified Email
No
Verified Flair
No
Total Karma
390
Link Karma
92
Comment Karma
109
Profile updated: 16 hours ago
Elec. Eng. - 2023

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago