Exemplo n.º 1
0
        protected override void Execute(NativeActivityContext context)
        {
            var closeall = CloseAll.Get(context);
            var browser  = Browser.Get(context);
            var timeout  = TimeSpan.FromSeconds(3);

            if (browser != "chrome" && browser != "ff" && browser != "edge")
            {
                browser = "chrome";
            }
            NMHook.enumtabs();
            if (closeall)
            {
                foreach (var tab in NMHook.tabs.Where(x => x.browser == browser).ToList())
                {
                    NMHook.closetab(browser, tab.id);
                }
            }
            else
            {
                if (browser == "chrome")
                {
                    if (NMHook.CurrentChromeTab != null)
                    {
                        NMHook.closetab(browser, NMHook.CurrentChromeTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
                if (browser == "ff")
                {
                    if (NMHook.CurrentFFTab != null)
                    {
                        NMHook.closetab(browser, NMHook.CurrentFFTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
                if (browser == "edge")
                {
                    if (NMHook.CurrentEdgeTab != null)
                    {
                        NMHook.closetab(browser, NMHook.CurrentEdgeTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
            }
        }