Last active
August 5, 2017 19:56
Star
You must be signed in to star a gist
youtube-refactoring.js
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
document.addEventListener("readystatechange", function (event) { | |
// Unable to use jQuery here | |
if (document.readyState == "complete") { | |
var page = document.getElementById("page"); | |
if (!page) { | |
return; | |
} | |
var performChanges = () => { | |
var videoTitleSpan = document.getElementById("eow-title"); | |
if (videoTitleSpan && !videoTitleSpan.innerText.startsWith("Refactored - ")) { | |
videoTitleSpan.innerText = "Refactored - " + videoTitleSpan.innerText; | |
} | |
}; | |
performChanges(); | |
var observer = new MutationObserver(mutations => | |
mutations.forEach(mutation => performChanges()) | |
); | |
var config = { | |
attributes: true, | |
attributeFilter: ["class"] | |
}; | |
observer.observe(page, config); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment