Forum Discussion

EvTheFuture's avatar
Nov 03, 2023

[Workaound] User required to manually start EPI and VPN in browsers

After upgrading to version 16.1.4 the users need to manually start the End Point Inspector and the Web Initiated VPN by clicking on a "Start" button. This is describe in this KB.

I created a user-common.js that will automatically click on the start button for the user. However, please note that this workround works as of 3rd of November 2023, but might stop working in the future in different browsers.

In order to activate the workaround you need to have an Access Policy of the Moden type. Then go to Customizations -> Advanced -> Acces Profiles -> <Your Access Profile> -> Common

Add the followinf to the file user-common.js

define(["require", "exports", "apmui"], function (require, exports, apmui_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var app = apmui_1.App.get();

app.subscribe(apmui_1.EventType.EPS_CHECK_PROGRESS, function (_, store) {
var btns = document.getElementsByClassName("apmui-button");

if (btns.length == 0) {
console.log("Failed to find button...");
return;
}

btns[0].click();
});

app.subscribe(apmui_1.EventType.DIALOG_OPEN, function (_, store) {
setTimeout(function () {
var dialog = document.getElementById("sna_auto_start_not_supported");

if (dialog == null) {
console.log("Didn't find the right dialog");
return;
}

var btns = dialog.getElementsByClassName("apmui-button");

if (btns.length == 0) {
console.log("Didn't find the start button");
return;
}

btns[0].click();
}, 100);
});
});

If you have a better solution to this, please let me know. This was just what I came up with when asked by customers that the new "Start" button had created confusion among their users.

 

  • 2024-01-30: Updated to also include auto start of tunnels.

     

    define(["require", "exports", "apmui"], function (require, exports, apmui_1) {
        "use strict";
        Object.defineProperty(exports, "__esModule", { value: true });
        var app = apmui_1.App.get();

        app.subscribe(apmui_1.EventType.EPS_CHECK_PROGRESS, function (_, store) {
            var btns = document.getElementsByClassName("apmui-button");

            if (btns.length == 0) {
                console.log("Failed to find button...");
                return;
            }

            btns[0].click();
        });

        app.subscribe(apmui_1.EventType.DIALOG_OPEN, function (_, store) {
            setTimeout(function () {
                var dialog = document.getElementById("sna_auto_start_not_supported");

                if (dialog == null) {
                    try {
                        dialog = document.getElementsByClassName("restart_noautostart_action")[0];
                    } catch (e) { }
                }   
                
                if (dialog == null) {
                    console.log("Didn't find the right dialog");
                    return;
                }

                var btns = dialog.getElementsByClassName("apmui-button");

                if (btns.length == 0) {
                    console.log("Didn't find the start button");
                    return;
                }

                btns[0].click();
            }, 100);
        });
    });

