Search code examples
javascriptgoogle-chromegoogle-chrome-extensiongoogle-chrome-devtoolschromium

Chrome extension Content Script not working on gmail


I have been facing some serious issues here, i tried building a chrome extension for gmail, but neither my interface or the content script is not loading at all, I get to see this error whenever I inspect the popup console.

Unchecked runtime.lastError while running tabs.executeScript: 
This page cannot be scripted due to an ExtensionsSettings policy.
    at Object.callback (chrome-extension://hchilaodbnedmljenkfdfpjmgmlkmpci/js/popup.js:247:17)

enter image description here

Is the error related to my JSON file ?

I declared the content script as follow

{
  "name": "name",
  "version": "1.0",
  "description": "description",
  "permissions": [
    "activeTab",
    "tabs",
    "*://mail.google.com/*",
    "declarativeContent",
    "storage",
    "contentSettings"
  ],
  "background": {
    "scripts": ["js/send.js"],
    "persistent": false
  },
  "browser_action": {
    "default_popup": "index.html",
    "default_icon": {
      "16": "images/imagege1.png",
    }
  },
  "icons": {
    "16": "images/image1.png",
  },
  "web_accessible_resources": [
    "css/bootstrap.min.css",
    "js/jquery-3.3.1.slim.min.js",
    "js/popper.min.js",
    "js/bootstrap.min.js"
  ],
  "content_scripts": [{
    "matches": [
      "*://mail.google.co.in/*",
    ],
    "css": [
      "css/bootstrap.min.css"
    ],
    "js": [
      "js/jquery-3.3.1.slim.min.js",
      "js/bootstrap.js",
      "js/send.js",
      "js/bootstrap.min.js"
    ],
    "run_at": "document_end",
    "all_frames": true
  }],
  "manifest_version": 2
}

piece of JS code is here in case anyone needs it

enter image description here


Solution

  • The problem I faced was not even related to the content script, Im was within an organisation which network did not allow my extensions to be executed In the private gmail that we use, and that required a different token provided by the organisation itself which need to be used a a key in the manifest file.