I have a <script>
that generates a both <style>
and inline style attributes with !important
tags. I'd like to remove all this styling.
My plan was to use a javascript onload
callback (and some jQuery) to remove the <style>
block and all inline style attributes — but I can't seem to select any of these elements. Here's what I've been toying with:
var script = document.createElement("script");
script.src = "//script.path.js";
script.onload = function(){
$(this).parent().find("style").remove();
$(this).parent().find("[style]").removeAttr("style");
};
$(target).append(script);
UPDATE
It seems that the elements generated by the <script>
just aren't available in the DOM right away. If I use setInterval
to check if the elements exist first, I can get this to work. I imagine there's a better way to do this though...