Simple LinkedIn Resume Generator (js)

LinkedIn recently disabled it’s third party APIs which took out an auto-resume builder service based on my public profile. I wrote some JS to try and at least generate a basic resume from my LinkedIn profile now:

From LinkedIn Profile -to- a simple clean resume! with just a little bit of effort! (done in Safari with print-to-PDF graphics enabled & headers disabled):

var s = 0, q = 0;
function y() {
  if (s < document.body.scrollHeight) {
    // scroll
    window.scrollBy(0, 125); s += 125;
    setTimeout(y, 0.125 * 1000);
  } else {
    if (q == 0) { q = 1; w(); }
    else { window.scrollTo(0, 0); }
  }
}

function w() {
  var s = 0, m = ["pv-profile-section__see-more-inline", "inline-show-more-text__button"];
  for (var j = 0; j < m.length; ++j) {
    var l = document.getElementsByClassName(m[j]);
    for (var i = 0; (i < l.length) && (s == 0); ++i) {
      try {
        // click
        var t = l[i].innerText; if (!t) { t = ""; }
        if (t.match(/^.*(see|show).*(more).*$/mi)) { l[i].click(); s = 1; }
        else if (t.match(/^.*(see|show).*(few|less)*$/mi)) { l[i].innerText = "x"; l[i].style.display = "none"; s = 1; }
        //console.log(i,t,l[i]);
      } catch(e) { /* no-op */ }
    }
  }
  if (s == 1) { setTimeout(w, 0.521 * 1000); } else { v(); z(); }
}

function v() {
  var u = (location.href.replace(/^.*\.com/, "") + "detail/contact-info/");
  var xttp = new XMLHttpRequest();
  xttp.onreadystatechange = function() {
    var r = this.responseText, l = []; if (r) { l = r.replace(/[ \t\r\n]/mig, " ").split(" "); }
    for (var i = 0; i < l.length; ++i) {
      // extra
      if (l[i] && l[i].match(/^.*emailaddr.*$/mig)) { pi(l[i]); }
    }
  }
  xttp.open("GET", u, true);
  xttp.send();
}

function pi(rr) {
  var p = "", q = "";
  var d = document.createElement("div");
  d.innerHTML = rr;
  var j = JSON.parse(d.innerText)["data"];
  console.log("ajax",j);
  p = j["emailAddress"];
  var l = j["websites"];
  for (var i = 0; l && (i < l.length); ++i) {
    if (q != "") { q += " | "; }
    q += l[i]["url"].replace(/^https?:../,"");
  }
  if (j["address"] && (j["address"].length > 0)) {
    if (q != "") { q += " | "; }
    q += j["address"];
  }
  if ((!p) || (!q)) { return ""; }
  var n = document.getElementsByClassName("pb2")[0];
  n.getElementsByTagName("a")[0].innerHTML = p;
  if (!document.getElementById("info")) {
    d = document.createElement("div");
    d.setAttribute("id", "info");
    d.setAttribute("class", "text-body-small");
    d.setAttribute("style", "font-family: monospace; padding-top: 5px;");
    d.innerHTML = q;
    n.parentNode.appendChild(d);
  }
}

function u() {
  // hide
  var l = [
    "msg-overlay", "global-nav", "global-footer", "scaffold-layout__aside", "artdeco-carousel__content", "artdeco-toasts",
    "pv-profile-sticky-header", "pv-top-card--photo", "pv-top-card__badge-wrap", "profile-topcard-background-image-edit__icon", "pv-open-to-carousel__navigation-button", "pv-text-details__right-panel",
    "pv-top-card--list", "pv-top-card-v2-ctas", "pv-entity__add-action", "pv-entity__edit-action", "pv-profile-section__header-add-action", "pv-profile-section__header-edit-action", "pv-profile-section__add-action", "pv-profile-section__edit-action"];
  for (var i in l) {
    var a = document.getElementById(l[i]);
    var b = document.getElementsByClassName(l[i]);
    try { a.setAttribute("style", "display: none !important;"); } catch(e) { /* no-op */ }
    for (var j in b) { try { b[j].setAttribute("style", "display: none !important;"); } catch(e) { /* no-op */ } }
  }

  // info
  var n = document.getElementsByClassName("pb2")[0];
  var h = n.innerHTML;
  var p = n.parentNode.children[0].children[1];
  p.innerHTML += ('<span class="pv-text-details__separator"></span>' + h);
  n.setAttribute("style", "display: none !important;");
  p.style.fontSize = "12px";
  var l = p.getElementsByTagName("*");
  for (var i = 0; i < l.length; ++i) { l[i].style.fontSize = "12px"; }
  n.parentNode.parentNode.parentNode.style.paddingBottom = "10px";
  document.getElementsByClassName("live-video-hero-image")[0].style.minHeight = "25px";
  document.getElementsByClassName("live-video-hero-image")[0].style.maxHeight = "25px";
}

