// Выбираем случайную версию Firefox
Random r = new Random();
//Формируем набор buildID нашего Firefox (у каждой версии свой)
Tuple<string, string>[] buildIDSet = {
Tuple.Create("57", "20171112125346"),
Tuple.Create("56", "20171024165158"), // 56.0.2
Tuple.Create("56", "20171002220106"), // 56.0.1
Tuple.Create("56", "20170926190823"),
Tuple.Create("55", "20170802111421"),
Tuple.Create("54", "20170608105825"),
Tuple.Create("53", "20170413192749"),
Tuple.Create("52", "20171206101620"), // 52.5.2
Tuple.Create("52", "20171107091003"), // 52.5.0
Tuple.Create("52", "20170316213829"),
Tuple.Create("51", "20170125094131"),
Tuple.Create("50", "20161104212021"),
Tuple.Create("49", "20161019084923")
};
// Версия
int currentBuild = r.Next(buildIDSet.Length);
string version = buildIDSet[currentBuild].Item1;
// Устанавливаем BuildID
instance.ShowNavigatorField(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.BuildId);
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.BuildId, buildIDSet[currentBuild].Item2);
// Устанавливаем Vendor
instance.ShowNavigatorField(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.Vendor);
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.Vendor, null);
// Устанавливаем VendorSub
instance.ShowNavigatorField(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.VendorSub);
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.VendorSub, null);
// Формируем набор версий операционной системы Windows
// 6.0 Windows Vista
// 6.1 Windows 7
// 6.2 Windows 8
// 6.3 Windows 8.1
// 10.0 Windows 10
string winOC = Macros.TextProcessing.Spintax("{6.0|6.1|6.2|6.3|10.0}");
string platform = Macros.TextProcessing.Spintax("{Win32|Win64}");
// Определяем "битность" самого приложения
string platformApp = string.Empty;
if(platform=="Win32"){
platformApp = Macros.TextProcessing.Spintax("{; WOW64|}");
} else {
platformApp = "; Win64; x64";
}
// OC
project.Profile.UserAgentOsCpu = string.Format("Windows NT {0}{1}", winOC, platformApp);
project.Profile.UserAgentPlatform = platform;
// Устанавливаем Useragent
project.Profile.UserAgent = string.Format("Mozilla/5.0 (Windows NT {0}{1}; rv:{2}.0) Gecko/20100101 Firefox/{2}.0", winOC, platformApp, version);
project.Profile.UserAgentAppVersion = "5.0 (Windows)";
project.Profile.UserAgentAppName = "Netscape";
project.Profile.UserAgentAppCodeName = "Mozilla";
project.Profile.UserAgentProduct = "Gecko";
project.Profile.UserAgentProductSub = "20100101";