Skip to content

Instantly share code, notes, and snippets.

@pupi1985
Last active August 5, 2017 19:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pupi1985/937c28349b3f8513e1bda9a7b79cba7e to your computer and use it in GitHub Desktop.
youtube-refactoring.js
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