I know about chrome extensions and I built one.
As far as I know, popup can only be opened from the button action (page action too) and will be closed once they lose focus (i.e. if users clicks somewhere on the webpage).
But how did this extension - barc manage to
1) open from bottom
2) refrain from closing even after losing focus
I looked at my chrome://flags/#enable-panels and found panels to be disabled. So, this ain't the cause.
I'll be happy if some one can point me to the underpinnings of this implementation or API?
It's injecting custom UI into pages via content scripts, not showing it in a panel.
You can test it by minimizing/moving the Chrome window.
Related
I'm developing a Firefox extension and I've been looking for a way to display it automatically (with JavaScript) under certain conditions, as if the user had clicked on the icon.
I know it is possible because some extensions already do it (like Wanteeed, see image below)
I have my javascript getting all the informations that I want, I know when my condition is okay the only thing that I need now is a way to make my little extension's 'popup' magically appear
I've looked for answers as I could, I hope that I didn't miss an already existing post, sorry if I did and thank you very much for your answers !
Are you using the latest WebExtensions format? If so, then you can't just open the popup page programmatically, this is for security reasons. From the MDN web docs:
When the user clicks the button, the popup is shown. When the user clicks anywhere outside the popup, the popup is closed. The popup can be closed programmatically by calling window.close() from a script running in the popup. However, you can't open the popup programmatically from an extension's JavaScript: it can only be opened in response to a user action.
An alternative is to use content scripts to append a position:fixed div to the current page, and then to style it with CSS to match the popup style. This is probably what the extension you referenced is doing.
Is there anyway to prevent changes to web pages such as a live chat or a video feed? Im guessing its a javascript that times out the webpage and then exits it or prevents further entry.
I saw this question: Freeze screen in chrome debugger / DevTools panel for popover inspection?
What I did was I inspected the element, then went to the line of code and then clicked on :hover but the script still executed and locked me out. Any other ways you can think of to prevent changes being made to a page?
Chrome allows you to disable JavaScript on certain pages, to do so click on the globe of the URL bar and it will show some permission options for the site you are. There disable JavaScript.
How to deliberately freeze javascript in chrome (plugin/console)
Found another solution in the link above:
Open Chrome javascript console
Go to "sources"
On the right side, click the little "pause" icon, or press F8 to pause script execution.
Hi I have set up a task in my task scheduler to login to my UTM by opening a firefox window at regular intervals. When the relevant URL is loaded a auto-login GM script works on it and logs me in to UTM.
I would like to close that tab after the login is done. If I use
window.close();
It works fine but if no other tab is opened at the time, it simply closes the window.
Without going into details of UTM I would like the following -
A GM hack which closes the tab only if other tabs are already open. If it is the last tab of the window, then it should just replace it with a blank tab (so that window is not closed).
Probably GM cannot obtain any info about the other tabs, but is there any hack ?
As far as I'm aware this isn't possible, if nothing else then for security reasons: you don't spam javascript from your video streaming tab collecting all your data and submitting forms on your behalf.
Here's a thread with a solution that worked for IE7 that you may be able to manipulate but as I said it's not likely.
If you decide to have ago, don't think about identifying the number of tabs, it won't happen, instead focus on determining whether or not there are multiple tabs.
The linked example uses if(clientY == 0) to determine whether or not the browser is closing. This would be a good starting point.
Again, for security reasons, you won't be able to find out information about open tabs.
I'm developing a Google Chrome extension with a popup (it's a browser action), and it changes the location of the page, which makes the popup disappear. How can I make it stay between page reloads?
You can't. browserAction popups are closed on any activity outside of the popup. You could potentially use Desktop Notifications though.
You'll need to use Background Page, and pull information from it every time you load the popup. Background pages run whether or your extension is currently being used or not.
Not sure if this helps, but from the FAQ:
Can extensions keep popups open after the user clicks away from them?
No, popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.
I had to implement a workaround for this as well. In my case, I was trying to use auth0's loginWithPopup. When the popup closed, it returned focus to the chrome window instead of the extension which caused the extension to close before authorization fully completed. I worked around it by opening a new window which acts as a barrier of sorts to prevent chrome's focus from going back to the window the extension was opened from. Anyway, just wanted to put it out there in case it helps someone in the future.
We'd like to have a message popup when a visitor to specific webpages leave those webpages. So we could tie some Javascript to the links on those webpages, but then we can't control if the user exited the webpage by typing in a URL, using a bookmark or just closing the window...
I assume we have limited options if the user tries closing the browser window... but I do know it's possible because Google Docs' Documents offers the chance to cancel closing the window if you have unsaved work while closing the browser.
What are my options? Can I have Javascript called upon going to another webpage? Can I control the text in the popup when trying to close the window?
I'm using jQuery, so if there are good solutions implemented with jQuery that's perfectly fine.
Yes.
https://developer.mozilla.org/en/DOM/window.onbeforeunload
jQuery UI Dialog OnBeforeUnload
There is onunload event you can bind to, first example:
http://www.codetoad.com/javascript/miscellaneous/onunload_event.asp