I have an Website which contains something like this:
<div class="yqCWmB">
<img referrerpolicy="unsafe-url" src="//www.golem.de/1903/sp_Vllz-744275_rc.jpg" style="position: fixed; top: 87px;">
</div>
where this "yqCWmB" in the class name is dynamically created.
When I use: GM_addStyle(".'yqCWmB' {visibility: hidden !important; }");
that element is hidden, but next time that class name is something like "zCNfYMo" and the element is not hidden anymore.
How can I search for that dynamic class name? I'm using this in an Greasemonkey Script.
That <img referrerpolicy="unsafe-url"
inside the DIV is always the same, maybe find somehow with that?
Thanks a lot!
You can use referrerpolicy
attribute along with its value to hide the div.
Working snippet:
$(document).find('img[referrerpolicy="unsafe-url"]').closest('div').hide();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="yqCWmB">
<img referrerpolicy="unsafe-url" src="//www.golem.de/1903/sp_Vllz-744275_rc.jpg" style="position: fixed; top: 87px;">
<p>Hey</p>
</div>
Output: