Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:
- /* =============== Copy/paste all of this code as the content of a bookmark in your browser =============== */
- (function skipMSLearnModules(
- documentUrl = window.location.href.split("?")[0],
- innerDocument = document
- ) {
- /* Discard query string from URL as it was interfering with regex matching */
- const urlRegex =
- /https?:\/\/([^/]+)\/([^/]+\/)?(learn|training)\/(\w+)\/([\w-]+)\/([^/]*)/g;
- const allMatches = [...documentUrl.matchAll(urlRegex)];
- const [url, domain, locale, area, pathOrModule, module, unit] = [
- ...allMatches[0],
- ];
- if (pathOrModule == "paths") {
- const moduleLinks = innerDocument.querySelectorAll(
- 'a[data-linktype="relative-path"][class~="text-decoration-none"]'
- );
- moduleLinks.forEach((module) => window.open(module.href, "_blank"));
- } else if (pathOrModule == "modules") {
- if (!unit) {
- const iframeContainer = innerDocument.createElement("div");
- iframeContainer.style = `
- padding-top: 80vh;
- position: absolute;
- inset: 0;
- z-index: 1000;`;
- innerDocument.body.insertAdjacentElement("afterbegin", iframeContainer);
- const unitLinks = innerDocument.querySelectorAll(
- 'a[class~="unit-title"]'
- );
- unitLinks.forEach((unit) => {
- const iframe = innerDocument.createElement("iframe");
- iframe.src = unit.href;
- iframe.style = `
- outline: 2px dashed orangered;
- width: 90vw;
- height: 50vh;`;
- iframe.addEventListener("load", () => {
- setTimeout(() => {
- skipMSLearnModules(iframe.src, iframe.contentDocument);
- }, 500);
- });
- iframeContainer.insertAdjacentElement("beforeend", iframe);
- });
- } else {
- const radioButtons = innerDocument.querySelectorAll(
- 'input[type=radio][id*="quiz-choice-"][id$="-0"]'
- );
- radioButtons.forEach((radio) => {
- radio.checked = true;
- innerDocument
- .querySelector('button[data-bi-name="check-answers"]')
- .click();
- });
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment