I know I can use MutationObserver for inline styles, but I'm wondering if there's a way to detect if an external class style has been changed with chrome's dev tools and what the change was. In this example changing the font color to that shade of green:
This is the best I was able to come up with. https://jsfiddle.net/cotssc7e/
var elem1 = document.getElementById("elemId");
var this_id = $('#elem-container').attr('id');
var style = window.getComputedStyle( document.getElementById(this_id), "")
function getTheStyle(){
var elem = document.getElementById("elem-container");
var theCSSprop = window.getComputedStyle(elem,null).getPropertyValue("color");
document.getElementById("output").innerHTML = theCSSprop;
}
setInterval(function() { getTheStyle() }, 1000)
I've used MutationObserver like this:
var MutationObserver = window.MutationObserver;
var target = document.querySelector('#page');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation);
});
});
var config = { attributes: true, childList: true, characterData: true, attributeOldValue: true, subtree:true, attributeOldValue:true, characterDataOldValue:true }
observer.observe(target, config);
But if you look at the original photo, MutationObserver won't detect a class style change from dev tools, because I suppose the DOM html doesn't change. I tried running MutationObserver on the css itself, but chrome doesn't literally change the css, they only change the computedStyle. And how and what changed is what I'm trying to figure out.