Is Opera Turbo on?
Asked Answered
D

3

5

I've got a page which uses Flash with animations (These are not crucial but additional).

Everything works fine, if I'm not using Opera with activated Turbo. Then the Flash Movie is shown as a big ugly arrow in a circle the size of the flash movie which is intended to act as a play button for the flash.

I'm using SWFobject, so I easily could turn of the animation if I knew if Opera's turbo mechanism is used, but how do I do this in JavaScript (or maybe CSS if this goes)


How to reproduce?
Surf this page with Opera (or any other page which uses flash)
http://www.adobe.com/software/flash/about/
Without Opera Turbo you see a flash animation and flash version information With Opera Turbo you see two white arrows in gray circles


edit 1 I'm quite sure now, that there is not a pure JS solution and not a PHP solution. The best guess is a combined AS/JS solution.

Danie answered 11/1, 2012 at 9:42 Comment(4)
are you still able to circumvent plugin-on-demand in Opera ?Thumbtack
@Thumbtack I don't know anything about that. And I don't think this is the problem. I just switch on Turbo and there you go. Flash is installed and if you klick on the play button, flash starts to play.Danie
Sorry for of topic, but what is required to add bountys to a question? I've read the faq but cant seem to find it.Haplography
@Haplography you need to wait 2 days after the question was asked. Then you can add bountyDanie
F
2

You can try to check if the flash object is loaded with some javascript. This code works on my computer with Opera 11:

<html>
<head>
  <script language=JavaScript>
    function isFlashBlocked(){
      var blocked;
      try {
        // Can test this on any flash object on the page
        window.document.myFlash.SetVariable("dummy", "dummy");
        // Flash not blocked
        blocked = false;
      }
      catch(err) {
        // Flash blocked
        blocked = true;
      }

      return blocked;
    }

    function removeBlockedFlash() {
      if (isFlashBlocked()) {
        // Hide all flash objects
        window.document.myFlash.setAttribute("style", "display: none");
        // ...

        // Display replacement content
        window.document.myImage.setAttribute("style", "display: inline");
        // ...
      }
    }
  </script>
</head>
<body onload="removeBlockedFlash()">
  <object type="application/x-shockwave-flash" data="HelloWorld.swf" 
          width="100" height="100" id="myFlash">
  </object>
  <img src="image.jpg" style="display: none" id="myImage" />
</body>
</html>

If you detect that flash is blocked, you hide every flash object and display what you want.

Edit: This code doesn't work with Firefox, you probably need to detect the browser before using this function.

Franky answered 19/1, 2012 at 22:9 Comment(5)
+1 This is very opera turbo independent and works to tell if flash was loaded or is blocked! Still no way to avoid the hideous white button right?Claro
That means, I need a dummy 1x1 flash anywhere on the page? This works with ExternalInterface only?Danie
@Danie You don't need a dummy flash object because you already have some flash on the page. I think you don't need to modify your page or your flash code, you simply add the javascript with the id of one of your existing flash objects. If you detect that flash is blocked then remove/hide <object> (modify DOM with javascript) and add/show what you want to display instead.Franky
@Franky But I have the problem, that the blocked Flash looks so ugly. And can I set a variable on a flash that is currently loading? So I do not remove flash when it is not blocked?Danie
@Danie I have edited the answer with a more complete example. It show how to replace flash with an image if flash was blocked.Franky
C
5

Client side detection: There is no way to access that through javascript. Client side detection for opera turbo is not possible currently, maybe it will be supported in the future but who knows?

