0

I'm playing around with chrome extensions. I've made a simple extension that deletes all the body content, just for learning purpose.

Works fine with almost all sites (facebook, yahoo, google) but somehow is not working here https://login.live.com/

This is my code:

manifest.json

{
  "name": "test",
  "description": "test",
  "version": "0.1",
  "manifest_version": 2,
  "permissions": [
    "storage"
  ],  
  "content_scripts": [{
    "matches": ["<all_urls>"],
    "js": ["content_script.js"],   
    "run_at": "document_end"
  }]  
}

content_script.js

document.body.innerHTML = '';

Why the extension is not effective on that page? I'm missing something about chrome extensions or Microsoft implements some security measures?

nulll
  • 1,465
  • 1
  • 17
  • 28

1 Answers1

1

DOM can be added after your document_end-timed script executes.

Quoting Chrome docs:

In the case of "document_end", the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded.

So it is possible that your script executes before page's own $(document).ready(...) or equivalent, that still adds some content.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • I think you are wrong as far as I understood, document_end and domready event are equivalent http://stackoverflow.com/questions/5113318/in-a-chrome-extension-content-script-must-i-wait-for-document-ready-before-proc – nulll Jun 01 '14 at 13:13
  • In any case, there's still an `onload` event that fires after all that. – Xan Jun 01 '14 at 13:21