function z() {
  // misc
  var l = ["profile-views", "pv-accomplishments-section", "pv-interests-section", "pv-recommendations-section", "pv-skill-categories-section", "pv-recent-activity-section-v2__headline"];
  for (var i = 0; i < l.length; ++i) {
    var p = document.getElementsByClassName(l[i]);
    if (p.length > 0) { p = p[0].parentNode; } else { p = null; }
    while (p) {
      if ((p.nodeName.toLowerCase() == "div") && p.id.startsWith("ember")) {
        if ((p.className == "ember-view") || p.className.includes("pv-deferred-area")) {
          p.style.display = "none"; break;
        }
      }
      p = p.parentNode;
    }
  }

  // high
  try {
    document.getElementsByClassName("authentication-outlet")[0].style.background = "white";
    document.getElementsByClassName("authentication-outlet")[0].style.paddingTop = "5px";
    document.getElementsByClassName("authentication-outlet")[0].style.paddingBottom = "256px";
    document.getElementsByClassName("live-video-hero-image")[0].style.width = "100.3%";
    document.getElementsByClassName("live-video-hero-image")[0].style.left = "-1px";
  } catch(e) { /* no-op */ }

  // wide
  try {
    document.getElementsByClassName("scaffold-layout__main")[0].style.width = "125%";
    document.getElementsByClassName("scaffold-layout__main")[0].style.background = "white";
    document.getElementsByClassName("scaffold-layout")[0].style.setProperty("--scaffold-layout-gutter", "0px");
    document.getElementsByClassName("scaffold-layout")[0].style.background = "white";
    document.getElementsByClassName("scaffold-layout-container")[0].style.margin = "0px";
    document.getElementsByClassName("scaffold-layout-container")[0].style.paddingLeft = "5px";
    document.getElementsByClassName("scaffold-layout-container")[0].style.background = "white";
  } catch(e) { /* no-op */ }

  // dots
  var l = document.getElementsByClassName("pv-entity__description");
  for (var i = 0; i < l.length; ++i) {
    var f = 1;
    while (f == 1) {
      f = 0;
      var h = l[i].innerHTML; if (!h) { h = ""; }
      h = h.replace(/\*/mig, "•")
      var m = h.match(/^(.*[^•])([•]+)([^&][^<]+)(.*)$/mi);
      if (m) {
        h = (m[1] + "<table style='display:inline;'><tr><td style='padding-left:"+(25*(m[2].length-1))+"px;white-space:nowrap;'><b style='font-size:16px;'>"+m[2][0]+"&nbsp;</b></td><td>" + m[3] + "</td></tr></table>" + m[4]);
        f = 1;
      }
      l[i].innerHTML = h;
    }
  }

  // imgs
  var l = document.getElementsByClassName("pv-entity__logo-img");
  for (var i = 0; i < l.length; ++i) {
    l[i].style.position = "relative"; l[i].style.transform = "none";
    l[i].style.top = "0px"; l[i].style.left = "0px";
  }

  // fixs
  var l = document.getElementsByClassName("pv-entity__extra-details");
  for (var i = 0; i < l.length; ++i) {
    l[i].style.paddingBottom = "25px";
    var p = l[i].parentNode;
    while (1) {
      //console.log(i,p);
      var m = p.classList.length;
      for (var j = 0; j < m; ++j) {
        p.classList.forEach(n => { if (!n.includes("pv-entity")) { p.classList.remove(n); } });
      }
      p.style.display = "block";
      p.style.padding = "0px"; p.style.margin = "0px";
      if (p.nodeName.toLowerCase() == "ul") {
        p.style.backgroundColor = "white";
      }
      if (p.nodeName.toLowerCase() == "section") {
        p.style.padding = "25px 25px 0px 5px";
        if (p.childNodes[0].nodeName.toLowerCase() == "header") {
          p.childNodes[0].style.padding = "0px 0px 25px 0px";
        }
        break;
      }
      p = p.parentNode;
    }
  }

  // find
  try {
    var l = document.getElementsByTagName("div");
    for (var i = 0; i < l.length; ++i) {
      var o = window.getComputedStyle(l[i], null).getPropertyValue("margin-left");
      var n = parseInt(o), s = "margin: 0px 0px 0px 65px !important;";
      if (n > 65) {
        console.log(l[i],n);
        l[i].setAttribute("style", s);
      }
    }
    var m = [document.getElementsByTagName("section"), document.getElementsByClassName("pv-profile-section__card-header")];
    for (var j = 0; j < m.length; ++j) {
      var l = m[j];
      for (var i = 0; i < l.length; ++i) {
        var o = window.getComputedStyle(l[i], null).getPropertyValue("padding-left");
        var n = parseInt(o), s = "padding: 25px 5px 5px 5px !important;";
        if (n > 15) {
          console.log(l[i],n);
          l[i].setAttribute("style", s);
        }
        if (j == 0) {
          var f = l[i], p = f.parentNode;
          while (p) {
            if (p.nodeName.toLowerCase() == "section") { f = p; }
            p = p.parentNode;
          }
          if (f != l[i]) { s = ""; }
          if (f.children.length < 1) { s = "display: none;"; }
          s += "box-shadow: 0px 0px 0px 0px !important;";
          s += "border-bottom: 1px solid rgba(0, 0, 0, 0.11) !important;";
          f.setAttribute("style", s);
        }
        if (l[i].innerHTML.match(/^.*cares about.*$/mig)) {
          l[i].style.display = "none";
        }
      }
    }
    document.getElementsByTagName("h1")[0].parentNode.parentNode.parentNode.parentNode.setAttribute("style", "padding-left: 5px !important;");
  } catch(e) { /* no-op */ }

  // font
  var m = ["inline-show-more-text", "pv-entity__description"];
  for (var j = 0; j < m.length; ++j) {
    var l = document.getElementsByClassName(m[j]);
    for (var i = 0; i < l.length; ++i) {
      l[i].style.fontSize = "10px"; l[i].style.paddingTop = "10px"; l[i].style.paddingBottom = "10px";
    }
  }
  var l = document.getElementsByTagName("h2");
  for (var i = 0; i < l.length; ++i) {
    l[i].setAttribute("style", "line-height: 0px !important;");
  }

  // fill
  var l = document.getElementsByClassName("pv-entity__description");
  for (var i = 0; i < l.length; ++i) {
    l[i].onclick = function() { this.innerHTML += "<br/> &nbsp; "; };
  }

  // mini
  var m = ["pv-entity__summary-info", "pv-entity__summary-info-v2"];
  for (var j = 0; j < m.length; ++j) {
    var l = document.getElementsByClassName(m[j]);
    for (var i = 0; i < l.length; ++i) {
      var n = l[i].getElementsByClassName("display-flex")[0];
      var h = l[i].children[l[i].children.length-1].innerHTML;
      if (!n) { console.log(j,i,l[i]); continue; }
      n.innerHTML += ('<h4 class="t-14 t-black--light t-normal"><span class="pv-entity__bullet-item-v2">' + h + '</span></h4>');
      l[i].children[l[i].children.length-1].setAttribute("style", "display: none !important;");
      var c = n.children;
      for (var k = 0; k < c.length; ++k) { c[k].style.fontSize = "10px"; }
      var k = (l[i].children.length - 3);
      while (k > 0) { l[i].children[k].style.fontSize = "12px"; --k; }
      l[i].children[0].style.fontSize = "14px";
    }
  }

  // end!
  setTimeout(u, 5 * 1000);
  window.scrollTo(0, 0);
  s = 0; y();
}

s = 0; y();

Simple LinkedIn Resume Generator (js)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s