0

We have a screen in the office running a weather map. The map runs in an iframe and is set to refresh every hour. This is the code;

<!DOCTYPE html>
<head>
<title>VentuSky Barco Display</title>
<link rel="icon" type="image/png" href="favicon.ico">
<meta http-equiv="refresh" content="3600">
</head>
<iframe src="https://www.ventusky.com/?p=53.2;-9.7;4&l=rain-1h" style="position:fixed;top:0px;left:0px;bottom:0px;right:0px;width:100%;height:100%;border:none;margin:0;padding:0;overflow:hidden;z-index:999999"></iframe>

On the VentuSky map that sits in the iframe, if the user presses "p" on the keyboard it hides all the menus and just shows the map (or "presentation mode", as VentuSky call it).

Is there any way I can get the browser to do this automatically when it refreshes every hour?

Dmitry
  • 6,716
  • 14
  • 37
  • 39

1 Answers1

0

It is impossible to do this from this code directly because browsers disable access to iframes from another domain for security reasons. But you can do it with browser plugins like Grease Monkey for FireFox.

Solution for FireFox and Grease Monkey:

  1. Install FireFox and Grease Monkey
  2. Press on chevron near the GM icon (1) and select New User Script(2) enter image description here
  3. Name the script "ventusky"
  4. Enter the namespace: https://www.ventusky.com/ enter image description here
  5. Paste the following code into the window that will open:

    // ==UserScript==
    // @name        ventusky
    // @namespace   https://www.ventusky.com/
    // @description trigger p key press in https://www.ventusky.com/
    // @version     1
    // @grant       none
    // ==/UserScript==
    window.onload = function()
    {
        var keyboardEvent = document.createEvent("KeyboardEvent");
    
        keyboardEvent.initKeyEvent(
            "keydown", // event type : keydown, keyup, keypress
            true, // bubbles
            true, // cancelable
            window, // viewArg: should be window
            false, // ctrlKeyArg
            false, // altKeyArg
            false, // shiftKeyArg
            false, // metaKeyArg
            'P'.charCodeAt(0), // keyCodeArg : unsigned long the virtual key code, else 0
            0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
        );
        document.dispatchEvent(keyboardEvent);
    };
    

NOTE: It will ask you to type "allow pasting" when you try to paste the code.

Key press event triggering code is based on this answer.

Dmitry
  • 6,716
  • 14
  • 37
  • 39