3 Replies

  • 2024-01-30: Updated to also include auto start of tunnels.

     

    define(["require", "exports", "apmui"], function (require, exports, apmui_1) {
        "use strict";
        Object.defineProperty(exports, "__esModule", { value: true });
        var app = apmui_1.App.get();

        app.subscribe(apmui_1.EventType.EPS_CHECK_PROGRESS, function (_, store) {
            var btns = document.getElementsByClassName("apmui-button");

            if (btns.length == 0) {
                console.log("Failed to find button...");
                return;
            }

            btns[0].click();
        });

        app.subscribe(apmui_1.EventType.DIALOG_OPEN, function (_, store) {
            setTimeout(function () {
                var dialog = document.getElementById("sna_auto_start_not_supported");

                if (dialog == null) {
                    try {
                        dialog = document.getElementsByClassName("restart_noautostart_action")[0];
                    } catch (e) { }
                }   
                
                if (dialog == null) {
                    console.log("Didn't find the right dialog");
                    return;
                }

                var btns = dialog.getElementsByClassName("apmui-button");

                if (btns.length == 0) {
                    console.log("Didn't find the start button");
                    return;
                }

                btns[0].click();
            }, 100);
        });
    });

  • This is an updated version that will also auto start application tunnels:

    <SPAN class="token function">define</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token string">"require"</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token string">"exports"</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token string">"apmui"</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token keyword">function</SPAN> <SPAN class="token punctuation">(</SPAN><SPAN class="token parameter">require<SPAN class="token punctuation">,</SPAN> exports<SPAN class="token punctuation">,</SPAN> apmui_1</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
        <SPAN class="token string">"use strict"</SPAN><SPAN class="token punctuation">;</SPAN>
        Object<SPAN class="token punctuation">.</SPAN><SPAN class="token function">defineProperty</SPAN><SPAN class="token punctuation">(</SPAN>exports<SPAN class="token punctuation">,</SPAN> <SPAN class="token string">"__esModule"</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token punctuation">{</SPAN> <SPAN class="token literal-property property">value</SPAN><SPAN class="token operator">:</SPAN> <SPAN class="token boolean">true</SPAN> <SPAN class="token punctuation">}</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
        <SPAN class="token keyword">var</SPAN> app <SPAN class="token operator">=</SPAN> apmui_1<SPAN class="token punctuation">.</SPAN>App<SPAN class="token punctuation">.</SPAN><SPAN class="token function">get</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    
        app<SPAN class="token punctuation">.</SPAN><SPAN class="token function">subscribe</SPAN><SPAN class="token punctuation">(</SPAN>apmui_1<SPAN class="token punctuation">.</SPAN>EventType<SPAN class="token punctuation">.</SPAN><SPAN class="token constant">EPS_CHECK_PROGRESS</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token keyword">function</SPAN> <SPAN class="token punctuation">(</SPAN><SPAN class="token parameter">_<SPAN class="token punctuation">,</SPAN> store</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
            <SPAN class="token keyword">var</SPAN> btns <SPAN class="token operator">=</SPAN> document<SPAN class="token punctuation">.</SPAN><SPAN class="token function">getElementsByClassName</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"apmui-button"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    
            <SPAN class="token keyword">if</SPAN> <SPAN class="token punctuation">(</SPAN>btns<SPAN class="token punctuation">.</SPAN>length <SPAN class="token operator">==</SPAN> <SPAN class="token number">0</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
                console<SPAN class="token punctuation">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"Failed to find button..."</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
                <SPAN class="token keyword">return</SPAN><SPAN class="token punctuation">;</SPAN>
            <SPAN class="token punctuation">}</SPAN>
    
            btns<SPAN class="token punctuation">[</SPAN><SPAN class="token number">0</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">.</SPAN><SPAN class="token function">click</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
        <SPAN class="token punctuation">}</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    
        app<SPAN class="token punctuation">.</SPAN><SPAN class="token function">subscribe</SPAN><SPAN class="token punctuation">(</SPAN>apmui_1<SPAN class="token punctuation">.</SPAN>EventType<SPAN class="token punctuation">.</SPAN><SPAN class="token constant">DIALOG_OPEN</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token keyword">function</SPAN> <SPAN class="token punctuation">(</SPAN><SPAN class="token parameter">_<SPAN class="token punctuation">,</SPAN> store</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
            <SPAN class="token function">setTimeout</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token keyword">function</SPAN> <SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
                <SPAN class="token keyword">var</SPAN> dialog <SPAN class="token operator">=</SPAN> document<SPAN class="token punctuation">.</SPAN><SPAN class="token function">getElementById</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"sna_auto_start_not_supported"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    
                <SPAN class="token keyword">if</SPAN> <SPAN class="token punctuation">(</SPAN>dialog <SPAN class="token operator">==</SPAN> <SPAN class="token keyword">null</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
                    <SPAN class="token keyword">try</SPAN> <SPAN class="token punctuation">{</SPAN>
                        dialog <SPAN class="token operator">=</SPAN> document<SPAN class="token punctuation">.</SPAN><SPAN class="token function">getElementsByClassName</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"restart_noautostart_action"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token number">0</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">;</SPAN>
                    <SPAN class="token punctuation">}</SPAN> <SPAN class="token keyword">catch</SPAN> <SPAN class="token punctuation">(</SPAN>e<SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN> <SPAN class="token punctuation">}</SPAN>
                <SPAN class="token punctuation">}</SPAN>   
                
                <SPAN class="token keyword">if</SPAN> <SPAN class="token punctuation">(</SPAN>dialog <SPAN class="token operator">==</SPAN> <SPAN class="token keyword">null</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
                    console<SPAN class="token punctuation">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"Didn't find the right dialog"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
                    <SPAN class="token keyword">return</SPAN><SPAN class="token punctuation">;</SPAN>
                <SPAN class="token punctuation">}</SPAN>
    
                <SPAN class="token keyword">var</SPAN> btns <SPAN class="token operator">=</SPAN> dialog<SPAN class="token punctuation">.</SPAN><SPAN class="token function">getElementsByClassName</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"apmui-button"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    
                <SPAN class="token keyword">if</SPAN> <SPAN class="token punctuation">(</SPAN>btns<SPAN class="token punctuation">.</SPAN>length <SPAN class="token operator">==</SPAN> <SPAN class="token number">0</SPAN><SPAN class="token punctuation">)</SPAN> <SPAN class="token punctuation">{</SPAN>
                    console<SPAN class="token punctuation">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token string">"Didn't find the start button"</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
                    <SPAN class="token keyword">return</SPAN><SPAN class="token punctuation">;</SPAN>
                <SPAN class="token punctuation">}</SPAN>
    
                btns<SPAN class="token punctuation">[</SPAN><SPAN class="token number">0</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">.</SPAN><SPAN class="token function">click</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
            <SPAN class="token punctuation">}</SPAN><SPAN class="token punctuation">,</SPAN> <SPAN class="token number">100</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
        <SPAN class="token punctuation">}</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
    <SPAN class="token punctuation">}</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>