intel-screenbot.meta

Issues/PRs archive for MTRNord/intel_screenbot
git clone git://archive.git.mtrnord.blog/MTRNord/intel-screenbot.meta.git
Log | Files | Refs

5.diff (30695B)


      1 diff --git a/__init__.py b/__init__.py
      2 index dfdebf0..e0bc4bb 100644
      3 --- a/__init__.py
      4 +++ b/__init__.py
      5 @@ -1,13 +1,9 @@
      6  from bs4 import BeautifulSoup
      7  import requests
      8  import json
      9 -import asyncio, io, logging, os, re, time, tempfile
     10 -import subprocess
     11 +import asyncio, io, logging, os, tempfile
     12  import plugins
     13  import re
     14 -from asyncio import subprocess
     15 -from shutil import move
     16 -from os import remove, close
     17  
     18  logger = logging.getLogger(__name__)
     19  
     20 @@ -20,13 +16,9 @@ def _initialise(bot):
     21  
     22  @asyncio.coroutine
     23  def _open_file(name):
     24 -    logger.debug("opening screenshot file: {}".format(name))
     25 -    statinfo = os.stat(name)
     26 -    logger.info(statinfo.st_size)
     27      return open(name, 'rb')
     28  
     29  def _parse_onlineRepos(url, ext=''):
     30 -    logger.debug("parsing github or gitlab or http(s)")
     31      page = requests.get(url).text
     32      if 'gitlab.com' in url:
     33          files = []
     34 @@ -96,7 +88,6 @@ def _screencap(url, args_filepath, filepath, filename, bot, event):
     35  
     36      # read the resulting file into a byte array
     37      # yield from asyncio.sleep(10)
     38 -    logger.info(filepath)
     39      file_resource = yield from _open_file(filepath)
     40      file_data = yield from loop.run_in_executor(None, file_resource.read)
     41      image_data = yield from loop.run_in_executor(None, io.BytesIO, file_data)
     42 @@ -107,6 +98,8 @@ def _screencap(url, args_filepath, filepath, filename, bot, event):
     43              os.unlink(filepath)
     44              os.unlink(args_filepath)
     45          except Exception as e:
     46 +            os.unlink(filepath)
     47 +            os.unlink(args_filepath)
     48              logger.exception("upload failed: {}".format(url))
     49              logger.exception("exception: {}".format(e))
     50              yield from bot.coro_send_message(event.conv_id, "<i>error uploading screenshot</i>")
     51 @@ -114,8 +107,8 @@ def _screencap(url, args_filepath, filepath, filename, bot, event):
     52  
     53  def setintel(bot, event, *args):
     54      """set url for current converation for the intel or iitc command.
     55 -    use /bot clearintel to clear the previous url before setting a new one.
     56 -    """
     57 +    use /bot clearintel to clear the previous url before setting a new one."""
     58 +    
     59      url = bot.conversation_memory_get(event.conv_id, 'IntelURL')
     60      if url is None:
     61          bot.conversation_memory_set(event.conv_id, 'IntelURL', ''.join(args))
     62 @@ -130,8 +123,7 @@ def setintel(bot, event, *args):
     63  
     64  
     65  def intel(bot, event, *args):
     66 -    """get a screenshot of a search term or intel URL or the default intel URL of the hangout.
     67 -    """
     68 +    """get a screenshot of a search term or intel URL or the default intel URL of the hangout."""
     69  
     70      arguments = {}
     71  
     72 @@ -143,7 +135,10 @@ def intel(bot, event, *args):
     73          if '"' in url:
     74              url = url.replace('"', '')
     75      else:
     76 -        url = bot.conversation_memory_get(event.conv_id, 'IntelURL')
     77 +        try:
     78 +            url = bot.conversation_memory_get(event.conv_id, 'IntelURL')
     79 +        except:
     80 +            url = 'https://www.ingress.com/intel'
     81  
     82      if bot.config.exists(["intel_screenbot", "email"]):
     83          if bot.config.exists(["intel_screenbot", "password"]):
     84 @@ -175,7 +170,7 @@ def intel(bot, event, *args):
     85                  if zoomlevel.isdigit():
     86                      yield from bot.coro_send_message(event.conv_id, "<i>intel map at zoom level "+ zoomlevel + " requested, please wait...</i>")
     87              else:
     88 -                yield from bot.coro_send_message(event.conv_id, "<i>intel map at last zoom level requested, please wait...</i>")
     89 +                yield from bot.coro_send_message(event.conv_id, "<i>intel map requested, please wait...</i>")
     90          else:
     91              search = url
     92              zoomParameter = re.search(r"(?<=z=)", url, re.IGNORECASE)
     93 @@ -186,17 +181,15 @@ def intel(bot, event, *args):
     94                  zoomlevel = zoomlevel_raw.group()
     95                  search = search.replace("z={}".format(zoomlevel),"")
     96                  if zoomlevel.isdigit():
     97 -                    yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting at zoom level "+ zoomlevel + " as requested, please wait...</i>")
     98 +                    yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on intel map and screenshooting at zoom level "+ zoomlevel + " as requested, please wait...</i>")
     99                      arguments['zoomlevel'] = str(zoomlevel)
    100              else:
    101 -                yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting as requested, please wait...</i>")
    102 +                yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on intel map and screenshooting as requested, please wait...</i>")
    103              url = 'https://www.ingress.com/intel'
    104  
    105          filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
    106          filename = filepath.split('/', filepath.count('/'))[-1]
    107          args_filepath = tempfile.NamedTemporaryFile(prefix="args_{}".format(event.conv_id), suffix=".json", delete=False).name
    108 -        logger.debug("temporary screenshot file: {}".format(filepath))
    109 -        logger.debug("temporary args file: {}".format(args_filepath))
    110  
    111          arguments['search'] = search
    112          arguments['url'] = url
    113 @@ -205,8 +198,7 @@ def intel(bot, event, *args):
    114  
    115          with open(args_filepath, 'w') as out:
    116              out.write(json.dumps(arguments))
    117 -
    118 -
    119 +            
    120          try:
    121              loop = asyncio.get_event_loop()
    122              image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event)
    123 @@ -217,8 +209,7 @@ def intel(bot, event, *args):
    124  
    125  
    126  def iitc(bot, event, *args):
    127 -    """get a screenshot of a search term or intel URL or the default intel URL of the hangout.
    128 -    """
    129 +    """get a screenshot of a search term or intel URL or the default intel URL of the hangout."""
    130  
    131      arguments = {}
    132  
    133 @@ -260,9 +251,9 @@ def iitc(bot, event, *args):
    134                  zoomlevel_clean = zoomlevel_raw.group()
    135                  zoomlevel = zoomlevel_clean[3:][:2]
    136                  if zoomlevel.isdigit():
    137 -                    yield from bot.coro_send_message(event.conv_id, "<i>intel map at zoom level "+ zoomlevel + " requested, please wait...</i>")
    138 +                    yield from bot.coro_send_message(event.conv_id, "<i>iitc map at zoom level "+ zoomlevel + " requested, please wait...</i>")
    139              else:
    140 -                yield from bot.coro_send_message(event.conv_id, "<i>intel map at last zoom level requested, please wait...</i>")
    141 +                yield from bot.coro_send_message(event.conv_id, "<i>iitc map requested, please wait...</i>")
    142          else:
    143              search = url
    144              zoomParameter = re.search(r"(?<=z=)", url, re.IGNORECASE)
    145 @@ -273,10 +264,10 @@ def iitc(bot, event, *args):
    146                  zoomlevel = zoomlevel_raw.group()
    147                  search = search.replace("z={}".format(zoomlevel),"")
    148                  if zoomlevel.isdigit():
    149 -                    yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting at zoom level "+ zoomlevel + " as requested, please wait...</i>")
    150 +                    yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on iitc map and screenshooting it at zoom level "+ zoomlevel + " as requested, please wait...</i>")
    151                      arguments['zoomlevel'] = str(zoomlevel)
    152              else:
    153 -                yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting as requested, please wait...</i>")
    154 +                yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on iitc map and and screenshooting it as requested, please wait...</i>")
    155              url = 'https://www.ingress.com/intel'
    156  
    157          filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
    158 @@ -313,6 +304,7 @@ def iitc(bot, event, *args):
    159              return
    160  
    161  def show_iitcplugins(bot, event, *args):
    162 +    """Shows all available iitc Plugins."""
    163      if bot.memory.exists(["iitc_plugins"]):
    164          plugin_names = []
    165          for plugin_objects in bot.memory.get_by_path(["iitc_plugins"]):
    166 @@ -322,6 +314,7 @@ def show_iitcplugins(bot, event, *args):
    167          yield from bot.coro_send_to_user_and_conversation(event.user.id_.chat_id, event.conv_id, "<i><b>IITC Plugins:</b><br> {}</i>".format(', <br>'.join(str(i) for i in plugin_names)), _("<i><b>{}</b>, I've sent you the plugins ;)</i>").format(event.user.full_name))
    168  
    169  def set_iitcplugins(bot, event, *args):
    170 +    """sets the activated iitc plugins for a hangout."""
    171      if not bot.conversation_memory_get(event.conv_id, 'iitc_plugins') is None:
    172          bot.conversation_memory_set(event.conv_id, 'iitc_plugins', None)
    173          bot.conversation_memory_set(event.conv_id, 'iitc_plugins', ', '.join(args))
    174 @@ -333,10 +326,10 @@ def set_iitcplugins(bot, event, *args):
    175          yield from bot.coro_send_message(event.conv, html)
    176  
    177  def active_iitcplugins(bot, event, *args):
    178 +    """shows the activated iitc plugins for a hangout."""
    179      if bot.conversation_memory_get(event.conv_id, 'iitc_plugins') is None:
    180          html = "<i><b>{}</b> no active IITC Plugins for this conversation".format(event.user.full_name)
    181          yield from bot.coro_send_message(event.conv, html)
    182 -
    183      else:
    184          plugins = bot.conversation_memory_get(event.conv_id, 'iitc_plugins')
    185          html = "<i><b>{}</b> plugins for this conversation: {}<br />".format(event.user.full_name, plugins)
    186 diff --git a/screencap.js b/screencap.js
    187 index 30f8030..0b34349 100644
    188 --- a/screencap.js
    189 +++ b/screencap.js
    190 @@ -23,20 +23,6 @@ if (args.length === 1) {
    191    var user = arguments['email']
    192    var pass = arguments['password']
    193  }
    194 -function quit() {
    195 -  phantom.exit(0);
    196 -}
    197 -
    198 -loadCookies(function() {
    199 -  if (config.SACSID == undefined || config.SACSID == '') {
    200 -    firePlainLogin(user, pass, url);
    201 -  } else {
    202 -    addCookies(config.SACSID, config.CSRF);
    203 -    console.log('Using cookies to log in');
    204 -    afterCookieLogin(url, search);
    205 -  }
    206 -});
    207 -
    208  
    209  function loadCookies(callback) {
    210    if(fs.exists(cookiespath)) {
    211 @@ -58,6 +44,45 @@ function loadCookies(callback) {
    212    callback();
    213  }
    214  
    215 +function addCookies(sacsid, csrf) {
    216 +  phantom.addCookie({
    217 +    name: 'SACSID',
    218 +    value: sacsid,
    219 +    domain: 'www.ingress.com',
    220 +    path: '/',
    221 +    httponly: true,
    222 +    secure: true
    223 +  });
    224 +  phantom.addCookie({
    225 +    name: 'csrftoken',
    226 +    value: csrf,
    227 +    domain: 'www.ingress.com',
    228 +    path: '/'
    229 +  });
    230 +}
    231 +
    232 +loadCookies(function() {
    233 +  if (config.SACSID == undefined || config.SACSID == '') {
    234 +    firePlainLogin(user, pass, url);
    235 +  } else {
    236 +    addCookies(config.SACSID, config.CSRF);
    237 +    afterLogin(url, search, "cookie");
    238 +  }
    239 +});
    240 +
    241 +function waitFor ($config) {
    242 +    $config._start = $config._start || new Date();
    243 +    if ($config.timeout && new Date - $config._start > $config.timeout) {
    244 +        if ($config.error) $config.error();
    245 +        return;
    246 +    }
    247 +    if ($config.check()) {
    248 +        return $config.success();
    249 +    }
    250 +    setTimeout(waitFor, $config.interval || 0, $config);
    251 +}
    252 +
    253 +
    254  function isSignedIn() {
    255    return page.evaluate(function() {
    256      return document.getElementsByTagName('a')[0].innerText.trim() !== 'Sign in';
    257 @@ -77,7 +102,7 @@ function firePlainLogin(user, pass, url) {
    258      page.evaluate(function () {
    259        localStorage.clear()
    260      });
    261 -    if (status !== 'success') {console.log("Login ERROR"); quit();}
    262 +    if (status !== 'success') {console.log("Login ERROR"); phantom.exit(0);}
    263      var link = 'https://www.google.com/accounts/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://www.ingress.com/intel&ltmpl='
    264      page.open(link, function () {
    265        login(user, pass, url);
    266 @@ -123,7 +148,7 @@ function login(l, p, url) {
    267                  window.setTimeout(function () {
    268                      if (page.url.substring(0,40) === 'https://accounts.google.com/ServiceLogin') {
    269                          console.log("login failed: wrong email and/or password")
    270 -                        quit()
    271 +                        phantom.exit(0);
    272                      }
    273  
    274                      if (page.url.substring(0,40) === 'https://appengine.google.com/_ah/loginfo') {
    275 @@ -136,114 +161,83 @@ function login(l, p, url) {
    276                      if (page.url.substring(0,44) === 'https://accounts.google.com/signin/challenge') {
    277                          twostep = system.stdin.readLine();
    278                      }
    279 -                    window.setTimeout(afterPlainLogin(url, search), loginTimeout);
    280 +                    window.setTimeout(afterLogin(url, search, "plain"), loginTimeout);
    281                  }, loginTimeout)
    282              }, loginTimeout / 10);
    283          },
    284          error: function () {
    285 -            console.log("error waitingFor loginform")
    286 -            quit();
    287 +            phantom.exit(0);
    288          }
    289      });
    290  }
    291  
    292 -function afterPlainLogin(url, search) {
    293 +function afterLogin(url, search, mode) {
    294    page.viewportSize = { width: '1280', height: '720' };
    295    page.open(url, function(status) {
    296      console.log(url)
    297 -    if (status !== 'success') {console.log('unable to connect to remote server afterPlainLogin'); quit()}
    298 +    if (status !== 'success') {console.log('unable to connect to remote server afterPlainLogin'); phantom.exit(0);}
    299      if (!isSignedIn()) {
    300 +      if(mode =="cookie"){
    301 +        if(fs.exists(cookiespath)) {
    302 +          fs.remove(cookiespath);
    303 +        }
    304 +      }
    305        console.log("not logged in")
    306        quit();
    307      }
    308      setTimeout(function() {
    309 -      storeCookies();
    310 -		  setupIITC()
    311 -        setTimeout(function() {
    312 -          setTimeout(function() {
    313 -            if (search != 'nix') {
    314 -              searchfunc(search);
    315 -            }
    316 -          }, 1000);
    317 -            waitFor({
    318 -                timeout: 240000,
    319 -                check: function () {
    320 -                  return page.evaluate(function(zoomlevel) {
    321 -                    if (typeof zoomlevel === 'undefined' || zoomlevel === null) {
    322 -                      window.map.setZoom(zoomlevel,animate=false)
    323 -                    }
    324 -                    if (document.querySelector('.map').textContent.indexOf('done') != -1) {
    325 -                        return true;
    326 -                    }else{
    327 -                        console.log('generateFakeOutput')
    328 -                        return false;
    329 -                    }
    330 -                  }, zoomlevel);
    331 -                },
    332 -                success: function () {
    333 -                  var startTime = new Date().getTime();
    334 -                  var interval = setInterval(function(){
    335 -                    if(new Date().getTime() - startTime > 5000){
    336 -                      hideDebris();
    337 -                      prepare('1280', '720');
    338 -                      main();
    339 -                      clearInterval(interval);
    340 -                      return;
    341 -                    }
    342 -                    console.log('generateFakeOutput')
    343 -                  }, 1000);
    344 -                },
    345 -                error: function () {
    346 -                  var startTime = new Date().getTime();
    347 -                  var interval = setInterval(function(){
    348 -                    if(new Date().getTime() - startTime > 5000){
    349 -                      hideDebris();
    350 -                      prepare('1280', '720');
    351 -                      main();
    352 -                      clearInterval(interval);
    353 -                      return;
    354 -                    }
    355 -                    console.log('generateFakeOutput')
    356 -                  }, 1000);
    357 -                }
    358 -            });
    359 -        }, "1000");
    360 +      if(mode == "plain"){
    361 +        storeCookies();
    362 +      }
    363 +      setupIITC()
    364 +      setTimeout(function() {
    365 +        if (search != 'nix') {
    366 +          searchfunc(search);
    367 +        }
    368 +        waitFor({
    369 +          timeout: 240000,
    370 +          check: function () {
    371 +            return page.evaluate(function(zoomlevel) {
    372 +              if (document.querySelector('.map').textContent.indexOf('done') != -1) {
    373 +                return true;
    374 +              }else{
    375 +                console.log('generateFakeOutput')
    376 +                return false;
    377 +              }
    378 +            }, zoomlevel);
    379 +          },
    380 +          success: function () {
    381 +            var startTime = new Date().getTime();
    382 +            var interval = setInterval(function(){
    383 +              if(new Date().getTime() - startTime > 5000){
    384 +                hideDebris();
    385 +                prepare('1280', '720');
    386 +                main();
    387 +                clearInterval(interval);
    388 +                return;
    389 +              }
    390 +              console.log('generateFakeOutput')
    391 +            }, 1000);
    392 +          },
    393 +          error: function () {
    394 +            var startTime = new Date().getTime();
    395 +            var interval = setInterval(function(){
    396 +              if(new Date().getTime() - startTime > 5000){
    397 +                hideDebris();
    398 +                prepare('1280', '720');
    399 +                main();
    400 +                clearInterval(interval);
    401 +                return;
    402 +              }
    403 +              console.log('generateFakeOutput')
    404 +            }, 1000);
    405 +          }
    406 +        });
    407 +      }, "1000");
    408      }, "1000");
    409    });
    410  }
    411  
    412 -
    413 -
    414 -function addCookies(sacsid, csrf) {
    415 -  phantom.addCookie({
    416 -    name: 'SACSID',
    417 -    value: sacsid,
    418 -    domain: 'www.ingress.com',
    419 -    path: '/',
    420 -    httponly: true,
    421 -    secure: true
    422 -  });
    423 -  phantom.addCookie({
    424 -    name: 'csrftoken',
    425 -    value: csrf,
    426 -    domain: 'www.ingress.com',
    427 -    path: '/'
    428 -  });
    429 -}
    430 -
    431 -
    432 -function waitFor ($config) {
    433 -    $config._start = $config._start || new Date();
    434 -    if ($config.timeout && new Date - $config._start > $config.timeout) {
    435 -        if ($config.error) $config.error();
    436 -        return;
    437 -    }
    438 -    if ($config.check()) {
    439 -        return $config.success();
    440 -    }
    441 -    setTimeout(waitFor, $config.interval || 0, $config);
    442 -}
    443 -
    444  function loadIitcPlugin(src) {
    445    page.evaluate(function(src) {
    446      var script = document.createElement('script');
    447 @@ -257,82 +251,21 @@ function loadLocalIitcPlugin(src) {
    448      page.injectJs(src)
    449  }
    450  
    451 -function afterCookieLogin(url, search) {
    452 -  page.viewportSize = { width: '1280', height: '720' };
    453 -  page.open(url, function(status) {
    454 -    if (status !== 'success') {quit('unable to connect to remote server')}
    455 -    if(!isSignedIn()) {
    456 -      if(fs.exists(cookiespath)) {
    457 -        fs.remove(cookiespath);
    458 -      }
    459 -      quit('Cookies are obsolete. Update your config file.');
    460 -    }
    461 -    setTimeout(function() {
    462 -    	setupIITC()
    463 -        setTimeout(function() {
    464 -          if (search != "nix") {
    465 -            searchfunc(search);
    466 -          }
    467 -            waitFor({
    468 -                timeout: 240000,
    469 -                check: function () {
    470 -                  return page.evaluate(function() {
    471 -                    if (document.querySelector('.map').textContent.indexOf('done') != -1) {
    472 -                        return true;
    473 -                    }else{
    474 -                        console.log('generateFakeOutput')
    475 -                        return false;
    476 -                    }
    477 -                  });
    478 -                },
    479 -                success: function () {
    480 -                  var startTime = new Date().getTime();
    481 -                  var interval = setInterval(function(){
    482 -                    if(new Date().getTime() - startTime > 5000){
    483 -                      hideDebris();
    484 -                      prepare('1280', '720');
    485 -                      main();
    486 -                      clearInterval(interval);
    487 -                      return;
    488 -                    }
    489 -                    console.log('generateFakeOutput')
    490 -                  }, 1000);
    491 -                },
    492 -                error: function () {
    493 -                  var startTime = new Date().getTime();
    494 -                  var interval = setInterval(function(){
    495 -                    if(new Date().getTime() - startTime > 5000){
    496 -                      hideDebris();
    497 -                      prepare('1280', '720');
    498 -                      main();
    499 -                      clearInterval(interval);
    500 -                      return;
    501 -                    }
    502 -                    console.log('generateFakeOutput')
    503 -                  }, 1000);
    504 -                }
    505 -            });
    506 -        }, "1000");
    507 -    }, "1000");
    508 -  });
    509 -}
    510 -
    511  function searchfunc(search){
    512    page.evaluate(function(search, zoomlevel) {
    513      if (document.querySelector('#search')){
    514 -        window.addHook('search', function(query) {
    515 -          var checkExist = setInterval(function() {
    516 -            if (query.results.length > 0) {
    517 -              console.warn(query.results)
    518 -              map.fitBounds(query.results[0].bounds, {maxZoom: 17})
    519 -              clearInterval(checkExist);
    520 -            }
    521 -            if (typeof zoomlevel !== 'undefined' || zoomlevel !== null) {
    522 -              console.log(zoomlevel)
    523 -              window.map.setZoom(zoomlevel,animate=false)
    524 -            }
    525 -          }, 100);
    526 -        });
    527 +      window.addHook('search', function(query) {
    528 +        var checkExist = setInterval(function() {
    529 +          if (query.results.length > 0) {
    530 +            map.fitBounds(query.results[0].bounds, {maxZoom: 17})
    531 +            clearInterval(checkExist);
    532 +          }
    533 +          if (typeof zoomlevel !== 'undefined' || zoomlevel !== null) {
    534 +            console.log(zoomlevel)
    535 +            window.map.setZoom(zoomlevel,animate=false)
    536 +          }
    537 +        }, 100);
    538 +      });
    539        setTimeout(function() {
    540          window.search.doSearch(search, true)
    541        }, 2000);
    542 @@ -341,47 +274,46 @@ function searchfunc(search){
    543  }
    544  
    545  function setupIITC(){
    546 -    loadIitcPlugin('https://static.iitc.me/build/release/plugins/canvas-render.user.js');
    547 -    page.evaluate(function(maptype) {
    548 -        localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify({
    549 -          "Unclaimed Portals": true,
    550 -          "Level 1 Portals": true,
    551 -          "Level 2 Portals": true,
    552 -          "Level 3 Portals": true,
    553 -          "Level 4 Portals": true,
    554 -          "Level 5 Portals": true,
    555 -          "Level 6 Portals": true,
    556 -          "Level 7 Portals": true,
    557 -          "Level 8 Portals": true,
    558 -		      "Fields": true,
    559 -		      "Links": true,
    560 -		      "Resistance": true,
    561 -		      "Enlightened": true,
    562 -          "DEBUG Data Tiles":false,
    563 -          "Artifacts":true,
    564 -          "Ornaments":true
    565 -        });
    566 -        var script = document.createElement('script');
    567 -        script.type='text/javascript';
    568 -        script.src='https://static.iitc.me/build/test/total-conversion-build.user.js';
    569 -        document.head.insertBefore(script, document.head.lastChild);
    570 -        if (maptype == "intel") {
    571 -          localStorage['iitc-base-map'] = 'Google Default Ingress Map';
    572 -        }else {
    573 -          localStorage['iitc-base-map'] = 'Google Roads';
    574 -        }
    575 -    }, maptype);
    576 -    if (maptype != "intel") {
    577 -      console.log(plugins);
    578 -      for(var i in plugins){
    579 -          var plugin = plugins[i];
    580 -          if(plugin.match('(http(s)?:\/\/)')){
    581 -              loadIitcPlugin(plugin);
    582 -          }else{
    583 -             loadLocalIitcPlugin(plugin);
    584 -          }
    585 +  loadIitcPlugin('https://static.iitc.me/build/release/plugins/canvas-render.user.js');
    586 +  page.evaluate(function(maptype) {
    587 +    localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify({
    588 +      "Unclaimed Portals": false,
    589 +      "Level 1 Portals": true,
    590 +      "Level 2 Portals": true,
    591 +      "Level 3 Portals": true,
    592 +      "Level 4 Portals": true,
    593 +      "Level 5 Portals": true,
    594 +      "Level 6 Portals": true,
    595 +      "Level 7 Portals": true,
    596 +      "Level 8 Portals": true,
    597 +      "Fields": true,
    598 +      "Links": true,
    599 +      "Resistance": true,
    600 +      "Enlightened": true,
    601 +      "DEBUG Data Tiles":false,
    602 +      "Artifacts":true,
    603 +      "Ornaments":true
    604 +    });
    605 +    var script = document.createElement('script');
    606 +    script.type='text/javascript';
    607 +    script.src='https://static.iitc.me/build/test/total-conversion-build.user.js';
    608 +    document.head.insertBefore(script, document.head.lastChild);
    609 +    if (maptype == "intel") {
    610 +      localStorage['iitc-base-map'] = 'Google Default Ingress Map';
    611 +    }else {
    612 +      localStorage['iitc-base-map'] = 'Google Roads';
    613 +    }
    614 +  }, maptype);
    615 +  if (maptype != "intel") {
    616 +    for(var i in plugins){
    617 +      var plugin = plugins[i];
    618 +      if(plugin.match('(http(s)?:\/\/)')){
    619 +        loadIitcPlugin(plugin);
    620 +      }else{
    621 +        loadLocalIitcPlugin(plugin);
    622        }
    623      }
    624 +  }
    625  }
    626  
    627  function s(file) {
    628 @@ -392,7 +324,7 @@ function s(file) {
    629    var interval = setInterval(function(){
    630      if(new Date().getTime() - startTime > 5000){
    631        clearInterval(interval);
    632 -      quit();
    633 +      phantom.exit(0);
    634        return;
    635      }
    636      console.log('doSomeOutput')
    637 @@ -481,81 +413,81 @@ function getDateTime(format) {
    638  
    639  function addTimestamp(time) {
    640    if (search == "nix") {
    641 -	if (maptype == "iitc") {
    642 -	    page.evaluate(function(dateTime, search) {
    643 -	      var water = document.createElement('p');
    644 -	      water.id='watermark-ice';
    645 -	      water.innerHTML = dateTime;
    646 -	      water.style.position = 'absolute';
    647 -	      water.style.color = '#3A539B';
    648 -	      water.style.top = '0';
    649 -	      water.style.zIndex = '4404';
    650 -	      water.style.marginTop = '0';
    651 -	      water.style.paddingTop = '0';
    652 -	      water.style.left = '0';
    653 -	      water.style.fontSize = '40px';
    654 -	      water.style.opacity = '0.8';
    655 -	      water.style.fontFamily = 'monospace';
    656 -	      water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    657 -	      document.querySelectorAll('body')[0].appendChild(water);
    658 -	    }, time, search);
    659 -	  }else {
    660 -	    page.evaluate(function(dateTime, search) {
    661 -	      var water = document.createElement('p');
    662 -	      water.id='watermark-ice';
    663 -	      water.style.zIndex = '4404';
    664 -	      water.innerHTML = dateTime;
    665 -	      water.style.position = 'absolute';
    666 -	      water.style.color = 'orange';
    667 -	      water.style.top = '0';
    668 -	      water.style.left = '0';
    669 -	      water.style.fontSize = '40px';
    670 -	      water.style.opacity = '0.8';
    671 -	      water.style.marginTop = '0';
    672 -	      water.style.paddingTop = '0';
    673 -	      water.style.fontFamily = 'monospace';
    674 -	      water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    675 -	      document.querySelectorAll('body')[0].appendChild(water);
    676 -	    }, time, search);
    677 -	  }
    678 +    if (maptype == "iitc") {
    679 +      page.evaluate(function(dateTime, search) {
    680 +        var water = document.createElement('p');
    681 +	water.id='watermark-ice';
    682 +	water.innerHTML = dateTime;
    683 +	water.style.position = 'absolute';
    684 +	water.style.color = '#3A539B';
    685 +	water.style.top = '0';
    686 +	water.style.zIndex = '4404';
    687 +	water.style.marginTop = '0';
    688 +	water.style.paddingTop = '0';
    689 +	water.style.left = '0';
    690 +	water.style.fontSize = '30px';
    691 +	water.style.opacity = '0.8';
    692 +	water.style.fontFamily = 'monospace';
    693 +	water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    694 +	document.querySelectorAll('body')[0].appendChild(water);
    695 +      }, time, search);
    696 +    }else {
    697 +      page.evaluate(function(dateTime, search) {
    698 +        var water = document.createElement('p');
    699 +        water.id='watermark-ice';
    700 +        water.style.zIndex = '4404';
    701 +        water.innerHTML = dateTime;
    702 +        water.style.position = 'absolute';
    703 +        water.style.color = 'orange';
    704 +        water.style.top = '0';
    705 +        water.style.left = '0';
    706 +        water.style.fontSize = '30px';
    707 +        water.style.opacity = '0.8';
    708 +        water.style.marginTop = '0';
    709 +        water.style.paddingTop = '0';
    710 +        water.style.fontFamily = 'monospace';
    711 +        water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    712 +        document.querySelectorAll('body')[0].appendChild(water);
    713 +      }, time, search);
    714 +    }
    715    }else{
    716 -	  if (maptype == "iitc") {
    717 -	    page.evaluate(function(dateTime, search) {
    718 -	      var water = document.createElement('p');
    719 -	      water.id='watermark-ice';
    720 -	      water.innerHTML = dateTime + ' - ' + search;
    721 -	      water.style.position = 'absolute';
    722 -	      water.style.color = '#3A539B';
    723 -	      water.style.top = '0';
    724 -	      water.style.zIndex = '4404';
    725 -	      water.style.marginTop = '0';
    726 -	      water.style.paddingTop = '0';
    727 -	      water.style.left = '0';
    728 -	      water.style.fontSize = '40px';
    729 -	      water.style.opacity = '0.8';
    730 -	      water.style.fontFamily = 'monospace';
    731 -	      water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    732 -	      document.querySelectorAll('body')[0].appendChild(water);
    733 -	    }, time, search);
    734 -	  }else {
    735 -	    page.evaluate(function(dateTime, search) {
    736 -	      var water = document.createElement('p');
    737 -	      water.id='watermark-ice';
    738 -	      water.style.zIndex = '4404';
    739 -	      water.innerHTML = dateTime + ' - ' + search;
    740 -	      water.style.position = 'absolute';
    741 -	      water.style.color = 'orange';
    742 -	      water.style.top = '0';
    743 -	      water.style.left = '0';
    744 -	      water.style.fontSize = '40px';
    745 -	      water.style.opacity = '0.8';
    746 -	      water.style.marginTop = '0';
    747 -	      water.style.paddingTop = '0';
    748 -	      water.style.fontFamily = 'monospace';
    749 -	      water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    750 -	      document.querySelectorAll('body')[0].appendChild(water);
    751 -	    }, time, search);
    752 -	  }
    753 +    if (maptype == "iitc") {
    754 +      page.evaluate(function(dateTime, search) {
    755 +        var water = document.createElement('p');
    756 +        water.id='watermark-ice';
    757 +        water.innerHTML = dateTime + ' - ' + search;
    758 +        water.style.position = 'absolute';
    759 +        water.style.color = '#3A539B';
    760 +        water.style.top = '0';
    761 +        water.style.zIndex = '4404';
    762 +        water.style.marginTop = '0';
    763 +        water.style.paddingTop = '0';
    764 +        water.style.left = '0';
    765 +        water.style.fontSize = '30px';
    766 +        water.style.opacity = '0.8';
    767 +        water.style.fontFamily = 'monospace';
    768 +        water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    769 +        document.querySelectorAll('body')[0].appendChild(water);
    770 +      }, time, search);
    771 +    }else {
    772 +      page.evaluate(function(dateTime, search) {
    773 +        var water = document.createElement('p');
    774 +        water.id='watermark-ice';
    775 +        water.style.zIndex = '4404';
    776 +        water.innerHTML = dateTime + ' - ' + search;
    777 +        water.style.position = 'absolute';
    778 +        water.style.color = 'orange';
    779 +        water.style.top = '0';
    780 +        water.style.left = '0';
    781 +        water.style.fontSize = '30px';
    782 +        water.style.opacity = '0.8';
    783 +        water.style.marginTop = '0';
    784 +        water.style.paddingTop = '0';
    785 +        water.style.fontFamily = 'monospace';
    786 +        water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)';
    787 +        document.querySelectorAll('body')[0].appendChild(water);
    788 +      }, time, search);
    789 +    }
    790    }
    791  }
    792