// ==UserScript== // @name Power+ Userscript Loader // @namespace https://powerplus.app/ // @version 1.2 // @description An alternate, customizable loader for Power+ (powerplus.app) // @author jottocraft // @license MIT // @icon https://powerplus.app/favicon.png // @grant none // @run-at document-start // @match https://*.instructure.com/* // @downloadURL none // ==/UserScript== (function () { 'use strict'; if ((window.location.pathname === "/power+/") || (window.location.pathname === "/power+")) { var s; //Check for light or dark theme var light = false; if (window.localStorage.fluidTheme == "light") { light = true; } else if (((window.localStorage.fluidTheme == "system") || (window.localStorage.fluidTheme == "auto")) && !window.matchMedia("(prefers-color-scheme: dark)").matches) { light = true; } //Replace canvas 404 page with Power+ const observer = new MutationObserver(mutations => { mutations.forEach(({ addedNodes }) => { addedNodes.forEach(node => { //Power+ preloader if (node.nodeType === 1 && node.tagName === 'BODY') { node.innerHTML = /*html*/`

`; } else if (node.nodeType === 1 && node.tagName === 'HEAD') { node.innerHTML = /*html*/` Power+ `; } else if (node.nodeType === 1 && node.tagName === 'SCRIPT' && (node.textContent && node.textContent.includes('"current_user"'))) { //Do nothing for node containing enviornment data for faster load times } else if (node.nodeType === 1 && node.getAttribute("dtps") != "true") { //Node is not added by dtps node.remove(); } }) }) }) //Start MutationObserver observer.observe(document.documentElement, { childList: true, subtree: true }); //Get Power+ base URL var baseURL = "https://powerplus.app"; if (window.localStorage.dtpsLoaderPref === "local") { baseURL = "http://localhost:2750"; } //Set DTPS loader parameters s = document.createElement("script"); s.textContent = "window.dtpsPreLoader = true;window.dtpsBaseURL = '" + baseURL + "'"; s.async = false; s.setAttribute("dtps", "true"); document.documentElement.appendChild(s); //Load jQuery s = document.createElement("script"); s.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"; s.async = false; s.setAttribute("dtps", "true"); document.documentElement.appendChild(s); //Wait for page to load window.onload = function () { //Stop observer observer.disconnect(); //Determine LMS script to load var lmsScript = null; if (window.location.hostname.startsWith("dtechhs")) { lmsScript = "dtech"; } else { lmsScript = "canvas"; } //Check for debugging LMS overrides if (window.localStorage.dtpsLMSOverride) lmsScript = window.localStorage.dtpsLMSOverride; //Add script to DOM s = document.createElement("script"); s.src = baseURL + "/scripts/lms/" + lmsScript + ".js"; s.async = false; s.setAttribute("dtps", "true"); document.documentElement.appendChild(s); s.onerror = function () { //Couldn't load debugging script, fallback to production if (window.localStorage.dtpsLoaderPref && (window.localStorage.dtpsLoaderPref !== "prod")) { console.log("[DTPS CHROME] Failed to load debugging script. Falling back to production."); window.localStorage.dtpsLoaderPref = "prod"; window.location.reload(); } else { document.getElementById("dtpsLoadingScreenBar").style.animationPlayState = "paused"; document.getElementById("dtpsLoadingScreenStatus").innerText = "Could not load Power+. Please try again later."; } }; } } else { var releaseType = null; if (window.localStorage.dtpsLoaderPref == "local") releaseType = "Power+ (local)"; const observer = new MutationObserver(mutations => { mutations.forEach(({ addedNodes }) => { addedNodes.forEach(node => { //Power+ button if (node.nodeType === 1 && node.id == "menu") { node.insertAdjacentHTML("beforeend", /*html*/` `); } }) }) }) // Starts the monitoring observer.observe(document.documentElement, { childList: true, subtree: true }) } })();