Last active
August 5, 2017 19:56
-
-
Save pupi1985/937c28349b3f8513e1bda9a7b79cba7e to your computer and use it in GitHub Desktop.
youtube-refactoring.js
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
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