Last active
August 27, 2018 21:51
-
-
Save cuylerstuwe/762a83bdb42d0839ad6ea6e2af47f354 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 Simple Udemy Higher Standards Button | |
| // @namespace Cuyler Stuwe (salembeats) | |
| // @version 1.5 | |
| // @description Assume we want only 4+ star courses (since others' standards for reviews are too low), and take the decimal to give a X/10 rating. (i.e., a 4.4/5 course becomes a 4/10 course). | |
| // @author Cuyler Stuwe (salembeats) | |
| // @include https://www.udemy.com/* | |
| // @exclude https://www.udemy.com/*/learn/v4/content | |
| // @grant unsafeWindow | |
| // ==/UserScript== | |
| unsafeWindow.applyHigherStandards = function() { | |
| document.querySelectorAll("[class*='star-rating--reviews__stats']:not(.better-stats)") | |
| .forEach(el => { | |
| el.classList.add("better-stats"); | |
| const ratingFloor = +(el.innerText.match(/(\d)\./) || {"0": 0})[0]; | |
| el.innerText = ratingFloor < 4 ? "TRASH" : el.innerText.replace(/\d\.*/, "").trim().replace(/(\d)/, "$1/10"); | |
| const score = el.innerText[0]; | |
| let color; | |
| if(score <= 3 || ratingFloor < 4) { | |
| color = "red"; | |
| } | |
| else if(score <= 6) { | |
| color = "orange"; | |
| } | |
| else { | |
| color = "green"; | |
| } | |
| el.style.color = color; | |
| el.style.fontSize = '1.2rem'; | |
| }); | |
| document.querySelectorAll("[data-purpose=star-rating-shell]").forEach(starRatingContainer => { | |
| starRatingContainer.style.display = "none"; | |
| }); | |
| } | |
| function main() { | |
| document.body.insertAdjacentHTML("afterbegin", ` | |
| <button onClick="applyHigherStandards()">Apply Higher Standards (4+ Stars Only, X/10)</button> | |
| `); | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment