Added recharge percentage support (portal only) as well as optimisations regaring PortalGetLink

This commit is contained in:
cyi1341 2023-09-07 15:13:47 +08:00
parent aa5484373a
commit b979c96dd1
2 changed files with 37 additions and 10 deletions

View File

@ -131,6 +131,7 @@ function wrapper(plugin_info) {
exportTime = new Date();
}
function downloadFile(data, filename) {
var link = document.createElement('a');
link.href = 'data:text/json;charset=utf-8,' + encodeURIComponent(data);
@ -141,7 +142,7 @@ function wrapper(plugin_info) {
document.body.removeChild(link);
}
window.plugin.portalsJSON.fields = [
window.plugin.portalsJSON.fields = [
{
title: 'Portal Name',
value: function(portal) {
@ -188,6 +189,7 @@ function wrapper(plugin_info) {
title: 'Links',
value: function(portal) {
var links = window.getPortalLinks(portal.options.guid);
portal.links = links; // Save the computed links for reuse
return links.in.length + links.out.length;
},
},
@ -200,7 +202,7 @@ function wrapper(plugin_info) {
{
title: 'AP',
value: function(portal) {
var links = window.getPortalLinks(portal.options.guid);
var links = portal.links; // Use the previously computed links
var fields = getPortalFieldsCount(portal.options.guid);
return portalApGainMaths(portal.options.data.resCount, links.in.length + links.out.length, fields);
},
@ -234,7 +236,7 @@ function wrapper(plugin_info) {
{
title: 'Incoming Links',
value: function(portal) {
var links = window.getPortalLinks(portal.options.guid);
var links = portal.links; // Use the previously computed links
return links.in.map(function(linkGuid) {
var link = window.links[linkGuid].options.data;
var GUID = link.oGuid;
@ -253,7 +255,7 @@ function wrapper(plugin_info) {
{
title: 'Outgoing Links',
value: function(portal) {
var links = window.getPortalLinks(portal.options.guid);
var links = portal.links; // Use the previously computed links
return links.out.map(function(linkGuid) {
var link = window.links[linkGuid].options.data;
var GUID = link.dGuid;
@ -268,9 +270,19 @@ function wrapper(plugin_info) {
};
});
},
},
{
title: 'Recharge Percentage',
value: function(portal) {
var health = portal.options.data.health;
if(health !== undefined && portal.options.team != TEAM_NONE {
return health;
}
return 'N/A';
},
}
// Add more column specifications here as needed
];
];
window.plugin.portalsJSON.displayPL = function() {
var button = document.createElement('button');
@ -351,4 +363,3 @@ var info = {};
if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
script.appendChild(document.createTextNode('('+ wrapper +')('+ JSON.stringify(info) +')'));
(document.body || document.head || document.documentElement).appendChild(script);

View File

@ -62,7 +62,13 @@
"Portal Name": {
"type": "string"
}
}
},
"required": [
"GUID",
"Latitude",
"Longitude",
"Portal Name"
]
}
},
"Outgoing Links": {
@ -82,8 +88,17 @@
"Portal Name": {
"type": "string"
}
}
},
"required": [
"GUID",
"Latitude",
"Longitude",
"Portal Name"
]
}
},
"Recharge Percentage": {
"type": "string"
}
},
"required": [
@ -100,6 +115,7 @@
"Image URL",
"GUID",
"Incoming Links",
"Outgoing Links"
"Outgoing Links",
"Recharge Percentage"
]
}