1

I am opening the chrome store in a fullscreen popup.

onclick="window.open('https://chrome.google.com/webstore/detail...', 'targetWindow', 'width=' + window.outerWidth + ',height=window.outerHeight,top=' + window.screenTop + ',left=' + window.screenLeft);

After the user has installed the extension, the focus comes back to the main tab and when my Chrome extension background script run the following code :

chrome.runtime.onInstalled.addListener(function (details) {
    if (details.reason == "install") {
      thankyou();
    }
  });

  function thankyou(){
    chrome.tabs.update({
        url: 'https://mythankyoupage.com',
        active: true
      });

  }

The problem is the Thankyou page is loaded in the main tab but NOT in the original popup, which is lost in the background.

How can I make sure the thank you page is loaded in the popup that was used to install from the chrome store ?

I have read https://developer.chrome.com/extensions/tabs but could not understand how to target my popup

Thank you for your guidance

UPDATE 1 :

following good advices from comments, I tried this : (I tried without "windowType":"popup" too)

  function thankyou(){
    chrome.tabs.query({url: "https://chrome.google.com/webstore/detail/...", "windowType":"popup"}, function(results) {
      chrome.tabs.update({ 
        url: 'https://thankyou.com'
       })
    }

tried this as well :

function(results) { chrome.tabs.update(tabs[0].id, { url: 'thankyou.com', active: true }) }

but all of them resulted in refreshing the main window and not the popup. I do uninstall each time the extension (not just refresh).

Jeremy
  • 31
  • 4
  • Super simple, send a message from background to popup in your thankyou function that tells popup to display the thankyou screen. – Tom Shaw Nov 10 '19 at 05:02
  • Use chrome.tabs.query({url: 'your-webstore-url'}, tabs => chrome.tabs.update(tabs[0].id, { your-update-params })) – wOxxOm Nov 10 '19 at 05:08
  • @TomShaw : could you point me to the direction on how to do that ? – Jeremy Nov 10 '19 at 05:41
  • Check out https://stackoverflow.com/questions/12265403/passing-message-from-background-js-to-popup-js @wOxxOm solution is also an excellent idea. The bottom line is popup needs to execute some code to display your thank you screen. – Tom Shaw Nov 10 '19 at 05:48
  • @wOxxOm That seems like a very interesting approach. I have tried this >chrome.tabs.query({url: "https://chrome.google.com/webstore/detail/...*"}, function(results) { chrome.tabs.update(tabs[0].id, { url: 'https://thankyou.com', active: true }) } But still result in the main window, not the tab, to be refreshed – Jeremy Nov 10 '19 at 05:52
  • @TomShaw The difference with the link you provided, which I had read, is my popup was not generated by my extension and I have no control on it since its hosted by the chrome store. But that may be just me lacking proper knowledge – Jeremy Nov 10 '19 at 05:56
  • Make sure you've reloaded the extension on chrome://extensions page after editing. I can't help further without seeing more of the new code ([MCVE](/help/mcve)). – wOxxOm Nov 10 '19 at 06:55

0 Answers0