Chrome Extension : Retain modal window when page refreshes - javascript

In my chrome extension, I am using content script on a particular site. When a particular button is pressed, the page refreshes with new updates. Is there any way to show a Modal window or Popup, from the time the button is clicked till the page refreshes.

Modal window or popup: no
But you can use a chrome notification. It will show a customizable window which you can remember its id and take it down when the page refreshes. I do this for a popular extension i develop.

Related

How to trigger current browser tab to close via Remix.js?

I want to close current browser tab via button click.
I tried window.close, but for clear reason it didn't work, because, the page is SSR.

How to bring popup browser window to the front so its on top of all browser windows?

My application gives users a specific amount of time to pay for a service. We do this because we can only keep their reservation for X amount of time.
The time we give them should be sufficient, however if they are running out of time we notify them with a Bootstrap Modal as shown below:
However, as soon as the modal achieves focus by the user clicking on the button or anywhere on the modal window, the PayPal browser window moves behind the main window. See picture below.
Simple clicking anywhere on the black overlay will bring the Paypal browser window back. However, I was hoping that someone might have some idea on how to achieve this using the button click in the modal.
In other words, how can I bring the Paypal browser window back to the front by clicking on the 'Yes Please' button on the modal or the close event of the modal?
I have tried to simulate the clicking of the overlay element in code but it does not seem to work.
Here is the code of the page:
From what I have read because the PopUp browser window is being opened from an iframe and the content is from a different source I cannot access the popup for security reasons. So there is no way to move it to the front unless the user clicks the dark overlay or the link 'Click to Continue'

Can a Google Chrome Extension popup window remain open as a new window is opened on top of it and then closed?

I have a Google Chrome Extension that uses the Background.html and background.js files to show this popup window when the chrome extension icon in the tray menu is clicked on....
Inside my popup is a button to generate a screenshot image of the current tab URL and it then uploads the image to my server and fills in the text input with the URL of my image upload.
I am now wanting to add the capability to select a region on the webpage screen and generate a screenshot image cropped to be just the content inside the selected region like this image below shows the region selected on the page....
My roblem now is that I cannot simply have a button in my popup take me into region selection mode on the page. I could but it would close the popup window and I have researched and found out that you cannot programtically open the popup.
So once the popup would close, I would no longer be able to edit the record loaded in it before.
I am trying to come up with a new solution to achieve my desired result.
Idea 1
Move all the functionality that my current background popup has into a modal window displayed on the actual webpage.
This would be a big change as it would require a lot of message passing as the modal code would not have access to theextension API which is used to generate the screenshot and get all the tabs data.
I could then open a modal that looks like my popup in the image above when the extension icon is clicked on.
When the generate screenshot button is clicked it would then send a message to the background script to get the tab API and generate the screenshot and then send it back as a message to the content script in the page.
As for my new feature of selecting a region and creating image of that region. The modal would have a button to do that and on click would hide the modal window. Next it would let me make the selection which on edn would send a message to background again and generate a screenshot and crop it to the coordinates of my selection and return it back in a return message to the content script which would then show the hidden modal window and update the image inside to show the new image.
This is the hardest way bu the best I think.
Idea 2)
If it is possibble even, on a button click inside my current popup would then launch a new popup window of the current page and allow me to make my selection region and generate the image which on completion would close the popup window and send the result back to my extension popup.
I do not know if this would work because I am unsure if the extension popup would auto-close when I click the new popup window?
Does anyone know of other way to accomplish this or if my ideas would be practical?
You can look at Adblock Plus for inspiration.
They have a popup with "Block Element" button that switches to "now interact with the page" mode.
After the user clicks, they open follow-up UI injected into the page.
In any case, clicking outside the popup will make it lose focus, which closes it by design.
You could instruct the user to click your button again after they interact with the page, or you would need to inject some UI into the page itself.

Stop refresh when Pop up opens

In my asp.net application, page is refreshing specific time using Response.AddHeader("Refresh","30"), but if i open pop up(window.open) case also Page is refreshing then pop up closing. How to stop the refresh in parent page when Popup opens.
I tried with another code.Added below code in window,onload event.
setTimeout(function(){window.location.reload()},30000)
How to increase refresh time when we open popup(window.open).
Thanks.
The following code at the bottom of the page is what you need.
setTimeout(function(){window.location.reload()},30000)

How can I get number of child windows for a browser

I have one icon (say open) in home page. When I click on this icon one child window will be open and the icon in that home page is also changed to 'close icon'. When close this popup window the icon should be same as previous icon (i.e. open icon) in home page. It's working fine when I stay on the same page.
But when redirecting from home page to next page the entire page gets reloaded. And the default image (open icon) is displaying even if the popup window is opened.
Now my requirement is:
At the time of page redirection the image should be loaded based upon the popup window. i.e. if popup window is open it should display the close icon otherwise it display open icon.
If page is refreshed or redirecting to another page the reference of the popup window is removed. then how can I get the reference of that popup window in a redirecting page.
How to count the number of child windows for a browser
EDIT:
I have tried the following solutions:
I set cookie at the time of opening a popup window and reset that cookie whenever I have closed that popup window. But the problem is, at the time of page redirection if I close the popup window the cookie is not reset to it's previous value, because the page is still in processing.
same problem with the session variable also
Please help me.
Set a cookie or a session variable when you open and close. This way you can remember the state of your popup window during new requests
When you go from one page to the next, you lose the reference to the pop-up window. But the pop-up window doesn't lose its reference to the main window. window.opener will always point to the window that opened it, even when there's a page change. Use this fact to reestablish communication between the windows after a navigation event. You might need to use an interval function to probe the main window, as I don't think you can listen for an event.

Categories