1// LICENSE_CODE ZON 2'use strict'; /*jslint node:true, browser:true*/ 3var define; 4var is_node = typeof module=='object' && module.exports; 5if (is_node) 6 define = require('../../../util/require_node.js').define(module, '..'); 7else 8 define = self.define; 9define('/www/hola/pub/site_load.js', ['/util/user_agent.js', 'hola_opt', 10 '/www/util/pub/inc_config.js', '/www/hola/pub/experiment_init', 11 '/www/hola/pub/lib/use_browser.ts', 'pub_config', 'cookie', 12 '/util/util.js', '/util/url.js'], 13 function(user_agent, hopt, inc_config, experiment_init, use_browser_m, 14 pub_config, cookie, zutil, zurl) 15 { 16var perr = inc_config.perr||function(){}; 17experiment_init = experiment_init.default; 18var use_browser = use_browser_m.use_browser; 19var E = {}; 20var mac_installer_filename = 'Hola2E-mac-installer.zip'; 21var mac_dmg_filename = function(versions){ 22 return 'HolaVPN2E-'+versions.iosmac2e+'-'+ 23 versions.iosmac2e_build+'.dmg'; 24}; 25 26E.GDL = { 27 firefox_signed: { 28 name: 'Firefox Signed', 29 cls: 'firefox_signed', 30 url: '/firefox_signed_last.xpi', 31 }, chrome: { 32 name: 'Chrome', 33 cls: 'chrome', 34 url: 'https://chromewebstore.google.com/detail/' 35 +'hola-vpn-the-website-unbl/gkojfkhlekighikafcpjkiklfbnlmeio', 36 }, opera: { 37 name: 'Opera', 38 cls: 'opera', 39 url: 'https://addons.opera.com/en/extensions/details/hola-better-' 40 +'internet/', 41 id: 'ekmmelpnmfdegjhnmadddcfjcahpajnm', 42 }, edge: { 43 name: 'Edge', 44 cls: 'edge', 45 url: 'https://microsoftedge.microsoft.com/addons/detail/' 46 +'eibinhpjpbkmjeohlclnebmkhdfehpbf', 47 id: 'eibinhpjpbkmjeohlclnebmkhdfehpbf', 48 }, android: { 49 name: 'Android', 50 cls: 'android', 51 }, android_premium: { 52 name: 'Android', 53 cls: 'android', 54 }, android_va: { 55 name: 'Android', 56 cls: 'android', 57 url: 'market://details?id=org.hola.va', 58 }, windows: { 59 name: 'Windows', 60 cls: 'windows', 61 url: '/download/windows', 62 }, mac: { 63 name: 'Mac OS', 64 cls: 'mac', 65 url: '/download/mac', 66 }, ios: { 67 name: 'iPhone/iPad', 68 cls: 'ios', 69 url: 'https://itunes.apple.com/us/app/hola-vpn/' 70 +'id1553473179?mt=8', 71 }, xbox: { 72 name: 'Xbox/Xbox 360/Xbox One', 73 cls: 'xbox', 74 url: '/plus_setup?platform=console&type=xbox_one', 75 }, ps: { 76 name: 'Playstation/Playstation 2/Playstation 3/Playstation 4', 77 cls: 'ps', 78 url: '/plus_setup?platform=console&type=ps4', 79 }, 80}; 81 82Object.defineProperty(E.GDL.android, 'url', { 83 get: function(){ 84 if (!hopt.www_hola.link_download_apk) 85 return 'market://details?id=org.hola'; 86 return hopt.www_hola.link_download_apk; 87 } 88}); 89Object.defineProperty(E.GDL.android_premium, 'url', { 90 get: function(){ 91 if (!hopt.www_hola.link_download_apk) 92 return 'market://details?id=org.hola.play'; 93 return hopt.www_hola.link_download_apk; 94 } 95}); 96function ga_send(type, category, action, label, non_interaction){ 97 window.ga(function(){ 98 window.ga('send', {hitType: type, eventCategory: category, 99 eventAction: action, eventLabel: label, 100 nonInteraction: non_interaction}); 101 }); 102} 103function is_agreed(_hopt, opt){ 104 return opt && (opt.agree || opt.agreed_in_ext) && 105 (_hopt.www_hola.enable_install_exe_agreed_win 106 || window.location.search.includes('test=exe_flow')); 107} 108 109function is_lum_promo(opt){ 110 return opt && opt.lum_promo; 111} 112function is_uninstall_flow(opt){ 113 return opt && opt.uninstall_flow; 114} 115function is_extension_flow(opt){ 116 return opt && opt.extension_flow; 117} 118function is_install_flow(opt){ 119 return opt && opt.install_flow; 120} 121function is_mac_install_flow(_hopt, opt){ 122 return opt && (opt.mac_installer || _hopt.www_hola.mac_installer); 123} 124function is_ext_vpn_flow(_hopt, opt){ 125 return opt && opt.ext_vpn; 126} 127function is_firefox_flow(opt){ 128 return opt && opt.firefox && !opt.os; 129} 130function is_firefox_jn_flow(opt, b){ 131 return opt && (opt.firefox || b=='firefox') && opt.from_jn && !opt.os; 132} 133function is_opera_flow(opt){ 134 return opt && opt.opera && !opt.os; 135} 136function is_opera_jn_flow(opt, b){ 137 return opt && (opt.opera || b=='opera') && opt.from_jn && !opt.os; 138} 139function is_edge_flow(opt){ 140 return opt && opt.edge && !opt.os; 141} 142function is_edge_jn_flow(opt, b){ 143 return opt && (opt.edge || b=='edge') && opt.from_jn && !opt.os; 144} 145function is_chrome_flow(opt){ 146 return opt && opt.chrome && !opt.os; 147} 148function is_chrome_jn_flow(opt, b){ 149 return opt && (opt.chrome || b=='chrome') && opt.from_jn && !opt.os; 150} 151function is_banner_flow(opt){ 152 return opt && opt.banner; 153} 154function is_email_flow(opt){ 155 return opt && opt.email; 156} 157function is_no_consent_flow(opt){ 158 return opt && opt.noconsent; 159} 160function is_ios_flow(opt){ 161 return opt && opt.ios; 162} 163function is_online_vpn_flow(opt){ 164 return opt && opt.online_vpn; 165} 166 167E.is_win_installer_v2 = function(_hopt, sys){ 168 var sys_win_installer_v2 = _hopt.www_hola.sys_win_installer_v2_re || []; 169 var is_v2_enabled = sys_win_installer_v2.some(function(_sys){ 170 var conf_keys = Object.keys(_sys); 171 return conf_keys.every(function(c_key){ 172 var r_exp = new RegExp(_sys[c_key]); 173 return r_exp.test(sys[c_key]); 174 }); 175 }); 176 return is_v2_enabled; 177}; 178E.get_exe_link = function(_hopt, sys, versions, opt){ 179 if (!opt) 180 opt = {}; 181 var url_d = _hopt.cdn4_host || pub_config.cdn_url; 182 var special_countries = _hopt.www_hola.use_site_for_download || []; 183 if (special_countries.indexOf((_hopt.user_country || '').toUpperCase())>-1) 184 url_d = pub_config.backend_url; 185 var filename = E.get_exe_filename(_hopt, sys, versions, opt); 186 if (sys.os=='macos' && !opt.os || opt.os=='macos') 187 return url_d+'/static/'+filename; 188 var ver_v2 = opt.hola_browser ? versions.browser_web_installer_v2 189 : versions.vpn_web_installer_v2; 190 return url_d+'/static/v2/'+filename 191 +'?web_installer_v2='+ver_v2 192 +'&product='+(opt.hola_browser ? 'browser' 193 : opt.hola_gameboost ? 'gameboost' : ''); 194}; 195 196var get_cmp_conf = function(c_type, type){ 197 return zutil.get(hopt, 'www_hola.campaigns.'+type, []).find(function(c){ 198 return c.name==c_type || c.cam_id && c_type.startsWith(c.name); 199 }); 200}; 201 202E.get_exe_filename = function(_hopt, sys, versions, opt){ 203 if (!opt) 204 opt = {}; 205 var os = sys.os=='macos' && !opt.os || opt.os=='macos' ? 'mac' : 'windows'; 206 var is_mac = os=='mac'; 207 var cmp_conf; 208 if (is_mac && (window.location.pathname=='/' || 209 is_mac_install_flow(_hopt, opt) || opt.hola_browser)) 210 { 211 return mac_installer_filename; 212 } 213 if (opt.hola_gameboost && !is_mac) 214 { 215 return hopt.www_hola.gameboost_installer_name || 216 'Hola-Setup-v2-Gaming.exe'; 217 } 218 if (opt.hola_browser && !(hopt.www_hola.no_mac_browser && is_mac)) 219 { 220 var fn_browser = !is_mac ? hopt.www_hola.hola_browser_name : 221 hopt.www_hola.mac_installer_browser; 222 var fn_ext = is_mac ? '.zip' : '.exe';
223 // XXX dmitriiz: don't add campaign from cookie for mac 224 if (is_mac && fn_browser) 225 { 226 return fn_browser.indexOf(fn_ext)==-1 ? fn_browser+fn_ext 227 : fn_browser; 228 } 229 if (!is_mac && E.is_win_installer_v2(_hopt, sys)) 230 fn_browser = hopt.www_hola.hola_browser_name_v2; 231 var ab_tests = is_mac ? [] : []; 232 var is_a = ab_tests.some(function(x){ 233 return experiment_init.ui_test[x]===true; }); 234 var is_b = ab_tests.some(function(x){ 235 return experiment_init.ui_test[x]===false; }); 236 if (is_a) 237 fn_browser = fn_browser.replace(fn_ext, '-C-hpa'+fn_ext); 238 else if (is_b) 239 fn_browser = fn_browser.replace(fn_ext, '-C-hpb'+fn_ext); 240 else 241 { 242 var c_browser = cookie.get('c_browser'); 243 if (c_browser && c_browser!='organic') 244 { 245 cmp_conf = get_cmp_conf(c_browser, 'browser'); 246 var pref = ''; 247 if (is_agreed(_hopt, opt)) 248 pref += '-Agreed'; 249 if (cmp_conf && cmp_conf.infix) 250 pref += cmp_conf.infix; 251 fn_browser = fn_browser.replace(fn_ext, 252 pref+'-C-'+c_browser+fn_ext); 253 } 254 } 255 return fn_browser; 256 } 257 var file_name; 258 var b = use_browser(); 259 var is_sdk = (hopt.www_hola.sdk_browsers || []).indexOf(b)>-1 && 260 (hopt.www_hola.sdk_os || []).indexOf(os)>-1; 261 var has_svc = E._is_installed && E._is_installed.svc || opt && opt.has_svc; 262 if (is_mac) 263 return mac_dmg_filename(versions); 264 var nosdk = opt && opt.svc_info 265 && opt.svc_info.appid=='win_hola.noconsent.hola.org'; 266 var is_installer_v2 = E.is_win_installer_v2(_hopt, sys); 267 var add_campaign; 268 if (is_lum_promo(opt)) 269 { 270 return is_agreed(_hopt, opt) ? 'Hola-Setup-Pro-Agreed.exe' 271 : 'Hola-Setup-Pro.exe'; 272 } 273 else if (is_online_vpn_flow(opt)) 274 { 275 file_name = 'Hola-Setup-VPN.exe'; 276 add_campaign = true; 277 } 278 else if (is_uninstall_flow(opt)) 279 { 280 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-P2-Agreed.exe' 281 : 'Hola-Setup-P2.exe'; 282 } 283 else if (is_ext_vpn_flow(_hopt, opt)) 284 { 285 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Ext-VPN-Agreed.exe' 286 : 'Hola-Setup-Ext-VPN.exe'; 287 } 288 else if (is_opera_jn_flow(opt, b)) 289 { 290 291 file_name = is_agreed(_hopt, opt) ? 292 'Hola-Opera-Agreed.exe' : 'Hola-Opera.exe'; 293 } 294 else if (is_firefox_jn_flow(opt, b)) 295 { 296 file_name = is_agreed(_hopt, opt) ? 297 'Hola-Firefox-Agreed.exe' : 'Hola-Firefox.exe'; 298 } 299 else if (is_edge_jn_flow(opt, b)) 300 { 301 file_name = is_agreed(_hopt, opt) ? 302 'Hola-Edge-Agreed.exe' : 'Hola-Edge.exe'; 303 } 304 else if (is_chrome_jn_flow(opt, b)) 305 { 306 file_name = is_agreed(_hopt, opt) ? 'Hola-Chrome-Agreed.exe' 307 : 'Hola-Chrome.exe'; 308 } 309 else if (is_extension_flow(opt)) 310 { 311 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Ext-Agreed.exe' 312 : 'Hola-Setup-Ext.exe'; 313 } 314 else if (is_install_flow(opt)) 315 { 316 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Ext2-Agreed.exe' 317 : 'Hola-Setup-Ext2.exe'; 318 } 319 else if (is_firefox_flow(opt)) 320 { 321 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Firefox-Agreed.exe' 322 : 'Hola-Setup-Firefox.exe'; 323 } 324 else if (is_opera_flow(opt)) 325 { 326 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Opera-Agreed.exe' 327 : 'Hola-Setup-Opera.exe'; 328 } 329 else if (is_chrome_flow(opt)) 330 { 331 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Chrome-Agreed.exe' 332 : 'Hola-Setup-Chrome.exe'; 333 } 334 else if (is_edge_flow(opt)) 335 { 336 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Edge-Agreed.exe' 337 : 'Hola-Setup-Edge.exe'; 338 } 339 else if (is_banner_flow(opt)) 340 { 341 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Banner-Agreed.exe' 342 : 'Hola-Setup-Banner.exe'; 343 } 344 else if (is_email_flow(opt)) 345 { 346 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Email-Agreed.exe' 347 : 'Hola-Setup-Email.exe'; 348 } 349 else if (is_no_consent_flow(opt)) 350 { 351 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Noconsent-Agreed.exe' 352 : 'Hola-Setup-Noconsent.exe'; 353 } 354 else if (is_ios_flow(opt)) 355 { 356 file_name = is_agreed(_hopt, opt) ? 'Hola-Setup-Ios-Agreed.exe' 357 : 'Hola-Setup-Ios.exe'; 358 } 359 else if (is_agreed(_hopt, opt)) 360 file_name = 'Hola-Setup-Agreed.exe'; 361 else 362 { 363 file_name = has_svc && !nosdk || is_sdk ? 364 hopt.www_hola.sdk_app_name_exe : (is_installer_v2 ? 365 hopt.www_hola.no_sdk_app_name_exe_v2 : 366 hopt.www_hola.no_sdk_app_name_exe) 367 || 'Hola-Setup.exe'; 368 add_campaign = true; 369 } 370 if (add_campaign) 371 {
372 var c_vpn_c = cookie.get('c_vpn') && cookie.get('c_vpn')!=='organic' ? 373 cookie.get('c_vpn') : ''; 374 var c_vpn = c_vpn_c || hopt.c_vpn; 375 if (c_vpn && c_vpn!='organic') 376 { 377 cmp_conf = get_cmp_conf(c_vpn, 'vpn'); 378 file_name = file_name.replace('.exe', 379 (cmp_conf && cmp_conf.infix || '')+'-C-'+c_vpn+'.exe'); 380 } 381 else if (opt.from_navbar) 382 { 383 file_name = file_name.replace('.exe', 384 '-C-HNB.exe'); 385 } 386 else if (window.location.pathname=='/') 387 { 388 file_name = file_name.replace('.exe', 389 '-C-HP'+(opt.after_dl_flow ? 'E' : '')+'.exe'); 390 } 391 } 392 if (is_installer_v2 && window.location.pathname=='/' 393 && experiment_init.ui_test.test_installer_eula_skip_v3 !== undefined) 394 { 395 var exp_ver = experiment_init.ui_test 396 .test_installer_eula_skip_v3 ? 'b' : 'a'; 397 file_name = file_name.replace('Hola-Setup', 'Hola-Installer'); 398 file_name = file_name.replace('.exe', exp_ver+'.exe'); 399 var exp_val = exp_ver=='b' ? 'true' : 'false'; 400 perr({id: 'www_exp_test_installer_eula_skip_v3.ev_01_download.val_' 401 +exp_val, info: {file_name: file_name, url: location.href}}); 402 } 403 if (experiment_init.ui_test.test_abexe1 !== undefined) 404 { 405 if (experiment_init.ui_test.test_abexe1 === true) 406 file_name = file_name.replace('Hola-Setup', 'Hola-Setup-abexe1'); 407 else if (experiment_init.ui_test.test_abexe1 === false) 408 file_name = file_name.replace('Hola-Setup', 'Hola-Setup-abexeoff'); 409 } 410 return file_name; 411}; 412 413var b = user_agent.guess_browser(); 414// XXX arik: simplify select_dl api and rm obsolete xxx_cws_plugin 415E.select_dl = function(xxx_cws_plugin, flow, premium){ 416 var os = user_agent.guess().os; 417 if (os=='android') 418 { 419 return flow=='accelerator' ? E.GDL.android_va : premium ? 420 E.GDL.android_premium : E.GDL.android; 421 } 422 if (os=='ios') 423 return E.GDL.ios; 424 if (os=='ps') 425 return E.GDL.ps; 426 if (os=='xbox') 427 return E.GDL.xbox; 428 if (b.browser=='firefox') 429 return E.GDL.firefox_signed; 430 if (b.browser=='chrome' && !!b.opera) 431 return E.GDL.opera; 432 if (b.browser=='chrome') 433 { 434 if (os=='windows') 435 return E.GDL.windows; 436 return E.GDL.chrome; 437 } 438 if (os=='macos') 439 return E.GDL.mac; 440 return E.GDL.windows; 441}; 442 443E.init_simple_download = function(){ 444 E.init_simple_download_by_class('detect-install2-vpn'); 445 E.init_simple_download_by_class('detect-install2-browser'); 446}; 447 448function mousedown_cb(evt){ 449 var el = evt.currentTarget; 450 var product = el.getAttribute('data-product'); 451 var source = el.getAttribute('data-source'); 452 ga_send('event', 'www_site_load', 'click_'+product, source); 453 perr({id: 'www_site_load_clicked', info: location.href, 454 product_type: product, source: source}); 455} 456 457E.init_simple_download_by_class = function(_class){ 458 var dl = E.select_dl(); 459 var tags = document.getElementsByClassName(_class); 460 var product = 'vpn'; 461 var tag; 462 for (var i=0; i<tags.length; i++) 463 { 464 tag = tags[i]; 465 if (tag.tagName!='A' 466 || tag.getAttribute('data-simple_download_initialized')) 467 { 468 continue; 469 } 470 tag.setAttribute('data-product', tag.getAttribute('data-product') 471 ||product); 472 tag.setAttribute('data-source', tag.getAttribute('data-source') 473 ||tag.getAttribute('id')||''); 474 tag.addEventListener('mousedown', mousedown_cb, false); 475 tag.href = dl.url; 476 tag.rel = dl.cls; 477 tag.setAttribute('data-simple_download_initialized', true); 478 } 479 init_reinstall_hover_behavior(_class); 480}; 481 482function init_reinstall_hover_behavior(_class){ 483 var reinstall_btn=document.querySelector('.link.'+_class); 484 var icon_el =document.querySelector('.reinstall-icon-container'); 485 if (!reinstall_btn||!icon_el) 486 return; 487 reinstall_btn.addEventListener('mouseenter', function(){ 488 icon_el.classList.add('hovered'); 489 }); 490 reinstall_btn.addEventListener('mouseleave', function(){ 491 icon_el.classList.remove('hovered'); 492 }); 493} 494 495E.uninit_simple_download = function(a){ 496 for (var i=0; i<a.length; i++) 497 { 498 a[i].removeEventListener('mousedown', mousedown_cb, false); 499 a[i].removeAttribute('data-simple_download_initialized'); 500 } 501}; 502 503E.redirect_to_store_needed = function(){ return b.browser=='chrome'; }; 504 505return E; 506});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.