// ==UserScript== // @id iitc-plugin-raw-portal-data // @name IITC plugin: Debug: Raw portal JSON data // @category Debug // @version 0.2.4.@@DATETIMEVERSION@@ // @namespace rawdata // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ // @description [@@BUILDNAME@@-@@BUILDDATE@@] Developer debugging aid: Add a link to the portal details to show the raw data of a portal. // @include https://*.ingress.com/intel* // @include http://*.ingress.com/intel* // @match https://*.ingress.com/intel* // @match http://*.ingress.com/intel* // @include https://*.ingress.com/mission/* // @include http://*.ingress.com/mission/* // @match https://*.ingress.com/mission/* // @match http://*.ingress.com/mission/* // @grant none // ==/UserScript== @@PLUGINSTART@@ // PLUGIN START //////////////////////////////////////////////////////// // use own namespace for plugin window.plugin.rawdata = function() {}; window.plugin.rawdata.setupCallback = function() { addHook('portalDetailsUpdated', window.plugin.rawdata.addLink); } window.plugin.rawdata.addLink = function(d) { $('.linkdetails').append(''); } window.plugin.rawdata.showPortalData = function(guid) { if (!window.portals[guid]) { console.warn ('Error: failed to find portal details for guid '+guid+' - failed to show debug data'); return; } var data = window.portals[guid].options.data; var ts = window.portals[guid].options.timestamp; var title = 'Raw portal data: ' + (data.title || '') + ' ('+guid+')'; var body = 'Portal GUID: '+guid+'
' + 'Entity timestamp: '+ts+' - '+window.unixTimeToDateTimeString(ts,true)+'
' + 'Portal map data:
'+JSON.stringify(data,null,2)+'
'; var details = portalDetail.get(guid); if (details) { body += 'Portal details:
'+JSON.stringify(details,null,2)+'
'; } body += '

Links referencing this portal

'; var haslinks = false; var linkGuids = getPortalLinks(guid); $.each(linkGuids.in.concat(linkGuids.out), function(i,lguid) { var l = window.links[lguid]; var ld = l.options.data; body += 'Link GUID: '+l.options.guid+'
'+JSON.stringify(ld,null,2)+'
'; haslinks = true; }); if (!haslinks) body += '

No links to/from this portal

'; body += '

Fields referencing this portal

'; var hasfields = false; var fieldGuids = getPortalFields(guid); $.each(fieldGuids, function(i,fguid) { var f = window.fields[fguid]; var fd = f.options.data; body += 'Field guid: '+f.options.guid+'
'+JSON.stringify(fd,null,2)+'
'; hasfields = true; }); if (!hasfields) body += '

No fields linked to this portal

'; dialog({ title: title, html: body, id: 'dialog-rawdata', dialogClass: 'ui-dialog-rawdata', }); } var setup = function () { window.plugin.rawdata.setupCallback(); $('head').append(''); } // PLUGIN END ////////////////////////////////////////////////////////// @@PLUGINEND@@