Skip to content

Instantly share code, notes, and snippets.

@wdlb
Last active Nov 15, 2018
Embed
What would you like to do?
Tapermonkey script to modify the styling of the Mixcloud website website
// ==UserScript==
// @name Mixcloud Ring Reset
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Ward Delabastita
// @match *://www.mixcloud.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// https://davidwalsh.name/javascript-debounce-function
function debounce(func, wait, immediate) {
var timeout
return function() {
var context = this, args = arguments
var later = function() {
timeout = null
if (!immediate) func.apply(context, args)
};
var callNow = immediate && !timeout
clearTimeout(timeout)
timeout = setTimeout(later, wait)
if (callNow) func.apply(context, args)
}
}
function resetRingColors() {
const listenedRings = document.getElementsByClassName("ring-listened");
Array.from(listenedRings).forEach((ringElement) => {
ringElement.style.stroke = ""
})
console.log("resetRingColors")
}
resetRingColors()
const efficientResetRingColors = debounce(resetRingColors, 250)
window.addEventListener("scroll", efficientResetRingColors)
})
();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment