1

I want to inject JavaScript code with a chrome extension, within a frame that is inside an iframe and that inside another iframe.

Page
  |-- iframe 1
         |-- iframe2
                |-- frame (no iframe), where I want to inject code

This is possible? how?

Thanks!

  • I have not solved the problem – Asius Ice Sword Oct 29 '15 at 12:24
  • Well basically you'll simply need to repeat the injection a few times, see method 1 in [Building a Chrome Extension - Inject code in a page using a Content script](https://stackoverflow.com/q/9515704) – wOxxOm Oct 29 '15 at 12:32
  • Thank @wOxxOm, but I do not understand how to inject the code several times. I want to inject this code: `Date.prototype.getYear = function(){;return this.getFullYear();}` .... Can you give an example? – Asius Ice Sword Oct 29 '15 at 12:45
  • Oh yeah!! Thank @wOxxOm :D ... I've got to work, following the method indicated. – Asius Ice Sword Oct 29 '15 at 13:00
  • Oh yeah!! Thank @wOxxOm :D ... I've got to work, following the method indicated: `var s = document.createElement('script'); s.src = chrome.extension.getURL('script.js'); (document.head||document.documentElement).appendChild(s); s.onload = function() { var s2 = document.createElement('script'); s2.src = chrome.extension.getURL('script.js'); (document.head||document.documentElement).appendChild(s2); s2.onload = function() { var s3 = document.createElement('script'); s3.src = chrome.extension.getURL('script.js'); (document.head||document.documentElement).appendChild(s3); }; };` – Asius Ice Sword Oct 29 '15 at 13:06
  • stackoverflow will not let me add answers ... :( code will try to hang on another page – Asius Ice Sword Oct 29 '15 at 13:38
  • Here you can see the readable solution ;) [link](https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/AaMc5lZ7vHA/a4BBLysHCAAJ) – Asius Ice Sword Oct 29 '15 at 13:52

0 Answers0