- chrome extension toolbar button pressed
- opens popup which has button and when that button is pressed it injects a
content.js
file into the current page DOM - The
content.js
in the page build a DIV Modal window. In that modal is a button that when pressed sends a message to chrome extensionsbackground.js
file to tell it to build a full page screenshot image. - It then also hides the modal DIV from view on that page
display: none;
- Because it is a full page height screenshot, it has to send messages back and forth between the
content.js
andbackground.js
scripts with coordinates so that it will snap an image of the view port frame by frame to build a full height image. - When the image is done building, my
background.js
script opens a new fileedit.html
which is a custom page in my extension with a full image annotation library to edit the image. - From the
edit.html
file, when the image is done editing, it uses AJAX to upload the new image to my remote server using AJAX and returns the URL of the new image upload. - This is where I need to close the
edit.html
file/tab and send a message back to the original pagescontent.js
with the new image URL and also a message to tell it to un-hide the modal window on that page and insert the new image URL into a text input field in that modal window.
I have all this working up until the point where I need to:
- close the
edit.html
file/tab - at the same time, bring focus back to the original page tab we started on
- also send a message to that original pages
content.js
script which can include a message to show the modal window and include the image URL of the screenshot we built, edited, and then uploaded to remote server.
1)
Any help in how to close the edit.html tab and bring focus back to the original tab page?
I believe the edit.html page will have to send a message to the background.js
file to close itself and then that background.js file can also send a message to the original tabs content.js file and bring focus to it again. Just not sure how to do this part. Mainly knowing which tab was the original.