chrome extension setPopup is not propagated immediately - javascript

I'm working on chrome extension and I want to have 2 pages one main popup and then on click on specific button I want to replace it with other one(some settings page) so far I managed to change it using
chrome.action.setPopup({ popup: "settings.html" })
but problem is in fact that it's not immediately propagated, I have to click on extension to close it and click again to open it to be able to see settings page, did I missed something or what is the preferred way in such case?

Related

Is it possible to inject a chrome extension popup into current webpage without using react?

I'm currently working on chrome extension and I'm dealing with a content injection problem.
In my extension when user clicks the button inside the popup, he has possibility to choose DIV from the webpage he's currently on and then he can return back to popup to choose options for that chosen DIV.
The problem is that I can't force the popup to be open when user clicks outside it (actually I can with open popup console, but it's not a solution here) and the popup.html is reloading every time extension is shown to user.
So I came up with an idea that I can inject a popup into an iframe in the webpage to have control over it's behaviour but I found similar solutions only connected with chrome extensions based on react. Is it possible without any framework?
Any help would be greatly appreciated.

Is there any event which will be fired when I click on a tab in google chrome?

I am developing an extension for google chrome. I want to find the URL of the current tab, whenever I click on any tab in chrome. If I have three tabs open "abc.com","xyz.com","mnc.com" and when I click on first tab, I want an event to be fired, where I can get the current URL("abc.com"), and when clicked on the second tab,I should get the URL as "xyz.com". Is there any way to achieve this?
I am new to Chrome extensions and any help is appreciated. Thanks in advance.
There is no event that would indicate that a tab was clicked if it does not change the active tab. I mean, if you were on tab 1, and click it again, it will not emit any event.
There are, however, some events in the tabs/windows APIs that can approximate what you want when the active tab changes.
Specifically, chrome.tabs.onActivated will alert you when the active tab changes (this includes opening a new tab that is focused).
You might also want to use chrome.windows.onFocusChanged to track switching to a window without changing the active tab.

How to execute an action when user clicks browser action and there is a popup (Chrome extension)

I'm trying to create a Chrome extension that features a browser action and a popup. I need to refresh the content I serve in the popup every time the user opens it, but since the on clicked event will not fire if a popup is assigned to the browser action, I don't know how to trigger the logic to refresh the content.
I'm trying to do this in the background page, but I understand that that might not be the best way. Does anybody have an idea of how to approach this?
Thanks for any help.
The popup is created from scratch every time the user opens it, so any javascript file you include using a <script> tag will be executed. You can include any logic you need there.

Chrome Extension: How to run Javascript on page load (without popup open)

I have a Chrome extension that does word substitutions on pages. Currently I have a popup that opens when I click on a browser action which lets the user control whether or not to perform the substitutions. I also have a background script running that sends a message to content scripts when a page refresh happens using a chrome.tabs.onUpdated event handler.
My problem is that when I refresh the page no substitutions are made unless the popup is open (which is only possible when I have the inspect elements panel open on the popup, because otherwise the popup closes when I refresh).
Has anybody had experience with this behavior before? What additional instrumentation should I add to diagnose the problem? Is there a different extension architecture/code arrangement I should be using?
Thanks in advance!
If you use localStorage on a given page you can probably store whether or not to substitute words. I think refreshing a page is similar to opening a new tab, so your script gets reinjected/reloaded rather than staying open and receiving an onupdate message.

JavaScript simulate physical click on a link to bypass pop blocker(Not Jquery)

I am opening a popup after main window load.
Problem:
When user actually click on link the popup opens without complaining anything.
But when I am using Javascript call to click on href, I am getting popup blocker.
I am suspecting that, browser identifies that, popup is opening without any actual operation by user and that's why it is blocking popup.
In herf, I am calling a javascript method to open the popup.
I searched all the questions regarding opening popup and simulating the click like this, these works fine to simulate the click but still getting popup blocker.
Is there any workaround to fool browser?
You can't fool the browser per-se in this scenario. You could however, launch a div as an overlay on the main window if that's an option.

Categories

Resources