intel-screenbot

An Ingress Intel Map Bot for Hangoutsbot
git clone git://archive.git.mtrnord.blog/MTRNord/intel-screenbot.git
Log | Files | Refs | README | LICENSE

commit 88699bd730db4e451ff1abb75c677ec1a12c2469
parent 66e0fb5140dcbcf013c1611d4b4422800514a921
Author: Marcel <MTRNord@users.noreply.github.com>
Date:   Sat, 31 Dec 2016 20:03:31 +0100

Merge pull request #5 from MTRNord/CodeRefactoring

Code refactoring
Diffstat:
M__init__.py | 51++++++++++++++++++++++-----------------------------
Mscreencap.js | 514++++++++++++++++++++++++++++++++++---------------------------------------------
2 files changed, 245 insertions(+), 320 deletions(-)

diff --git a/__init__.py b/__init__.py @@ -1,13 +1,9 @@ from bs4 import BeautifulSoup import requests import json -import asyncio, io, logging, os, re, time, tempfile -import subprocess +import asyncio, io, logging, os, tempfile import plugins import re -from asyncio import subprocess -from shutil import move -from os import remove, close logger = logging.getLogger(__name__) @@ -20,13 +16,9 @@ def _initialise(bot): @asyncio.coroutine def _open_file(name): - logger.debug("opening screenshot file: {}".format(name)) - statinfo = os.stat(name) - logger.info(statinfo.st_size) return open(name, 'rb') def _parse_onlineRepos(url, ext=''): - logger.debug("parsing github or gitlab or http(s)") page = requests.get(url).text if 'gitlab.com' in url: files = [] @@ -96,7 +88,6 @@ def _screencap(url, args_filepath, filepath, filename, bot, event): # read the resulting file into a byte array # yield from asyncio.sleep(10) - logger.info(filepath) file_resource = yield from _open_file(filepath) file_data = yield from loop.run_in_executor(None, file_resource.read) image_data = yield from loop.run_in_executor(None, io.BytesIO, file_data) @@ -107,6 +98,8 @@ def _screencap(url, args_filepath, filepath, filename, bot, event): os.unlink(filepath) os.unlink(args_filepath) except Exception as e: + os.unlink(filepath) + os.unlink(args_filepath) logger.exception("upload failed: {}".format(url)) logger.exception("exception: {}".format(e)) yield from bot.coro_send_message(event.conv_id, "<i>error uploading screenshot</i>") @@ -114,8 +107,8 @@ def _screencap(url, args_filepath, filepath, filename, bot, event): def setintel(bot, event, *args): """set url for current converation for the intel or iitc command. - use /bot clearintel to clear the previous url before setting a new one. - """ + use /bot clearintel to clear the previous url before setting a new one.""" + url = bot.conversation_memory_get(event.conv_id, 'IntelURL') if url is None: bot.conversation_memory_set(event.conv_id, 'IntelURL', ''.join(args)) @@ -130,8 +123,7 @@ def setintel(bot, event, *args): def intel(bot, event, *args): - """get a screenshot of a search term or intel URL or the default intel URL of the hangout. - """ + """get a screenshot of a search term or intel URL or the default intel URL of the hangout.""" arguments = {} @@ -143,7 +135,10 @@ def intel(bot, event, *args): if '"' in url: url = url.replace('"', '') else: - url = bot.conversation_memory_get(event.conv_id, 'IntelURL') + try: + url = bot.conversation_memory_get(event.conv_id, 'IntelURL') + except: + url = 'https://www.ingress.com/intel' if bot.config.exists(["intel_screenbot", "email"]): if bot.config.exists(["intel_screenbot", "password"]): @@ -175,7 +170,7 @@ def intel(bot, event, *args): if zoomlevel.isdigit(): yield from bot.coro_send_message(event.conv_id, "<i>intel map at zoom level "+ zoomlevel + " requested, please wait...</i>") else: - yield from bot.coro_send_message(event.conv_id, "<i>intel map at last zoom level requested, please wait...</i>") + yield from bot.coro_send_message(event.conv_id, "<i>intel map requested, please wait...</i>") else: search = url zoomParameter = re.search(r"(?<=z=)", url, re.IGNORECASE) @@ -186,17 +181,15 @@ def intel(bot, event, *args): zoomlevel = zoomlevel_raw.group() search = search.replace("z={}".format(zoomlevel),"") if zoomlevel.isdigit(): - 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>") + 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>") arguments['zoomlevel'] = str(zoomlevel) else: - yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting as requested, please wait...</i>") + yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on intel map and screenshooting as requested, please wait...</i>") url = 'https://www.ingress.com/intel' filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name filename = filepath.split('/', filepath.count('/'))[-1] args_filepath = tempfile.NamedTemporaryFile(prefix="args_{}".format(event.conv_id), suffix=".json", delete=False).name - logger.debug("temporary screenshot file: {}".format(filepath)) - logger.debug("temporary args file: {}".format(args_filepath)) arguments['search'] = search arguments['url'] = url @@ -205,8 +198,7 @@ def intel(bot, event, *args): with open(args_filepath, 'w') as out: out.write(json.dumps(arguments)) - - + try: loop = asyncio.get_event_loop() image_data = yield from _screencap(url, args_filepath, filepath, filename, bot, event) @@ -217,8 +209,7 @@ def intel(bot, event, *args): def iitc(bot, event, *args): - """get a screenshot of a search term or intel URL or the default intel URL of the hangout. - """ + """get a screenshot of a search term or intel URL or the default intel URL of the hangout.""" arguments = {} @@ -260,9 +251,9 @@ def iitc(bot, event, *args): zoomlevel_clean = zoomlevel_raw.group() zoomlevel = zoomlevel_clean[3:][:2] if zoomlevel.isdigit(): - yield from bot.coro_send_message(event.conv_id, "<i>intel map at zoom level "+ zoomlevel + " requested, please wait...</i>") + yield from bot.coro_send_message(event.conv_id, "<i>iitc map at zoom level "+ zoomlevel + " requested, please wait...</i>") else: - yield from bot.coro_send_message(event.conv_id, "<i>intel map at last zoom level requested, please wait...</i>") + yield from bot.coro_send_message(event.conv_id, "<i>iitc map requested, please wait...</i>") else: search = url zoomParameter = re.search(r"(?<=z=)", url, re.IGNORECASE) @@ -273,10 +264,10 @@ def iitc(bot, event, *args): zoomlevel = zoomlevel_raw.group() search = search.replace("z={}".format(zoomlevel),"") if zoomlevel.isdigit(): - 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>") + 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>") arguments['zoomlevel'] = str(zoomlevel) else: - yield from bot.coro_send_message(event.conv_id, "<i>intel map is searching " + search + " and screenshooting as requested, please wait...</i>") + yield from bot.coro_send_message(event.conv_id, "<i>searching " + search + " on iitc map and and screenshooting it as requested, please wait...</i>") url = 'https://www.ingress.com/intel' filepath = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name @@ -313,6 +304,7 @@ def iitc(bot, event, *args): return def show_iitcplugins(bot, event, *args): + """Shows all available iitc Plugins.""" if bot.memory.exists(["iitc_plugins"]): plugin_names = [] for plugin_objects in bot.memory.get_by_path(["iitc_plugins"]): @@ -322,6 +314,7 @@ def show_iitcplugins(bot, event, *args): 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)) def set_iitcplugins(bot, event, *args): + """sets the activated iitc plugins for a hangout.""" if not bot.conversation_memory_get(event.conv_id, 'iitc_plugins') is None: bot.conversation_memory_set(event.conv_id, 'iitc_plugins', None) bot.conversation_memory_set(event.conv_id, 'iitc_plugins', ', '.join(args)) @@ -333,10 +326,10 @@ def set_iitcplugins(bot, event, *args): yield from bot.coro_send_message(event.conv, html) def active_iitcplugins(bot, event, *args): + """shows the activated iitc plugins for a hangout.""" if bot.conversation_memory_get(event.conv_id, 'iitc_plugins') is None: html = "<i><b>{}</b> no active IITC Plugins for this conversation".format(event.user.full_name) yield from bot.coro_send_message(event.conv, html) - else: plugins = bot.conversation_memory_get(event.conv_id, 'iitc_plugins') html = "<i><b>{}</b> plugins for this conversation: {}<br />".format(event.user.full_name, plugins) diff --git a/screencap.js b/screencap.js @@ -23,20 +23,6 @@ if (args.length === 1) { var user = arguments['email'] var pass = arguments['password'] } -function quit() { - phantom.exit(0); -} - -loadCookies(function() { - if (config.SACSID == undefined || config.SACSID == '') { - firePlainLogin(user, pass, url); - } else { - addCookies(config.SACSID, config.CSRF); - console.log('Using cookies to log in'); - afterCookieLogin(url, search); - } -}); - function loadCookies(callback) { if(fs.exists(cookiespath)) { @@ -58,6 +44,45 @@ function loadCookies(callback) { callback(); } +function addCookies(sacsid, csrf) { + phantom.addCookie({ + name: 'SACSID', + value: sacsid, + domain: 'www.ingress.com', + path: '/', + httponly: true, + secure: true + }); + phantom.addCookie({ + name: 'csrftoken', + value: csrf, + domain: 'www.ingress.com', + path: '/' + }); +} + +loadCookies(function() { + if (config.SACSID == undefined || config.SACSID == '') { + firePlainLogin(user, pass, url); + } else { + addCookies(config.SACSID, config.CSRF); + afterLogin(url, search, "cookie"); + } +}); + +function waitFor ($config) { + $config._start = $config._start || new Date(); + if ($config.timeout && new Date - $config._start > $config.timeout) { + if ($config.error) $config.error(); + return; + } + if ($config.check()) { + return $config.success(); + } + setTimeout(waitFor, $config.interval || 0, $config); +} + + function isSignedIn() { return page.evaluate(function() { return document.getElementsByTagName('a')[0].innerText.trim() !== 'Sign in'; @@ -77,7 +102,7 @@ function firePlainLogin(user, pass, url) { page.evaluate(function () { localStorage.clear() }); - if (status !== 'success') {console.log("Login ERROR"); quit();} + if (status !== 'success') {console.log("Login ERROR"); phantom.exit(0);} 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=' page.open(link, function () { login(user, pass, url); @@ -123,7 +148,7 @@ function login(l, p, url) { window.setTimeout(function () { if (page.url.substring(0,40) === 'https://accounts.google.com/ServiceLogin') { console.log("login failed: wrong email and/or password") - quit() + phantom.exit(0); } if (page.url.substring(0,40) === 'https://appengine.google.com/_ah/loginfo') { @@ -136,114 +161,83 @@ function login(l, p, url) { if (page.url.substring(0,44) === 'https://accounts.google.com/signin/challenge') { twostep = system.stdin.readLine(); } - window.setTimeout(afterPlainLogin(url, search), loginTimeout); + window.setTimeout(afterLogin(url, search, "plain"), loginTimeout); }, loginTimeout) }, loginTimeout / 10); }, error: function () { - console.log("error waitingFor loginform") - quit(); + phantom.exit(0); } }); } -function afterPlainLogin(url, search) { +function afterLogin(url, search, mode) { page.viewportSize = { width: '1280', height: '720' }; page.open(url, function(status) { console.log(url) - if (status !== 'success') {console.log('unable to connect to remote server afterPlainLogin'); quit()} + if (status !== 'success') {console.log('unable to connect to remote server afterPlainLogin'); phantom.exit(0);} if (!isSignedIn()) { + if(mode =="cookie"){ + if(fs.exists(cookiespath)) { + fs.remove(cookiespath); + } + } console.log("not logged in") quit(); } setTimeout(function() { - storeCookies(); - setupIITC() - setTimeout(function() { - setTimeout(function() { - if (search != 'nix') { - searchfunc(search); - } - }, 1000); - waitFor({ - timeout: 240000, - check: function () { - return page.evaluate(function(zoomlevel) { - if (typeof zoomlevel === 'undefined' || zoomlevel === null) { - window.map.setZoom(zoomlevel,animate=false) - } - if (document.querySelector('.map').textContent.indexOf('done') != -1) { - return true; - }else{ - console.log('generateFakeOutput') - return false; - } - }, zoomlevel); - }, - success: function () { - var startTime = new Date().getTime(); - var interval = setInterval(function(){ - if(new Date().getTime() - startTime > 5000){ - hideDebris(); - prepare('1280', '720'); - main(); - clearInterval(interval); - return; - } - console.log('generateFakeOutput') - }, 1000); - }, - error: function () { - var startTime = new Date().getTime(); - var interval = setInterval(function(){ - if(new Date().getTime() - startTime > 5000){ - hideDebris(); - prepare('1280', '720'); - main(); - clearInterval(interval); - return; - } - console.log('generateFakeOutput') - }, 1000); - } - }); - }, "1000"); + if(mode == "plain"){ + storeCookies(); + } + setupIITC() + setTimeout(function() { + if (search != 'nix') { + searchfunc(search); + } + waitFor({ + timeout: 240000, + check: function () { + return page.evaluate(function(zoomlevel) { + if (document.querySelector('.map').textContent.indexOf('done') != -1) { + return true; + }else{ + console.log('generateFakeOutput') + return false; + } + }, zoomlevel); + }, + success: function () { + var startTime = new Date().getTime(); + var interval = setInterval(function(){ + if(new Date().getTime() - startTime > 5000){ + hideDebris(); + prepare('1280', '720'); + main(); + clearInterval(interval); + return; + } + console.log('generateFakeOutput') + }, 1000); + }, + error: function () { + var startTime = new Date().getTime(); + var interval = setInterval(function(){ + if(new Date().getTime() - startTime > 5000){ + hideDebris(); + prepare('1280', '720'); + main(); + clearInterval(interval); + return; + } + console.log('generateFakeOutput') + }, 1000); + } + }); + }, "1000"); }, "1000"); }); } - - -function addCookies(sacsid, csrf) { - phantom.addCookie({ - name: 'SACSID', - value: sacsid, - domain: 'www.ingress.com', - path: '/', - httponly: true, - secure: true - }); - phantom.addCookie({ - name: 'csrftoken', - value: csrf, - domain: 'www.ingress.com', - path: '/' - }); -} - - -function waitFor ($config) { - $config._start = $config._start || new Date(); - if ($config.timeout && new Date - $config._start > $config.timeout) { - if ($config.error) $config.error(); - return; - } - if ($config.check()) { - return $config.success(); - } - setTimeout(waitFor, $config.interval || 0, $config); -} - function loadIitcPlugin(src) { page.evaluate(function(src) { var script = document.createElement('script'); @@ -257,82 +251,21 @@ function loadLocalIitcPlugin(src) { page.injectJs(src) } -function afterCookieLogin(url, search) { - page.viewportSize = { width: '1280', height: '720' }; - page.open(url, function(status) { - if (status !== 'success') {quit('unable to connect to remote server')} - if(!isSignedIn()) { - if(fs.exists(cookiespath)) { - fs.remove(cookiespath); - } - quit('Cookies are obsolete. Update your config file.'); - } - setTimeout(function() { - setupIITC() - setTimeout(function() { - if (search != "nix") { - searchfunc(search); - } - waitFor({ - timeout: 240000, - check: function () { - return page.evaluate(function() { - if (document.querySelector('.map').textContent.indexOf('done') != -1) { - return true; - }else{ - console.log('generateFakeOutput') - return false; - } - }); - }, - success: function () { - var startTime = new Date().getTime(); - var interval = setInterval(function(){ - if(new Date().getTime() - startTime > 5000){ - hideDebris(); - prepare('1280', '720'); - main(); - clearInterval(interval); - return; - } - console.log('generateFakeOutput') - }, 1000); - }, - error: function () { - var startTime = new Date().getTime(); - var interval = setInterval(function(){ - if(new Date().getTime() - startTime > 5000){ - hideDebris(); - prepare('1280', '720'); - main(); - clearInterval(interval); - return; - } - console.log('generateFakeOutput') - }, 1000); - } - }); - }, "1000"); - }, "1000"); - }); -} - function searchfunc(search){ page.evaluate(function(search, zoomlevel) { if (document.querySelector('#search')){ - window.addHook('search', function(query) { - var checkExist = setInterval(function() { - if (query.results.length > 0) { - console.warn(query.results) - map.fitBounds(query.results[0].bounds, {maxZoom: 17}) - clearInterval(checkExist); - } - if (typeof zoomlevel !== 'undefined' || zoomlevel !== null) { - console.log(zoomlevel) - window.map.setZoom(zoomlevel,animate=false) - } - }, 100); - }); + window.addHook('search', function(query) { + var checkExist = setInterval(function() { + if (query.results.length > 0) { + map.fitBounds(query.results[0].bounds, {maxZoom: 17}) + clearInterval(checkExist); + } + if (typeof zoomlevel !== 'undefined' || zoomlevel !== null) { + console.log(zoomlevel) + window.map.setZoom(zoomlevel,animate=false) + } + }, 100); + }); setTimeout(function() { window.search.doSearch(search, true) }, 2000); @@ -341,47 +274,46 @@ function searchfunc(search){ } function setupIITC(){ - loadIitcPlugin('https://static.iitc.me/build/release/plugins/canvas-render.user.js'); - page.evaluate(function(maptype) { - localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify({ - "Unclaimed Portals": true, - "Level 1 Portals": true, - "Level 2 Portals": true, - "Level 3 Portals": true, - "Level 4 Portals": true, - "Level 5 Portals": true, - "Level 6 Portals": true, - "Level 7 Portals": true, - "Level 8 Portals": true, - "Fields": true, - "Links": true, - "Resistance": true, - "Enlightened": true, - "DEBUG Data Tiles":false, - "Artifacts":true, - "Ornaments":true - }); - var script = document.createElement('script'); - script.type='text/javascript'; - script.src='https://static.iitc.me/build/test/total-conversion-build.user.js'; - document.head.insertBefore(script, document.head.lastChild); - if (maptype == "intel") { - localStorage['iitc-base-map'] = 'Google Default Ingress Map'; - }else { - localStorage['iitc-base-map'] = 'Google Roads'; - } - }, maptype); - if (maptype != "intel") { - console.log(plugins); - for(var i in plugins){ - var plugin = plugins[i]; - if(plugin.match('(http(s)?:\/\/)')){ - loadIitcPlugin(plugin); - }else{ - loadLocalIitcPlugin(plugin); - } + loadIitcPlugin('https://static.iitc.me/build/release/plugins/canvas-render.user.js'); + page.evaluate(function(maptype) { + localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify({ + "Unclaimed Portals": false, + "Level 1 Portals": true, + "Level 2 Portals": true, + "Level 3 Portals": true, + "Level 4 Portals": true, + "Level 5 Portals": true, + "Level 6 Portals": true, + "Level 7 Portals": true, + "Level 8 Portals": true, + "Fields": true, + "Links": true, + "Resistance": true, + "Enlightened": true, + "DEBUG Data Tiles":false, + "Artifacts":true, + "Ornaments":true + }); + var script = document.createElement('script'); + script.type='text/javascript'; + script.src='https://static.iitc.me/build/test/total-conversion-build.user.js'; + document.head.insertBefore(script, document.head.lastChild); + if (maptype == "intel") { + localStorage['iitc-base-map'] = 'Google Default Ingress Map'; + }else { + localStorage['iitc-base-map'] = 'Google Roads'; + } + }, maptype); + if (maptype != "intel") { + for(var i in plugins){ + var plugin = plugins[i]; + if(plugin.match('(http(s)?:\/\/)')){ + loadIitcPlugin(plugin); + }else{ + loadLocalIitcPlugin(plugin); } } + } } function s(file) { @@ -392,7 +324,7 @@ function s(file) { var interval = setInterval(function(){ if(new Date().getTime() - startTime > 5000){ clearInterval(interval); - quit(); + phantom.exit(0); return; } console.log('doSomeOutput') @@ -481,81 +413,81 @@ function getDateTime(format) { function addTimestamp(time) { if (search == "nix") { - if (maptype == "iitc") { - page.evaluate(function(dateTime, search) { - var water = document.createElement('p'); - water.id='watermark-ice'; - water.innerHTML = dateTime; - water.style.position = 'absolute'; - water.style.color = '#3A539B'; - water.style.top = '0'; - water.style.zIndex = '4404'; - water.style.marginTop = '0'; - water.style.paddingTop = '0'; - water.style.left = '0'; - water.style.fontSize = '40px'; - water.style.opacity = '0.8'; - water.style.fontFamily = 'monospace'; - water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; - document.querySelectorAll('body')[0].appendChild(water); - }, time, search); - }else { - page.evaluate(function(dateTime, search) { - var water = document.createElement('p'); - water.id='watermark-ice'; - water.style.zIndex = '4404'; - water.innerHTML = dateTime; - water.style.position = 'absolute'; - water.style.color = 'orange'; - water.style.top = '0'; - water.style.left = '0'; - water.style.fontSize = '40px'; - water.style.opacity = '0.8'; - water.style.marginTop = '0'; - water.style.paddingTop = '0'; - water.style.fontFamily = 'monospace'; - water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; - document.querySelectorAll('body')[0].appendChild(water); - }, time, search); - } + if (maptype == "iitc") { + page.evaluate(function(dateTime, search) { + var water = document.createElement('p'); + water.id='watermark-ice'; + water.innerHTML = dateTime; + water.style.position = 'absolute'; + water.style.color = '#3A539B'; + water.style.top = '0'; + water.style.zIndex = '4404'; + water.style.marginTop = '0'; + water.style.paddingTop = '0'; + water.style.left = '0'; + water.style.fontSize = '30px'; + water.style.opacity = '0.8'; + water.style.fontFamily = 'monospace'; + water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; + document.querySelectorAll('body')[0].appendChild(water); + }, time, search); + }else { + page.evaluate(function(dateTime, search) { + var water = document.createElement('p'); + water.id='watermark-ice'; + water.style.zIndex = '4404'; + water.innerHTML = dateTime; + water.style.position = 'absolute'; + water.style.color = 'orange'; + water.style.top = '0'; + water.style.left = '0'; + water.style.fontSize = '30px'; + water.style.opacity = '0.8'; + water.style.marginTop = '0'; + water.style.paddingTop = '0'; + water.style.fontFamily = 'monospace'; + water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; + document.querySelectorAll('body')[0].appendChild(water); + }, time, search); + } }else{ - if (maptype == "iitc") { - page.evaluate(function(dateTime, search) { - var water = document.createElement('p'); - water.id='watermark-ice'; - water.innerHTML = dateTime + ' - ' + search; - water.style.position = 'absolute'; - water.style.color = '#3A539B'; - water.style.top = '0'; - water.style.zIndex = '4404'; - water.style.marginTop = '0'; - water.style.paddingTop = '0'; - water.style.left = '0'; - water.style.fontSize = '40px'; - water.style.opacity = '0.8'; - water.style.fontFamily = 'monospace'; - water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; - document.querySelectorAll('body')[0].appendChild(water); - }, time, search); - }else { - page.evaluate(function(dateTime, search) { - var water = document.createElement('p'); - water.id='watermark-ice'; - water.style.zIndex = '4404'; - water.innerHTML = dateTime + ' - ' + search; - water.style.position = 'absolute'; - water.style.color = 'orange'; - water.style.top = '0'; - water.style.left = '0'; - water.style.fontSize = '40px'; - water.style.opacity = '0.8'; - water.style.marginTop = '0'; - water.style.paddingTop = '0'; - water.style.fontFamily = 'monospace'; - water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; - document.querySelectorAll('body')[0].appendChild(water); - }, time, search); - } + if (maptype == "iitc") { + page.evaluate(function(dateTime, search) { + var water = document.createElement('p'); + water.id='watermark-ice'; + water.innerHTML = dateTime + ' - ' + search; + water.style.position = 'absolute'; + water.style.color = '#3A539B'; + water.style.top = '0'; + water.style.zIndex = '4404'; + water.style.marginTop = '0'; + water.style.paddingTop = '0'; + water.style.left = '0'; + water.style.fontSize = '30px'; + water.style.opacity = '0.8'; + water.style.fontFamily = 'monospace'; + water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; + document.querySelectorAll('body')[0].appendChild(water); + }, time, search); + }else { + page.evaluate(function(dateTime, search) { + var water = document.createElement('p'); + water.id='watermark-ice'; + water.style.zIndex = '4404'; + water.innerHTML = dateTime + ' - ' + search; + water.style.position = 'absolute'; + water.style.color = 'orange'; + water.style.top = '0'; + water.style.left = '0'; + water.style.fontSize = '30px'; + water.style.opacity = '0.8'; + water.style.marginTop = '0'; + water.style.paddingTop = '0'; + water.style.fontFamily = 'monospace'; + water.style.textShadow = '0px 1px 8px rgba(150, 150, 150, 1)'; + document.querySelectorAll('body')[0].appendChild(water); + }, time, search); + } } }