Sumit
Sumit

Reputation: 1669

Devtools audit shows unwanted/injected css rules

So, in trying to debug the performance of a webpage in Chrome devtools, I found that my page has lengthy css rules that I did not put there. I cant see the rules when I view the source. But chrome tells me that the rules are being executed. The rules are also obviously malicious,

things like .yahoo-sponsored to [onclick^="window.open('http://

My question is how to find out what is, I am presuming, injecting this into my DOM? I cant see anything when I view the source.

I am kind of at a loss as to how to proceed.

Thanks for any help.

Upvotes: 1

Views: 225

Answers (1)

Alexander Pavlov
Alexander Pavlov

Reputation: 32296

These are, most likely, injected by an extension similar to AdBlock, which injects an inline stylesheet with no textContent (which is rendered just as <style></style> in the DevTools) but rather dynamically adds required rules via the CSSOM API.

To avoid seeing these rules in the audit results, disable AdBlock or a similar extension, reload the page, and run the audits once again.

Upvotes: 2

Related Questions