How can I make a tab in Firefox falsely believe that it still has the focus?

27

8

In Firefox I would like to pass to another tab while an ad is playing in the current tab, but the pesky thing will pause when its tab loses the focus.

I would like to trick the ad to believe that it still has the focus, for it to keep on playing so I don't have to wait for it to finish.

How can I make a Firefox tab falsely believe that it still has the focus ?

You can make the assumption that the page is using techniques described here. window.onfocus and window.onblur are probably used. I don't remember where exactly I needed this when I asked the question; this is not necessarily used to trick ads. I'm looking for a generic solution.

alecail

Posted 2012-10-24T18:23:28.393

Reputation: 453

@harrymc Javascript only is ok. – alecail – 2013-10-12T10:53:32.577

1Need a demo url for giving useful advice. – harrymc – 2013-10-12T10:55:59.397

Answers

15

Since you have not provided details of the website, here is one solution you can try.

  • Install the Greasemonkey extension to allow you to run user JavaScripts on websites of your choice.
  • Install the Always on focus userscript.

    Script Summary: Some pages check the document.hidden property and won't render content unless the page is in focus. This script will trick them to think they are in focus so you can preload them in a tab and visit them when they have finished loading.

  • Configure the script for specific websites, as desired, while installing (or later).

M K

Posted 2012-10-24T18:23:28.393

Reputation: 2 414

3

Mirror: http://userscripts-mirror.org/scripts/review/177284

– Paul – 2017-03-07T16:12:28.080

3

I've tested Aways on focus with this other script that console logs if the screen in being focused (using jquery): http://jsfiddle.net/ScKbk/ It doesn't work, correct me if I'm wrong. Currently testing on Chrome v63 MacOS Sierra

– David Lopez – 2018-01-02T14:18:42.067

2

You need to create a User Script. These are javascripts that run within Firefox (or Chrome) and manipulate specific websites.

Tools such as Greasemonkey (http://www.greasespot.net) can be used for this. There may be one already available at http://userscripts.org.

But as @harrymc has already commented, an example URL would be useful.

Chenmunka

Posted 2012-10-24T18:23:28.393

Reputation: 3 019

2

I'm going to answer the question I think you're meaning to ask.

What you want to do is have Flash run in the background when you've lost focus. This is a big problem with Flash-based idle games, and the following are some bits from Adobe's Flash Administration Manual that should make stuff run when you aren't focused.

mms.cfg file location Assuming a default Windows installation, Flash Player looks for the mms.cfg file in the following system directories:

• 32-bit Windows - %WINDIR%\System32\Macromed\Flash

• 64-bit Windows - %WINDIR%\SysWow64\Macromed\Flash

What you want to do is create this mms.cfg file (you'll need admin access, natch) with the following lines in it:

ProtectedMode=0

FullFramerateWhenInvisible=true

I recall disabling protected mode being necessary, even though its stated purpose is sandboxing Flash apps - for whatever reason, the other option didn't work without it. YMMV, of course - try it without disabling protected mode first - it's been a long while since I've configured this on my computers.

FullFramerateWhenInvisible is the option that makes it so Flash runs when the window doesn't have focus.

Once again, this isn't the specific question you asked, but if it isn't the right answer, it'll at least send you in the right direction. :)

Reference: Admin guide: http://www.adobe.com/devnet/flashplayer/articles/flash_player_admin_guide.html

Framerate trick: http://tukkun.webs.com/ (#3 on that webpage, currently)

Epsilon

Posted 2012-10-24T18:23:28.393

Reputation: 66

1I don't use Windows, and the question is unrelated to Flash. – alecail – 2013-10-16T06:50:37.157

As a sidenote the mms.cfg path on linux is /etc/adobe/ and /Library/Application Support/Macromedia on OSX. – Shadok – 2013-10-17T14:40:38.223

0

The Grease/Tamper-monkey answer doesn't work on Facebook watchparties, but manually removing the blur event handlers works in Chrome 75:

Chrome event handler removal

In Firefox the same should be achievable using the Inspector as well:

enter image description here

Cees Timmerman

Posted 2012-10-24T18:23:28.393

Reputation: 1 240

0

Well i don't think you really can do anything to keep the focus
You can try to modify the website or you can try to open the page in a new window see if it works
If you know how to code in C++/C# you can try to give firefox focus for like each time it losing focus or just give it focus none stop it's not that hard and if you want the code i can write one for you.
also there is a way to modify the registry but i don't know if it really will work for you or not
Here is the instructions:

  1. Open regedit by Win + R or just type it in start menu's search box
  2. In regedit go to HKEY_CURRENT_USER > Control Panel > Desktop
  3. Edit "ForegroundLockTimeout" the key type is DWORD (Hexadecimal) the default is 30d40 (200000) milliseconds

don't forget to export the key to make a backup before editing it

or you can use this program called Tweak UI but i am not sure it work correctly since it was made for Windows XP

poqdavid

Posted 2012-10-24T18:23:28.393

Reputation: 441