Created
November 14, 2024 01:22
-
-
Save BoLaMN/6b222f1a7b6b2acf3f0312d4311d1ee2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 pluralsight | |
// @namespace http://tampermonkey.net/ | |
// @version 0.3 | |
// @description try to take over the world! | |
// @author You | |
// @match *://app.pluralsight.com/* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
const listeners = []; | |
const check = () => { | |
for (let listener of listeners) { | |
const elements = document.querySelectorAll(listener.selector); | |
for (let element of elements) { | |
if (!element.ready) { | |
element.ready = true; | |
listener.fn.call(element, element); | |
} | |
} | |
} | |
} | |
const observer = new MutationObserver(check); | |
observer.observe(document.documentElement, { | |
childList: true, | |
subtree: true | |
}) | |
const watch = (selector, fn) => { | |
listeners.push({ selector, fn }) | |
check(); | |
return () => { | |
const idx = listeners.findIndex(listener => listener.selector === selector); | |
if (idx > -1) { listeners.splice(idx, 1) } | |
}; | |
}; | |
watch('button', (element) => { | |
if (/Start module \d+/.test(element.textContent)) { | |
element.click() | |
} | |
if (element.getAttribute('aria-label') === "Next Lesson") { | |
element.click() | |
} | |
if (element.getAttribute('id') === "pendo-close-guide-78e241cc") { | |
element.click() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment