Moving XUL window - javascript

I'm working on an app, which is based on Firefox and what I need to build is an in-app password manager. I'm planning to populate it once and hide it from view outside of the window frame, bringing it in-frame when it is needed. Now, I have read about the rules applied to moveTo, namely
"You can't move a window or tab that wasn’t created by window.open.
You can't move a window or tab when it’s in a window with more than one tab."
I was wondering if there are any exceptions to that rule? I have full access to chrome, so I was wondering if there's some more low-level way to achieve the moveTo form there?
Thanks a lot!

The restrictions of window.moveTo() don't apply to code running with system privileges. I just tried typing top.moveTo(-1000, 0) into the Error Console - it moved the window off-screen, something that unprivileged code isn't allowed to do. Still, opening the window off-screen is not possible as far as I know (you can however move it in a load event handler, when the window is still invisible). Also, the task manager still shows that window - it is possible to Alt-Tab to it, then press Alt-Space and choose "Move" from that system menu (that's on Windows).

Related

Electron: Drag tab into another open window

I am creating a electron application that looks similar to google chrome with multiple dynamic tabs for different pages. The application also supports multiple open windows. I want to be able to drag tabs between these windows. I already know how to send messages between my windows with the ipcRenderer but I am coming up against a few roadblocks:
1) I cannot drag an html element outside of a window. How can I drag the tab (or something that looks identical) outside of the window?
I've found a discussion on the atom forums where someone claimed they were able to achieve this, but do not elaborate on how. They claim "Native HTML5 Drag and Drop in combination with IPC messaging was the solution". Someone else links a GitHub example below, but the example has since been removed.
2) How do I detect when a tab is dragged onto another open window (Mouse released on other window)?
Again the discussion suggests I use IPC messaging to do this, but I have not found a way to get the id of the window you release the mouse on.
Edit:
I have found a solution to issue 1. The mentioned discussion was right and using default HTML5 dragging behavior was able to create the effect I wanted. Issue 2 still stumps me. I understand the concept of alerting all other open windows with an IPC message to prepare for an incoming drag but I am still unsure how to get the id of the window and the position you dragged to on it so you can send the tab information to the correct place.
I know this is a bit old. but instead of dragging a tab to a new window, what about a context menu on the tab with a [Send to window].
using React for example (not that you'd have to), you could JSON.stringify the data you've used to render the tab, send it to the child window, JSON.parse it and render it in a new tab on the child window.
Not quite the effect of dragging but the same end result.
For communication between windows:
https://medium.com/#kahlil/how-to-communicate-between-two-electron-windows-166fdbcdc469

Safest way to break Flash focus?

The gist: What's the best way to escape a Flash object's focus on a webpage?
Context:
I have a hotkey listener (an AutoHotKey script) running in my tray. If the script detects the command Alt+Shift+F6 while I am clicked into a Flash object on a webpage, it activates and sends key combinations to Flash to pull certain data logs. After this process completes, I want to call up a JavaScript file on that same browser tab that requests additional information from the user - basically, a tiny UI with additional text fields available in a third-party bug tracker. To do this, I want to send a javascript: command to the address bar using Ctrl+L and having AutoHotKey paste in the full call to the JS file.
A visualization of a possible environment:
The problem:
I need the user to be clicked INTO Flash in order to pull the data logs. However, I need the user to be clicked OUT of Flash for Ctrl+L to actually work - Flash appears to eat all keystrokes at the browser-level when one of its objects has focus.
A possible solution: The easiest way to go about this would be to simulate clicking on the stage, which borders my Flash object on every side. This should work, but I must assume the stupidest possible user. Such a user would somehow limit their current browser window to only be as big as the Flash object (if not smaller), click into it, and attempt to use the hotkey. In this case...I have no idea where I should click, because it could be outside the browser. Further, I don't believe I can assume that all browser address bars are similar amounts of pixels south from the top of the window.
Additional complicating factors:
I want this to work for the user's default browser. (IE, Chrome, Firefox, Safari are my big targets.)
AHK does not provide any native DOM or COM hooks to anything except IE.
Ctrl+Tab and Alt+Tab shenanigans do not appear to work. That can get me to other tabs/windows, but returning to the tab/window with the Flash object still causes Flash to 'eat' further keyboard input.
While I'd be open to using another scripting language than AHK if it could overcome this Flash focus hurdle, I do not know how to create a keylistener that sits in the users tray until activated by a hotkey.
I have no access to the Flash object's code, and it contains no logic to interpret a key combination as a way to break focus or launch a script.
Would it be possible to use WinMaximize to maximize the size of the window? If you do that it should be easier to set up the script to avoid clicking outside the browser.
Perhaps look at ControlFocus and/or ControlSend (using the "edit1" control in IE and FF -- unfortunately, Chrome doesn't expose the "address bar" as a "control" this way but if you test for Chrome first, you can implement your "click outside the Flash box" method for that case).

Open multiple windows on chrome start

I work in a situation where the computer I use is inconsistent, and I often have never logged onto the computer I'm working on before. As such, I use chrome and launch most of the things I need using the "on startup" option.
My issue is that I have a page that I would like to open in a separate window. I've done some finagling with a javascript bookmarklet that does something similar to what I want, but it isn't perfect.
javascript:window.open("http://google.com","_blank","foobar"); javascript:window.close();
This will open a new window at google.com as expected, however It has a few flaws:
The window is not fullscreen. It will always open at a smaller window size, and is horribly inconsistent on where it will show up.
It isn't a standard window, I can't type in the address bar, add tabs, see my bookmarks bar, or use javascript.
I honestly don't know what the second and third parameters in window.open do, the window will open in a tab instead of a window if I don't have them, but it doesn't care what is there.
I have attempted passing javascript commands through the window.open command, but the window refuses to do any of them.
I understand that this is the type of thing that shouldn't be decided by a webpage, and should be left to a user. But I am the user...
I believe that most of the parameters you mentioned (fullscreen window, window size, other window features) are specified in the third argument of window.open(). For example:
window.open("http://google.com","_blank","fullscreen=yes;menubar=yes;titlebar=yes")
would open http://google.com in a new window (_blank) in fullscreen view (fullscreen=yes;) and render the menubar and titlebar (menubar=yes;titlebar=yes). A list of standard values is provided at w3schools.com and developer.mozilla.org

JavaScript window options

I'm looking to create a "pop-up" window that simply displays text within the window without the browser's signature. When I create a window simply by using the window.open command, the Chrome symbol and address bar is displayed.
Is there a way to get rid of this?
Or is there a smarter way of doing this?
Also, with that being said, I want this window to stay on top of all other windows being displayed. That is, I want it to essentially be running on top of a window even though I may be clicking on a full screen window behind it.
No, this is intentionally made not possible (at least in Chrome) because it could be used to confuse the user to think that a browser window is a window for another program.
Google Chrome window.open height includes URL bar

Having panel behavior in chrome extension

I need to have panel behavior in chrome: something always on top but that does not impair the navigation (in any other way than masking a few pixels).
We have two options at the moment:
window in panel mode: not available yet (although it is available now to the GTalk extension).
window in popup mode: I can make it be always on top by refocusing at every event, however the focus will get targeted at my window (and impair the navigation)
I'm looking for either:
GTalk's dark magic
A way to make a popup window stay on top (or come on top and relinquish the focus to the second topmost window)
I found how GTalk is the only extension with panels. You can have panels too in your own extension, using really dark magic:
In your manifest.json, add the key-value pair:
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsDApubb73tPfYlNIFxDu3K3/EHgV6/YOJXJkld1OZ20jW/cOht1j0NggnXhQYuu1mXFUufud4I2N7b5ydyg09gcM9Va3Zk17RhNV9smbPHOd4XlzJeXifX/9MgHPu4FzCen3CiSXsOeAELJIXEuT28xICriuUko/rNPwGeIB9VwIDAQAB"
And BOOM, panels activated!
This is Google's way of activating a hidden feature. The documentation tells us "key"'s purpose is to provide a unique identifier but that we don't really need it. As demonstrated, it also activates hidden features.
Also, you cannot have two extensions with the same "key" value (GTalk gets uninstalled). And I think your extension might not make it to the chrome store.
If you know someone at Google, please tell them we mortals would really really love to have panels too. Panels are awesome. And they are the only way to display information on top of a web page while still interacting with it. Google should share the love, we really need panels.

Categories

Resources