JavaScript Chrome Extension API: chrome.tabs.captureVisibleTab on Background Page to Content Script chrome extension chrome ig story,chrome extension chromecast,chrome extension

My overall goal was to take a screenshot via the background page using:

http://developer.chrome.com/extensions/tabs.html#method-captureVisibleTab

and pass it to the content script so I can use the page's HTML DOM to analyze the screenshot and cut it up the way I would like.

However, I can't seem to pass the dataUrl back to the content script with Message Passing:

http://developer.chrome.com/extensions/messaging.html

I tried JSON.stringify() but to no avail.

This works perfectly fine:

background.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        sendResponse({imgSrc:'hello'});
    }
);

I switch the code to this and nothing gets through:

background.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        chrome.tabs.captureVisibleTab(
            null,
            {},
            function(dataUrl)
            {
                sendResponse({imgSrc:dataUrl});
            }
        )
    }
);

My only proof that the background page is actually taking a screenshot is that I can do

chrome.tabs.captureVisibleTab(null,{},function(dataUrl){console.log(dataUrl);});

and I see

"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAA....etc..."

logged in background.html, which is valid

My question is: How can I send this URL to the content script?

I would prefer not to do all the logic on the background page which can't control anything on the actual visible page.

Answer:1

I'm working on a terminal-like modal, using bootstrap's and I want to clear it when the user presses Ctrl+L like it does when he writes clear in it. But the problem is, when I press Ctrl+L, it focuses ...

I'm working on a terminal-like modal, using bootstrap's and I want to clear it when the user presses Ctrl+L like it does when he writes clear in it. But the problem is, when I press Ctrl+L, it focuses ...

  1. prevent focus with css
  2. prevent focus on click
  3. prevent focus on element
  4. prevent focus on input
  5. prevent focus on button
  6. prevent focus on readonly input
  7. prevent focus on tab
  8. prevent focus on element css
  9. prevent focus on div
  10. prevent focus on click css
  11. prevent focus on button click
  12. prevent focus on click input
  13. prevent focus on iframe
  14. prevent focus on click react
  15. prevent focus on click jquery
  16. prevent focus on mousedown
  17. prevent focus on hidden element
  18. prevent focus on input element
  19. prevent focus in html
  20. prevent on focus

I am trying to place an element, "inner", flush against the upper right hand corner of another div, "outer", using absolute positioning. The "inner" element is not a child of "outer". I therefore need ...

I am trying to place an element, "inner", flush against the upper right hand corner of another div, "outer", using absolute positioning. The "inner" element is not a child of "outer". I therefore need ...

  1. place element inside div
  2. jquery place element inside div
  3. javascript place element inside another
  4. jquery place element inside another

How do I create a image map with separate <select>? I need something like this: <img src="image.png" alt="Website map" usemap="#mapname" /> <map name="judete" id="judete"> <...

How do I create a image map with separate <select>? I need something like this: <img src="image.png" alt="Website map" usemap="#mapname" /> <map name="judete" id="judete"> <...

  1. image with select option
  2. change image with select option
  3. image select
  4. image select sticker instagram
  5. image select sticker instagram missing
  6. image select html
  7. image select bootstrap
  8. image select jquery
  9. image select css
  10. image select sticker instagram android
  11. image select instagram story
  12. image select box
  13. image select checkbox
  14. image select sticker
  15. image select js
  16. image select from gallery android
  17. image select react
  18. image select javascript
  19. image select dropdown
  20. image select underwood

Very simple example: var a = { id: 5 }; var b = { id: 6 }; var c = { id: 7 }; var arr = [a, b, c]; Now i have a function: function remove(startIndex) { // set objects to null from startIndex in ...

Very simple example: var a = { id: 5 }; var b = { id: 6 }; var c = { id: 7 }; var arr = [a, b, c]; Now i have a function: function remove(startIndex) { // set objects to null from startIndex in ...

  1. access via null object reference
  2. access vba is null object required