Pergunta

This is very strange, but the chrome extension is loading the content files inside the iframes. I had a <all_urls> in the content script matches, and i switched it to "http://*/*", "https://*/*". It was very weird because it was still loading pages inside the iframes even thought the iframe's src does not fit that match.

I found a script to detect if an object was loaded into an iframe, and now the content script does nothing to affect google adchoices, or other ads, but notably jsfiddle doesnt work when my extension is on.

I would rather not post the code, so please tell me what code i need to post.

It seemed that the only time it worked is when the content script has some invalid code and didnt work at all.

Do all extensions do this? How would i fix it? What code could possibly be doing this?

Thank you so much in advance.

Manifest:

{
  "name": "NA",
  "version": "1.0.9",
  "manifest_version": 2,
  "description": "NA",
  "browser_action":{
    "default_icon": {
      "19": "img/icon19.png",
      "38": "img/icon38.png"
    },
    "default_popup":"popup.html"
  },
  "permissions": [
    "storage",
    "tabs",
    "contextMenus"
  ],
  "background":{
    "scripts":["background.js"]
  },
  "icons": {
    "16": "img/icon16.png",
    "48": "img/icon48.png",
    "128": "img/icon128.png"
  },
  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "js": ["scripts/jquery-for-content-only.js","scripts/content.js"],
      "run_at": "document_end",
      "all_frames": true
    }
  ]
}
Foi útil?

Solução

The Chrome Extension manifest file determines how and where your content script runs, not just in terms of URL pattern matching but also in terms of whether or not they apply to frames below the parent page:

From Google's "Content Scripts" documentation:

Name: all_frames

Type: boolean

Description:

Optional. Controls whether the content script runs in all frames of the matching page, or only the top frame.

Defaults to false, meaning that only the top frame is matched.

Since you have this property set to true, your script is running in iframes. Either set this property to false, or remove it, and the script should then only run in the parent page.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top