Created
August 26, 2021 09:50
-
-
Save daniele-rapagnani/506a579fd79f503cb86cc652ca56141c to your computer and use it in GitHub Desktop.
Greasemonkey script to hide group ratings on 1001albumsgenerator.com to avoid being influenced if you didn't vote yet
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 Hide Ratings on 1001albumsgenerator | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Hides group ratings on 1001 albums generator to avoid being influenced if you didn't vote yet | |
// @author Daniele Rapagnani | |
// @match https://1001albumsgenerator.com/groups* | |
// @icon https://1001albumsgenerator.com/images/favicon.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
var newBtn = document.createElement("div"); | |
newBtn.setAttribute("class", "btn btn-primary mb-3"); | |
newBtn.hiddenRatings = false; | |
function showRatings() { | |
document.querySelectorAll("#group-stats--listened-albums--rating").forEach((n) => { n.style.display = 'block'; }); | |
document.querySelectorAll(".group-stats__listened-albums__rating--placeholder").forEach((n) => n.parentElement.removeChild(n)); | |
newBtn.hiddenRatings = false; | |
newBtn.textContent = "Hide Ratings"; | |
} | |
function hideRatings() { | |
document.querySelectorAll("#group-stats--listened-albums--rating").forEach((n) => { | |
n.style.display = 'none'; | |
var ph = document.createElement("div"); | |
ph.textContent = "*"; | |
ph.setAttribute("class", "group-stats__listened-albums__rating--placeholder"); | |
n.parentElement.insertBefore(ph, n); | |
}); | |
newBtn.hiddenRatings = true; | |
newBtn.textContent = "Show Ratings"; | |
} | |
function toggleRatings() { | |
if (newBtn.hiddenRatings) { | |
showRatings(); | |
} else { | |
hideRatings(); | |
} | |
} | |
hideRatings(); | |
newBtn.addEventListener("click", function() { toggleRatings() }); | |
var gci = document.querySelector("#group-chat-inactive"); | |
gci.parentElement.insertBefore(newBtn, gci); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment