Button to add boot.dev certificate to linkedin

Adds a button to add your boot.dev certificate to linkedin

As of 2024-01-08. See the latest version.

// ==UserScript==
// @name        Button to add boot.dev certificate to linkedin
// @namespace   https://github.com/luigiMinardi
// @match       https://www.boot.dev/certificate/*
// @grant       none
// @version     0.6.9
// @author      luigiMinardi
// @license     MIT
// @description Adds a button to add your boot.dev certificate to linkedin
// @homepageURL https://gist.github.com/luigiMinardi/62b0492d187e39e495272b10d40f6aee
// @supportURL  https://gist.github.com/luigiMinardi/62b0492d187e39e495272b10d40f6aee
// ==/UserScript==


var mybutt = document.createElement("button");
// Copying boot.dev button style
mybutt.className = "active-scale-103 group relative block origin-bottom overflow-hidden rounded px-4 py-2 text-white shadow-md focus:outline-none disabled:scale-100 disabled:cursor-not-allowed bg-gradient-gray min-h-41 mt-8";
mybutt.style.cursor = "pointer";

// Button text
mybutt.textContent = 'Add to LinkedIn';

// Adjusting position
mybutt.style.position = "absolute";
mybutt.style.left = "3rem";
mybutt.style.top = ".25rem";

mybutt.onclick = async function () {
  // Current boot.dev url info
  let currUrl = location.href;
  let currUrlArray = currUrl.split("/");
  let username = currUrlArray.at(-2);
  let course = currUrlArray.at(-1);

  // Getting data from the course you did
  let getCoursesData = await fetch(`https://api.boot.dev/v1/users/public/${username}/tracks_and_courses`, {
    method: "GET",
  }).then((value) => {
    return value;
  });

  let coursesJson = await getCoursesData.json();

  let currCourse;
  for (const c of coursesJson["Courses"]) {
    if (c["UUID"] == course) {
      currCourse = c;
    }
  }

  // Creating variables with your course data
  let completionDate = currCourse["CompletedAt"].split("-");
  let comp_yr = completionDate[0];
  let comp_mth = completionDate[1];
  let title = currCourse["Title"];
  let bootdev = "40661112";

  // Open linkedin with the data pre-written
  window.open(`https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&name=${title}&organizationId=${bootdev}&issueYear=${comp_yr}&issueMonth=${comp_mth}&certUrl=${currUrl}&certId=${course}`, '_blank');
};


var nuxt = document.getElementById("__nuxt");
// Adding button to screen
nuxt.appendChild(mybutt);