Server side detection: When opera turbo is enabled all requests from client are done to opera servers, the opera servers are going to access your application (do compressions) and forward the processed content to the final client (user's computer).

With that in mind, let's do some network sniffing and see where are your connection going:

~$ nslookup opera10beta-turbo.opera-mini.net
>Server:        189.40.226.80
>Address:   189.40.226.80#53
>Non-authoritative answer:
>opera10beta-turbo.opera-mini.net   canonical name = global-turbo-1.opera-mini.net.
>Name:  global-turbo-1.opera-mini.net
>Address: 141.0.11.252

~$ nslookup 64.255.180.252
>Server:        192.168.1.254
>Address:   192.168.1.254#53
>Non-authoritative answer:
>252.180.255.64.in-addr.arpa    canonical name = 252.0-24.180.255.64.in-addr.arpa.
>252.0-24.180.255.64.in-addr.arpa   name = global-turbo-1-lvs-usa.opera-mini.net.

As you can see the name and canonical name from opera servers can be used to detect if you application is being accessed through opera servers intermediation. I think server side coding could handle that (not sure what language are you using on your server).

It's good to remember that Opera Turbo will not intermediate your requests if you're accessing something in your local server.

Hope it helps.

Claro answered 14/1, 2012 at 3:11 Comment(8)
Also, Opera sends an X-Forwarded-For header when using Turbo, with the value as the user's actual IP. If you're comparing the dns to check for Turbo, be sure to check for presence of X-forwarded-for as well. It's also worth to note that Opera Mini content is always piped through Opera's servers.Hooker
This seems like a good answer, but I thought there is no guarantee that every connection with opera turbo is actually compressed. If yout network connexion is fast enough, opera won't re-route the request via the opera servers, but will still not play the swf.Danie
@JaniHartikainen good information, I didn't include it in the answer because I thought every user behind a proxy would create this header too. Bu the X-forwarded-for could be used to filter which requests to inspect instead of inspect every requisition. That could be interesting to avoid performance loss on every cases.Claro
@Danie Well said. I like that feature since Opera Turbo can act as some kind off add blocker too. But it configures a drawback to my answer when flash is involved. This is probably a non win situation that developers shouldn't be concerned, users that activate opera turbo probably will understand that this behavior is a browser feature not a bug in the website (just like in any add blocker plugin from other browsers).Claro
Would be nice, if I shouldn't be bothered, but I am concerned about that.Danie
I'm still thinking about that problem but every check that comes to mind seems too indirect to fully detect Turbo presence.Claro
I think that individual users can change the Opera Turbo server in Opera's turbosettings.xml. So the server side solution may not be a great answer, even if it is the only one.Qoph
The idea is not to use the server name entire string, the idea is to look for keywords like opera and turbo altogether. But yes, nothing can beat a combo of ninja feature + user configuration.Claro
Q
2

I believe that the answer to the speed issue is that the Flash content is not downloaded initially. You have to manually click on the icon to download it. Same for animated GIFs. This is part of the strategy to boost the speed. (cf., this Opera Desktop Team post.)

Which is why you want to know how to check for Opera Turbo, and not just Opera. From my local tests, I cannot tell the difference using PHP's _SERVER["HTTP_USER_AGENT"] variable. I think this is similar to what Opera lists as the user agent string, as shown here and here.

It seems that, rather notifying the website of the browser condition, Opera silently manages the request results differently.

Qoph answered 13/1, 2012 at 23:43 Comment(9)
I'm not sure about the Flash not being downloaded with Turbo activated. I remember some sort of saving processor performance as a reason. But I'm not sure.Danie
@yunzen, please see the link to the Opera blog post. That is what I am using to verify my claim.Qoph
this is from 2009. Maybe it has changed sinceDanie
Well, you can always check whether the SWF is actually on the page, right? And that seems to be killing two birds with one stone . . . no Flash where there should be Flash (along with the Opera user agent string) is a pretty good way of determining that Turbo is activated.Qoph
As I stated in the comments in the other answer by marcioAlmada: 'I thought there is no guarantee that every connection with opera turbo is actually compressed. If yout network connexion is fast enough, opera won't re-route the request via the opera servers, but will still not play the swf.' So this will be no safe answerDanie
Currently behavior of OP turbo doesn't remove the flash <object>from DOM, it just blocks the download and automatic execution of the flash. In case the swf is already on cache it blocks the execution the same way and you wil still see the big play button.Claro
So you have just established conditions that do exist in the DOM: the Opera arrow. Or does it not exist in the DOM (I have uninstalled Opera at this point, so you will have to check this)? So if there is a big arrow instead of the SWF, you have a valid check (if there is no icon, then it is the normal condition). Or it may be that the SWF is hidden when you have not programmed it to be hidden, so cf., this post.Qoph
ok, checked again now. The arrow itself does not exist in the DOM, all that exists is the original flash element (with blocked download/execution as I said). But the arrow is not injected in DOM, the inspectors do not accuse any difference in DOM before and after a given flash object is activated. This seems a good thing, they're not hacking our DOMs =]Claro
Hm. But it is a hack. So much so that is is redefining what qualifies as part of the DOM; an image is showing that's not listed in the DOM. Hm hm hm. Cannot see anything using Firebug, and it does show up when all CSS is off. No solutions . . . yet?Qoph
F
2

You can try to check if the flash object is loaded with some javascript. This code works on my computer with Opera 11:

<html>
<head>
  <script language=JavaScript>
    function isFlashBlocked(){
      var blocked;
      try {
        // Can test this on any flash object on the page
        window.document.myFlash.SetVariable("dummy", "dummy");
        // Flash not blocked
        blocked = false;
      }
      catch(err) {
        // Flash blocked
        blocked = true;
      }

      return blocked;
    }

    function removeBlockedFlash() {
      if (isFlashBlocked()) {
        // Hide all flash objects
        window.document.myFlash.setAttribute("style", "display: none");
        // ...

        // Display replacement content
        window.document.myImage.setAttribute("style", "display: inline");
        // ...
      }
    }
  </script>
</head>
<body onload="removeBlockedFlash()">
  <object type="application/x-shockwave-flash" data="HelloWorld.swf" 
          width="100" height="100" id="myFlash">
  </object>
  <img src="image.jpg" style="display: none" id="myImage" />
</body>
</html>

If you detect that flash is blocked, you hide every flash object and display what you want.

Edit: This code doesn't work with Firefox, you probably need to detect the browser before using this function.

Franky answered 19/1, 2012 at 22:9 Comment(5)
+1 This is very opera turbo independent and works to tell if flash was loaded or is blocked! Still no way to avoid the hideous white button right?Claro
That means, I need a dummy 1x1 flash anywhere on the page? This works with ExternalInterface only?Danie
@Danie You don't need a dummy flash object because you already have some flash on the page. I think you don't need to modify your page or your flash code, you simply add the javascript with the id of one of your existing flash objects. If you detect that flash is blocked then remove/hide <object> (modify DOM with javascript) and add/show what you want to display instead.Franky
@Franky But I have the problem, that the blocked Flash looks so ugly. And can I set a variable on a flash that is currently loading? So I do not remove flash when it is not blocked?Danie
@Danie I have edited the answer with a more complete example. It show how to replace flash with an image if flash was blocked.Franky

© 2022 - 2024 — McMap. All rights reserved.