google chrome extension - Javascript: How to check if a style is already injected -
in chrome plugin, through background script, inject style way:
if(!styleleft){ var styleleft = document.createelement("style"); document.head.appendchild(styleleft); styleleft.innerhtml = "a, .left-hand { cursor: wait; }"; }
but if doesn't work when style tag in page. how can specific style?
thanks.
check id. example:
if ( !!document.getelementbyid( 'a-long-id-that-will-never-collide' ) ) { var styleleft = document.createelement("style"); // set id can check later styleleft.id = 'a-long-id-that-will-never-collide'; document.head.appendchild(styleleft); styleleft.innerhtml = "a, .left-hand { cursor: wait; }"; }
Comments
Post a Comment