problem Injecting content script from a visible background page

1,240 views
Skip to first unread message

Chromelody

unread,
Nov 24, 2014, 2:45:32 AM11/24/14
to chromium-...@chromium.org
Please help

I want to make use of the UI (ie: button and textarea, etc..) on my background page. So I create a visible background from the hidden background page (hiddenbackground.html) using: chrome.tabs.create({url: chrome.extension.getURL('visiblebackground.html')});. But when try injecting content script in to a regular webpage using: chrome.tabs.executeScript(specTab.id, {file:  "script.js"});, Chrome complains saying: 

" Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "chrome-extension://omjklcnhgmbdjadleonimbbmimmilmhd/visiblebackground.html". Extension manifest must request permission to access this host.
    at Object.callback (chrome-extension://omjklcnhgmbdjadleonimbbmimmilmhd/visiblebackground.js:19:25)"

here is my manifest.json
{  "name"             : "retrieve info from optionPage and insert into a webpage",

   "version"          : "1.0",

   "description"      : "Step 2: copy text from option page to google Drawings",

   "manifest_version" : 2,

   "icons"            : { "64"  : "pp64.png"},
 
   "background"       : { "page"     :  "hiddenbackground.html"},
  
  "browser_action"   : { "default_title" : "option page to google Drawings",
 
    "default_icon"  : "pp64.png"},
   "permissions"      : ["background", "tabs", "http://*/*", "file://*/*", "https://*/*"]

}

if you need more detail my extension can be found in: https://github.com/peterhot/Injecting-content-script-from-visible-background-page
or please download the zip file attached
creating visible background page then injecting content script.zip

Wolf War

unread,
Nov 24, 2014, 4:42:59 PM11/24/14
to chromium-...@chromium.org
I think you need to add
"web_accessible_resources": ["'visiblebackground.html"]
to your manifest file

Peter Peter

unread,
Nov 24, 2014, 9:11:10 PM11/24/14
to Wolf War, chromium-...@chromium.org
Hi Wolf War! thanks for your suggestion.
Adding "web_accessible_resources": ["'visiblebackground.html"to manifest.json is still giving me the same error. What else can you suggest?

Thanks


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/15973799-8e10-46da-a551-c4f885972067%40chromium.org.

injecting content script from visible background page.zip

Wolf War

unread,
Nov 25, 2014, 5:26:06 AM11/25/14
to chromium-...@chromium.org, wolf...@gmail.com
I'm out of ideas...
but you should ask this question on StackOverflow
someone more experienced will help you, I'm sure
just post all your relevant code in question

Peter Peter

unread,
Nov 25, 2014, 5:43:38 AM11/25/14
to Wolf War, chromium-...@chromium.org
Thanks for your time.

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Peter Peter

unread,
Nov 26, 2014, 12:51:13 AM11/26/14
to Wolf War, chromium-...@chromium.org
HI WW,

I have a try on chrome.downloads.onDeterminingFilename.addListener() but didn't get any where. I am pretty new to chrome extension. I can't find much info on it on the net either. I will use the non-silent saving method you show me earlier and wait for some one/some day to post a simple example. 
Thanks

Алексей Ткаченко

unread,
Feb 28, 2018, 7:00:07 AM2/28/18
to Chromium-Extensions-Announce, wolf...@gmail.com
Any news? I have the same problem.

среда, 26 ноября 2014 г., 8:51:13 UTC+3 пользователь Chromelody написал:
HI WW,

I have a try on chrome.downloads.onDeterminingFilename.addListener() but didn't get any where. I am pretty new to chrome extension. I can't find much info on it on the net either. I will use the non-silent saving method you show me earlier and wait for some one/some day to post a simple example. 
Thanks

On Tue, Nov 25, 2014 at 9:43 PM, Peter Peter <gm.p...@gmail.com> wrote:
Thanks for your time.

On Tue, Nov 25, 2014 at 9:26 PM, Wolf War <wolf...@gmail.com> wrote:
I'm out of ideas...
but you should ask this question on StackOverflow
someone more experienced will help you, I'm sure
just post all your relevant code in question

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
Reply all
Reply to author
Forward
0 new messages