Skip to content

Instantly share code, notes, and snippets.

@lrakai
Created March 24, 2022 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrakai/5c4c6a6288861555c71db9b274851aad to your computer and use it in GitHub Desktop.
Save lrakai/5c4c6a6288861555c71db9b274851aad to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Lab SEO
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Displays the SEO description
// @author Andrew Burchill
// @grant none
// @match https://*.cloudacademy.com/*
// @run-at document-start
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
(function() {
'use strict';
const page_title_selector = "#lab-page-title";
const admin_link_selector = "#admin-link";
waitForKeyElements(page_title_selector, labSeo);
waitForKeyElements(admin_link_selector, labSeo);
function labSeo() {
const pathElements = window.location.pathname.split('/').filter(e => e);
const view = pathElements.length > 2 ? "labstep" : "lab";
if (view == "lab") {
let nodes = document.querySelectorAll('meta[Name="description"]');
console.log(nodes);
var seo = "No SEO";
if (nodes.length > 0) {
for (var node of nodes) {
//console.log(node.getAttribute("content"));
var content = node.getAttribute("content");
if (content == "Accelerate progress up the cloud curve with Cloud Academy's digital training solutions. Build a culture of cloud with technology and guided learning experiences.") {
continue;
}
seo = content;
}
const title_element = document.querySelector(page_title_selector);
if (title_element) {
title_element.insertAdjacentHTML('beforeend', '<h6>' + seo + "</h6>");
}
}
}
}
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment