[Greasemonkey] kill an alert() popup from the script?

Mook mook.moz at gmail.com
Thu Mar 2 23:27:37 EST 2006


Can you use GM_setValue to set a flag to indicate whether the alert is
open, and just skip the alert() if it is set (doing so in the
setTimeout callback of course)?

To get fancier, possibly keep track of the time the alert is closed -
since alert() blocks, the statement after the alert should be after it
is closed.  While it's open, of course, this would just be Infinity. 
That way you could event do suppression if the last dialog of closed
within half a second of trying to open a new one, etc.

--
Mook

On 3/2/06, Vectorspace <vectorspace at ntlworld.com> wrote:
> window.focus() doesn't do enough - it only focuses the window if a
> Firefox window is active, and if the tab the script is running in is the
> active tab in its window. If a non-Firefox window is active, or if all
> Firefox windows are minimised, or if the script is not running in an
> active tab then nothing happens. I need to see something happen
> regardless of all that, which is why I was using alert() - it forces
> focus to that specific tab regardless of what window or tab is active,
> even if it is a non-Firefox one.
>
> Lenny Domnitser wrote:
> > On 3/2/06, Vectorspace <vectorspace at ntlworld.com> wrote:
> >
> >> My javascript isn't that good, but I think I understand... You're using
> >> open() to execute a set of javascript instructions, as if you typed them
> >> into the address bar (like a bookmarklet).
> >>
> >
> > Yes. That wrapper just executes the script as if it were a bookmarklet.
> >
> >
> >> I don't know what uneval() does
> >>
> >
> > It just produce the Javascript source as a string. For example,
> > uneval('foo') == '"foo"'
> >
> > I assumed that the alerts were coming from the web page. If only the
> > user script is producing the alerts, then you don't need that wrapper,
> > since you can just define a function in the Greasemonkey sandbox.
> >
> >
> >> The reason I use an alert popup is that it forces focus to the browser
> >> window and tab that spawned the alert, even if a non-Firefox window is
> >> active. And, if all browser windows are minimised, the taskbar icon for
> >> that window becomes highlighted. Will this still apply automatically, or
> >> will it be something I have to write? Because I don't know how to do that.
> >>
> >
> > If that is the only thing you need, you can skip alert or custom
> > functions and just use window.focus.
> > _______________________________________________
> > Greasemonkey mailing list
> > Greasemonkey at mozdev.org
> > http://mozdev.org/mailman/listinfo/greasemonkey
> >
> >
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


--
Mook
mook.moz at gmail


More information about the Greasemonkey mailing list