Beispiel #1
0
        /// <summary>
        /// Removes the cache folders that were created by Selenium driver, since they take a lot of space (70MB+)
        /// </summary>
        /// <param name="acc">Account</param>
        public static void RemoveCache(Account acc)
        {
            var userFolder = IoHelperCore.GetCacheFolder(acc.AccInfo.Nickname, acc.AccInfo.ServerUrl, "");

            var removeFolders = Directory
                                .GetDirectories(CachePath + "\\")
                                .Where(x => x.Replace(CachePath + "\\", "").StartsWith(userFolder))
                                .ToArray();

            if (removeFolders == null)
            {
                return;
            }

            for (int i = 0; i < removeFolders.Count(); i++)
            {
                Directory.Delete(removeFolders[i], true);
            }
        }
        /// <summary>
        /// Creates chrome extension (.crx) for proxy authentication
        /// </summary>
        /// <param name="username">Travian username</param>
        /// <param name="server">Travian server</param>
        /// <param name="access">Access</param>
        /// <returns>Path of the chrome extension</returns>
        public static string CreateExtension(string username, string server, Access access)
        {
            var cacheDir = IoHelperCore.GetCacheDir(username, server, access);
            var dir      = Path.Combine(cacheDir, "ProxyAuthExtension");

            Directory.CreateDirectory(dir);

            CreateFile(Path.Combine(dir, "manifest.json"), manifestJson);
            CreateFile(Path.Combine(dir, "background.js"), GenerateBackgroundJs(access));

            var zipPath = Path.Combine(cacheDir, "chromeExtension.crx");

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }
            ZipFile.CreateFromDirectory(dir, zipPath);

            return(zipPath);
        }
Beispiel #3
0
 /// <summary>
 /// Cache folder selenium will use for this account
 /// </summary>
 /// <param name="username">Username</param>
 /// <param name="server">Server url</param>
 /// <param name="proxy">Proxy ip</param>
 /// <returns></returns>
 internal static string GetCacheFolder(string username, string server, string proxy)
 {
     return($"{username}_{IoHelperCore.UrlRemoveHttp(server)}_{proxy}");
 }