Created
March 24, 2022 15:35
-
-
Save lrakai/5c4c6a6288861555c71db9b274851aad to your computer and use it in GitHub Desktop.
This file contains 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 characters
// ==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