7.diff (24908B)
1 diff --git a/README.md b/README.md 2 index 52bd897..dcee288 100644 3 --- a/README.md 4 +++ b/README.md 5 @@ -19,10 +19,10 @@ To install the plugin you need to: 6 7 ## Configuration with Email Password 8 9 -**IMPORTANT: DO NOT USE YOUR MAIN ACCOUNT! I AM NOT RESPONSIBLE IF YOU ACCOUNT GETS BANNED! USE AT YOUR OWN RISK** 10 +**IMPORTANT: DO NOT USE YOUR MAIN ACCOUNT! I AM NOT RESPONSIBLE IF YOUR ACCOUNT GETS BANNED! USE AT YOUR OWN RISK** 11 12 -*Note DON'T set cookies up when using emil/password* 13 -For using the Intel Screenbot you need to add the following to the config.json: 14 +*Note: DON'T set cookies up when using email/password*<br \><br \> 15 +For using the Intel Screenbot you need to add the following json-code to the config.json: 16 17 ``` 18 "intel_screenbot": { 19 @@ -34,8 +34,8 @@ For using the Intel Screenbot you need to add the following to the config.json: 20 } 21 ``` 22 23 -According to the official INSTALL Documention of the hangoutbot you will find the config.json in `/<username>/.local/share/hangupsbot/` 24 -(NOTE! add an comma behind the last element of the config.json and add it befor the outer element closes) 25 +According to the official INSTALL Documention of the hangoutbot you will find the config.json in `/<username>/.local/share/hangupsbot/` <br \> 26 +(NOTE! add an comma behind the last element of the config.json and add it before the outer element closes) 27 28 Also you need to add `intel_screenbot` to the plugins. 29 30 @@ -86,9 +86,15 @@ Also you need to add `intel_screenbot` to the plugins. 31 * If no `<url>` is supplied, use the default screenshot URL (or reply with an error if no URL is set) 32 * `z=` lets you change the zoomlevel of the map 33 34 +`/portalpic <url>` 35 +* Makes a screenshot of the Portalinfo of the defined portal. 36 + 37 +`/portalinfo <url>` 38 +* Gives you a text version of the most important Portal Information. (Pretty long!) 39 + 40 ## PhantomJS Installation 41 42 -Only tested: 43 +Only tested way to install: 44 45 ``` 46 wget https://cnpmjs.org/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 47 diff --git a/__init__.py b/__init__.py 48 index 50f1b24..8f83b12 100644 49 --- a/__init__.py 50 +++ b/__init__.py 51 @@ -9,14 +9,21 @@ 52 53 54 def _initialise(bot): 55 - plugins.register_user_command(["intel", "iitc", "active_iitcplugins"]) 56 + plugins.register_user_command(["intel", "iitc", "portalpic", "portalinfo", "active_iitcplugins"]) 57 plugins.register_admin_command(["setintel", "show_iitcplugins", "set_iitcplugins"]) 58 _get_iitc_plugins(bot) 59 60 61 @asyncio.coroutine 62 -def _open_file(name): 63 - return open(name, 'rb') 64 +def _open_file(name, otype): 65 + return open(name, otype) 66 + 67 +@asyncio.coroutine 68 +def readline(f): 69 + while True: 70 + data = f.readline() 71 + if data: 72 + return data 73 74 def _parse_onlineRepos(url, ext=''): 75 page = requests.get(url).text 76 @@ -78,7 +85,7 @@ def _get_lines(shell_command): 77 return p.returncode, output, True 78 79 @asyncio.coroutine 80 -def _screencap(url, args_filepath, filepath, filename, bot, event): 81 +def _screencap(url, args_filepath, filepath, filename, bot, event, arguments): 82 os.chmod(filepath, 0o666) 83 loop = asyncio.get_event_loop() 84 command = 'phantomjs hangupsbot/plugins/intel_screenbot/screencap.js "' + args_filepath + '"' 85 @@ -88,22 +95,30 @@ def _screencap(url, args_filepath, filepath, filename, bot, event): 86 87 # read the resulting file into a byte array 88 # yield from asyncio.sleep(10) 89 - file_resource = yield from _open_file(filepath) 90 - file_data = yield from loop.run_in_executor(None, file_resource.read) 91 - image_data = yield from loop.run_in_executor(None, io.BytesIO, file_data) 92 - if status: 93 - try: 94 - image_id = yield from bot._client.upload_image(image_data, filename=filename) 95 - yield from bot.coro_send_message(event.conv.id_, None, image_id=image_id) 96 - os.unlink(filepath) 97 - os.unlink(args_filepath) 98 - except Exception as e: 99 + if (arguments['screenshotfunction'] != 'portalinfoText'): 100 + file_resource = yield from _open_file(filepath, 'rb') 101 + file_data = yield from loop.run_in_executor(None, file_resource.read) 102 + image_data = yield from loop.run_in_executor(None, io.BytesIO, file_data) 103 + if status: 104 + try: 105 + image_id = yield from bot._client.upload_image(image_data, filename=filename) 106 + yield from bot.coro_send_message(event.conv.id_, None, image_id=image_id) 107 + os.unlink(filepath) 108 + os.unlink(args_filepath) 109 + except Exception as e: 110 + os.unlink(filepath) 111 + os.unlink(args_filepath) 112 + logger.exception("upload failed: {}".format(url)) 113 + logger.exception("exception: {}".format(e)) 114 + yield from bot.coro_send_message(event.conv_id, "<i>error uploading screenshot</i>") 115 + else: 116 + if status: 117 + response_file = yield from _open_file(arguments['portalinfoResponse'], 'r') 118 + response = yield from readline(response_file) 119 + yield from bot.coro_send_message(event.conv.id_, response.replace("'", "")) 120 os.unlink(filepath) 121 os.unlink(args_filepath) 122 - logger.exception("upload failed: {}".format(url)) 123 - logger.exception("exception: {}".format(e)) 124 - yield from bot.coro_send_message(event.conv_id, "<i>error uploading screenshot</i>") 125 - 126 + os.unlink(arguments['portalinfoResponse']) 127 128 def setintel(bot, event, *args): 129 """set url for current converation for the intel or iitc command. 130 @@ -121,7 +136,122 @@ def setintel(bot, event, *args): 131 html = "<i><b>{}</b> updated screenshot URL".format(event.user.full_name) 132 yield from bot.coro_send_message(event.conv, html) 133 134 +def portalpic(bot, event, *args): 135 + """get a screenshot of the portalInfo by URL.""" 136 + 137 + arguments = {} 138 139 + if args: 140 + if len(args) > 1: 141 + url = ' '.join(str(i) for i in args) 142 + else: 143 + url = args[0] 144 + if '"' in url: 145 + url = url.replace('"', '') 146 + else: 147 + html = "<i><b>{}</b> No Arguments provided".format(event.user.full_name) 148 + yield from bot.coro_send_message(event.conv, html) 149 + 150 + if bot.config.exists(["intel_screenbot", "email"]): 151 + if bot.config.exists(["intel_screenbot", "password"]): 152 + email = bot.config.get_by_path(["intel_screenbot", "email"]) 153 + password = bot.config.get_by_path(["intel_screenbot", "password"]) 154 + arguments['email'] = email 155 + arguments['password'] = password 156 + else: 157 + html = "<i><b>{}</b> No Intel password has been added to config. Unable to authenticate".format(event.user.full_name) 158 + yield from bot.coro_send_message(event.conv, html) 159 + else: 160 + html = "<i><b>{}</b> No Intel Email/password has been added to config. Unable to authenticate".format(event.user.full_name) 161 + yield from bot.coro_send_message(event.conv, html) 162 + 163 + if url is None: 164 + html = "<i><b>{}</b> No Portal URL has been set for screenshots.".format(event.user.full_name) 165 + yield from bot.coro_send_message(event.conv, html) 166 + else: 167 + if re.match(r'(http(s)?:\/\/)', url): 168 + yield from bot.coro_send_message(event.conv_id, "<i>Portal Info requested, please wait...</i>") 169 + filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name 170 + filename = filepath.split('/', filepath.count('/'))[-1] 171 + args_filepath = tempfile.NamedTemporaryFile(prefix="args_{}".format(event.conv_id), suffix=".json", delete=False).name 172 + 173 + arguments['url'] = url 174 + arguments['filepath'] = filepath 175 + arguments['screenshotfunction'] = "portalinfoScreen" 176 + 177 + with open(args_filepath, 'w') as out: 178 + out.write(json.dumps(arguments)) 179 + 180 + try: 181 + loop = asyncio.get_event_loop() 182 + image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event) 183 + except Exception as e: 184 + yield from bot.coro_send_message(event.conv_id, "<i>error getting screenshot</i>") 185 + logger.exception("screencap failed".format(url)) 186 + return 187 + else: 188 + html = "<i><b>{}</b> No URL found in Arguments".format(event.user.full_name) 189 + yield from bot.coro_send_message(event.conv, html) 190 + 191 +def portalinfo(bot, event, *args): 192 + """get a of the portalInfo by URL.""" 193 + 194 + arguments = {} 195 + 196 + if args: 197 + if len(args) > 1: 198 + url = ' '.join(str(i) for i in args) 199 + else: 200 + url = args[0] 201 + if '"' in url: 202 + url = url.replace('"', '') 203 + else: 204 + html = "<i><b>{}</b> No Arguments provided".format(event.user.full_name) 205 + yield from bot.coro_send_message(event.conv, html) 206 + 207 + if bot.config.exists(["intel_screenbot", "email"]): 208 + if bot.config.exists(["intel_screenbot", "password"]): 209 + email = bot.config.get_by_path(["intel_screenbot", "email"]) 210 + password = bot.config.get_by_path(["intel_screenbot", "password"]) 211 + arguments['email'] = email 212 + arguments['password'] = password 213 + else: 214 + html = "<i><b>{}</b> No Intel password has been added to config. Unable to authenticate".format(event.user.full_name) 215 + yield from bot.coro_send_message(event.conv, html) 216 + else: 217 + html = "<i><b>{}</b> No Intel Email/password has been added to config. Unable to authenticate".format(event.user.full_name) 218 + yield from bot.coro_send_message(event.conv, html) 219 + 220 + if url is None: 221 + html = "<i><b>{}</b> No Portal URL has been set for portal Info.".format(event.user.full_name) 222 + yield from bot.coro_send_message(event.conv, html) 223 + else: 224 + if re.match(r'(http(s)?:\/\/)', url): 225 + yield from bot.coro_send_message(event.conv_id, "<i>Portal Info requested, please wait...</i>") 226 + filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name 227 + portalinfoResponse = tempfile.NamedTemporaryFile(prefix="response_{}".format(event.conv_id), delete=False).name 228 + filename = filepath.split('/', filepath.count('/'))[-1] 229 + args_filepath = tempfile.NamedTemporaryFile(prefix="args_{}".format(event.conv_id), suffix=".json", delete=False).name 230 + 231 + arguments['url'] = url 232 + arguments['filepath'] = filepath 233 + arguments['screenshotfunction'] = "portalinfoText" 234 + arguments['portalinfoResponse'] = portalinfoResponse 235 + 236 + with open(args_filepath, 'w') as out: 237 + out.write(json.dumps(arguments)) 238 + 239 + try: 240 + loop = asyncio.get_event_loop() 241 + image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event, arguments) 242 + except Exception as e: 243 + yield from bot.coro_send_message(event.conv_id, "<i>error getting screenshot</i>") 244 + logger.exception("screencap failed".format(url)) 245 + return 246 + else: 247 + html = "<i><b>{}</b> No URL found in Arguments".format(event.user.full_name) 248 + yield from bot.coro_send_message(event.conv, html) 249 + 250 def intel(bot, event, *args): 251 """get a screenshot of a search term or intel URL or the default intel URL of the hangout.""" 252 253 @@ -195,13 +325,14 @@ def intel(bot, event, *args): 254 arguments['url'] = url 255 arguments['filepath'] = filepath 256 arguments['maptype'] = "intel" 257 + arguments['screenshotfunction'] = "map" 258 259 with open(args_filepath, 'w') as out: 260 out.write(json.dumps(arguments)) 261 262 try: 263 loop = asyncio.get_event_loop() 264 - image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event) 265 + image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event, arguments) 266 except Exception as e: 267 yield from bot.coro_send_message(event.conv_id, "<i>error getting screenshot</i>") 268 logger.exception("screencap failed".format(url)) 269 @@ -291,13 +422,14 @@ def iitc(bot, event, *args): 270 arguments['url'] = url 271 arguments['filepath'] = filepath 272 arguments['maptype'] = "iitc" 273 + arguments['screenshotfunction'] = "map" 274 275 with open(args_filepath, 'w') as out: 276 out.write(json.dumps(arguments)) 277 278 try: 279 loop = asyncio.get_event_loop() 280 - image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event) 281 + image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event, arguments) 282 except Exception as e: 283 yield from bot.coro_send_message(event.conv_id, "<i>error getting screenshot</i>") 284 logger.exception("screencap failed".format(url)) 285 diff --git a/screencap.js b/screencap.js 286 index 0a6eb83..364e01f 100644 287 --- a/screencap.js 288 +++ b/screencap.js 289 @@ -22,6 +22,10 @@ if (args.length === 1) { 290 var filepath = arguments['filepath'] 291 var user = arguments['email'] 292 var pass = arguments['password'] 293 + var screenshotfunction = arguments['screenshotfunction'] 294 + if(screenshotfunction == "portalinfoText"){ 295 + var portalinfoResponse = arguments['portalinfoResponse'] 296 + } 297 } 298 299 function loadCookies(callback) { 300 @@ -171,11 +175,220 @@ function login(l, p, url) { 301 }); 302 } 303 304 +function map(search){ 305 + setTimeout(function() { 306 + if (search != 'nix') { 307 + searchfunc(search); 308 + } 309 + waitFor({ 310 + timeout: 240000, 311 + check: function () { 312 + return page.evaluate(function(zoomlevel) { 313 + if (document.querySelector('.map').textContent.indexOf('done') != -1) { 314 + return true; 315 + }else{ 316 + console.log('generateFakeOutput') 317 + return false; 318 + } 319 + }, zoomlevel); 320 + }, 321 + success: function () { 322 + var startTime = new Date().getTime(); 323 + var interval = setInterval(function(){ 324 + if(new Date().getTime() - startTime > 5000){ 325 + hideDebris(); 326 + prepare('1280', '720'); 327 + main(); 328 + clearInterval(interval); 329 + return; 330 + } 331 + console.log('generateFakeOutput') 332 + }, 1000); 333 + }, 334 + error: function () { 335 + var startTime = new Date().getTime(); 336 + var interval = setInterval(function(){ 337 + if(new Date().getTime() - startTime > 5000){ 338 + hideDebris(); 339 + prepare('1280', '720'); 340 + main(); 341 + clearInterval(interval); 342 + return; 343 + } 344 + console.log('generateFakeOutput') 345 + }, 1000); 346 + } 347 + }); 348 + }, "1000"); 349 +} 350 + 351 +function portalinfoScreen(){ 352 + setTimeout(function() { 353 + waitFor({ 354 + timeout: 240000, 355 + check: function () { 356 + return page.evaluate(function() { 357 + if (document.querySelector('.map').textContent.indexOf('done') != -1) { 358 + return true; 359 + }else{ 360 + console.log('generateFakeOutput') 361 + return false; 362 + } 363 + }); 364 + }, 365 + success: function () { 366 + var clipRect = page.evaluate(function(){ 367 + return document.querySelector('#sidebar').getBoundingClientRect(); 368 + }); 369 + page.evaluate(function(){ 370 + document.querySelector('#playerstat').style.display = 'none'; 371 + document.querySelector('#searchwrapper').style.display = 'none'; 372 + document.querySelector('#redeem').style.display = 'none'; 373 + }); 374 + setTimeout(function() { 375 + var elementHeight = page.evaluate(function(){ 376 + return $("#sidebar").height(); 377 + }); 378 + 379 + page.clipRect = { 380 + top: clipRect.top, 381 + left: clipRect.left, 382 + width: clipRect.width, 383 + height: elementHeight 384 + } 385 + setTimeout(function() {s(filepath)}, "1000"); 386 + }, "2000"); 387 + }, 388 + error: function () { 389 + var clipRect = page.evaluate(function(){ 390 + return document.querySelector('#sidebar').getBoundingClientRect(); 391 + }); 392 + 393 + setTimeout(function() { 394 + var elementHeight = page.evaluate(function(){ 395 + return $("#sidebar").height(); 396 + }); 397 + 398 + page.clipRect = { 399 + top: clipRect.top, 400 + left: clipRect.left, 401 + width: clipRect.width, 402 + height: elementHeight 403 + } 404 + setTimeout(function() {s(filepath)}, "1000"); 405 + }, "2000"); 406 + } 407 + }); 408 + }, "1000"); 409 +} 410 + 411 +function portalinfoText(){ 412 + setTimeout(function() { 413 + waitFor({ 414 + timeout: 240000, 415 + check: function () { 416 + return page.evaluate(function() { 417 + if ((document.querySelector('.map').textContent.indexOf('done') != -1) || (document.getElementById("resodetails").rows[0])) { 418 + return true; 419 + }else{ 420 + console.log('generateFakeOutput') 421 + return false; 422 + } 423 + }); 424 + }, 425 + success: function () { 426 + var PortalName = page.evaluate(function(){ 427 + return document.getElementById("portaldetails").getElementsByClassName("title")[0].innerHTML; 428 + }); 429 + var reso1 = page.evaluate(function(){ 430 + return document.getElementById("resodetails").rows[0].cells[1].firstElementChild.getAttribute("title"); 431 + }); 432 + var reso2 = page.evaluate(function(){ 433 + return document.getElementById("resodetails").rows[0].cells[2].firstElementChild.getAttribute("title"); 434 + }); 435 + var reso3 = page.evaluate(function(){ 436 + return document.getElementById("resodetails").rows[1].cells[1].firstElementChild.getAttribute("title"); 437 + }); 438 + var reso4 = page.evaluate(function(){ 439 + return document.getElementById("resodetails").rows[1].cells[2].firstElementChild.getAttribute("title"); 440 + }); 441 + var reso5 = page.evaluate(function(){ 442 + return document.getElementById("resodetails").rows[2].cells[1].firstElementChild.getAttribute("title"); 443 + }); 444 + var reso6 = page.evaluate(function(){ 445 + return document.getElementById("resodetails").rows[2].cells[2].firstElementChild.getAttribute("title"); 446 + }); 447 + var reso7 = page.evaluate(function(){ 448 + return document.getElementById("resodetails").rows[3].cells[1].firstElementChild.getAttribute("title"); 449 + }); 450 + var reso8 = page.evaluate(function(){ 451 + return document.getElementById("resodetails").rows[3].cells[2].firstElementChild.getAttribute("title"); 452 + }); 453 + var text = PortalName.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><br /><b>Resonator 1:</b><br />" + reso1.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 2:</b><br />" + reso2.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 3:</b><br />" + reso3.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 4:</b><br />" + reso4.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 5:</b><br />" + reso5.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 6:</b><br />" + reso6.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 7:</b><br />" + reso7.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 8:</b><br />" + reso8.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') 454 + console.log(text) 455 + fs.write(portalinfoResponse, text, 'w'); 456 + var startTime = new Date().getTime(); 457 + var startTime = new Date().getTime(); 458 + var interval = setInterval(function(){ 459 + if(new Date().getTime() - startTime > 5000){ 460 + clearInterval(interval); 461 + phantom.exit(0); 462 + return; 463 + } 464 + console.log('doSomeOutput') 465 + }, 1000); 466 + }, 467 + error: function () { 468 + var PortalName = page.evaluate(function(){ 469 + return document.getElementById("portaldetails").getElementsByClassName("title")[0].innerHTML; 470 + }); 471 + var reso1 = page.evaluate(function(){ 472 + return document.getElementById("resodetails").rows[0].cells[1].firstElementChild.getAttribute("title"); 473 + }); 474 + var reso2 = page.evaluate(function(){ 475 + return document.getElementById("resodetails").rows[0].cells[2].firstElementChild.getAttribute("title"); 476 + }); 477 + var reso3 = page.evaluate(function(){ 478 + return document.getElementById("resodetails").rows[1].cells[1].firstElementChild.getAttribute("title"); 479 + }); 480 + var reso4 = page.evaluate(function(){ 481 + return document.getElementById("resodetails").rows[1].cells[2].firstElementChild.getAttribute("title"); 482 + }); 483 + var reso5 = page.evaluate(function(){ 484 + return document.getElementById("resodetails").rows[2].cells[1].firstElementChild.getAttribute("title"); 485 + }); 486 + var reso6 = page.evaluate(function(){ 487 + return document.getElementById("resodetails").rows[2].cells[2].firstElementChild.getAttribute("title"); 488 + }); 489 + var reso7 = page.evaluate(function(){ 490 + return document.getElementById("resodetails").rows[3].cells[1].firstElementChild.getAttribute("title"); 491 + }); 492 + var reso8 = page.evaluate(function(){ 493 + return document.getElementById("resodetails").rows[3].cells[2].firstElementChild.getAttribute("title"); 494 + }); 495 + var text = PortalName.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><br /><b>Resonator 1:</b><br />" + reso1.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 2:</b><br />" + reso2.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 3:</b><br />" + reso3.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 4:</b><br />" + reso4.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 5:</b><br />" + reso5.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 6:</b><br />" + reso6.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 7:</b><br />" + reso7.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') + "<br /><b>Resonator 8:</b><br />" + reso8.replace(/(?:\r\n|\r|\n)/g, '<br />').replace(/(?:\t)/g, ' ') 496 + console.log(text) 497 + fs.write(portalinfoResponse, text.replace(/'/g, ''), 'w'); 498 + var startTime = new Date().getTime(); 499 + var startTime = new Date().getTime(); 500 + var interval = setInterval(function(){ 501 + if(new Date().getTime() - startTime > 5000){ 502 + clearInterval(interval); 503 + phantom.exit(0); 504 + return; 505 + } 506 + console.log('doSomeOutput') 507 + }, 1000); 508 + } 509 + }); 510 + }, "1000"); 511 +} 512 + 513 function afterLogin(url, search, mode) { 514 page.viewportSize = { width: '1280', height: '720' }; 515 page.open(url, function(status) { 516 console.log(url) 517 - if (status !== 'success') {console.log('unable to connect to remote server afterPlainLogin'); phantom.exit(0);} 518 + if (status !== 'success') {console.log('unable to connect to remote server after Login'); phantom.exit(0);} 519 if (!isSignedIn()) { 520 if(mode =="cookie"){ 521 if(fs.exists(cookiespath)) { 522 @@ -190,50 +403,13 @@ function afterLogin(url, search, mode) { 523 storeCookies(); 524 } 525 setupIITC() 526 - setTimeout(function() { 527 - if (search != 'nix') { 528 - searchfunc(search); 529 - } 530 - waitFor({ 531 - timeout: 240000, 532 - check: function () { 533 - return page.evaluate(function(zoomlevel) { 534 - if (document.querySelector('.map').textContent.indexOf('done') != -1) { 535 - return true; 536 - }else{ 537 - console.log('generateFakeOutput') 538 - return false; 539 - } 540 - }, zoomlevel); 541 - }, 542 - success: function () { 543 - var startTime = new Date().getTime(); 544 - var interval = setInterval(function(){ 545 - if(new Date().getTime() - startTime > 5000){ 546 - hideDebris(); 547 - prepare('1280', '720'); 548 - main(); 549 - clearInterval(interval); 550 - return; 551 - } 552 - console.log('generateFakeOutput') 553 - }, 1000); 554 - }, 555 - error: function () { 556 - var startTime = new Date().getTime(); 557 - var interval = setInterval(function(){ 558 - if(new Date().getTime() - startTime > 5000){ 559 - hideDebris(); 560 - prepare('1280', '720'); 561 - main(); 562 - clearInterval(interval); 563 - return; 564 - } 565 - console.log('generateFakeOutput') 566 - }, 1000); 567 - } 568 - }); 569 - }, "1000"); 570 + if(screenshotfunction == "map"){ 571 + map(search); 572 + }else if (screenshotfunction == "portalinfoScreen"){ 573 + portalinfoScreen(); 574 + }else if (screenshotfunction == "portalinfoText"){ 575 + portalinfoText(); 576 + } 577 }, "1000"); 578 }); 579 }