Created
April 10, 2016 14:52
-
-
Save x3388638/215bcc12f73131072dc4e0170838668a to your computer and use it in GitHub Desktop.
Override the original function in ingress intel map to log the portal owner and get latest captured date of the portal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ingress tool | |
// @namespace IngressTool | |
// @version 0.1 | |
// @description Log portals you own | |
// @author Y.Y. | |
// @match https://www.ingress.com/intel* | |
// @match http://www.ingress.com/intel* | |
// @include https://www.ingress.com/intel* | |
// @include http://www.ingress.com/intel* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var baseURL = ''; | |
var qwert = setInterval(function() { | |
if(typeof Ij == 'function') { | |
window.Ij = function(a, b) { | |
if(b && b.title && b.A == 'portal' && b.state == 2) { | |
var formData = new FormData(), xhr = new XMLHttpRequest(); | |
formData.append('pd', JSON.stringify(b)), xhr.open('post', baseURL + 'portals/processPortal'), xhr.send(formData), | |
xhr.onload = function() { | |
if(location.href.indexOf('cw=1') != -1) { | |
window.close(); | |
} | |
var date = (JSON.parse(xhr.response)).date; | |
var countDay = countDayDiff(date); | |
console.log('Date: ' + date + ' Count: ' + countDay); | |
showCount(date, countDay); | |
}; | |
} | |
T(a.a, yj, { | |
H: b, | |
Fc: b.J && !IS_VERSION_MOBILE, | |
oc: b.o.join(", ") | |
}); | |
}; | |
console.log('Injected.'); | |
clearInterval(qwert); | |
} | |
}, 1000); | |
var countDayDiff = function(ori) { | |
var date1 = new Date(ori); | |
var date2 = new Date(); | |
var timeDiff = Math.abs(date2.getTime() - date1.getTime()); | |
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); | |
return diffDays; | |
}; | |
var showCount = function(date, count) { | |
var node = document.createElement('div'); | |
node.innerHTML = '<div>Captured: ' + date + '</div><div>Days: ' + count + '</div>'; | |
document.getElementById('portal_metadata').appendChild(node); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment