diff --git a/plugins/uniques.user.js b/plugins/uniques.user.js index 579f2792..29c5c8cb 100644 --- a/plugins/uniques.user.js +++ b/plugins/uniques.user.js @@ -38,12 +38,30 @@ window.plugin.uniques.enableSync = false; window.plugin.uniques.disabledMessage = null; window.plugin.uniques.contentHTML = null; -window.plugin.uniques.addToSidebar = function() { +window.plugin.uniques.onPortalDetailsUpdated = function() { if(typeof(Storage) === "undefined") { $('#portaldetails > .imgpreview').after(plugin.uniques.disabledMessage); return; } + var guid = window.selectedPortal, + details = portalDetail.get(guid), + nickname = window.PLAYER.nickname; + if(details) { + if(details.owner == nickname) { + plugin.uniques.updateCaptured(true); + // no further logic required + } else { + function installedByPlayer(entity) { + return entity && entity.owner == nickname; + } + + if(details.resonators.some(installedByPlayer) || details.mods.some(installedByPlayer)) { + plugin.uniques.updateVisited(true); + } + } + } + $('#portaldetails > .imgpreview').after(plugin.uniques.contentHTML); plugin.uniques.updateChecked(); } @@ -222,7 +240,7 @@ var setup = function() { window.plugin.uniques.setupCSS(); window.plugin.uniques.setupContent(); window.plugin.uniques.loadLocal(window.plugin.uniques.KEY); - window.addHook('portalDetailsUpdated', window.plugin.uniques.addToSidebar); + window.addHook('portalDetailsUpdated', window.plugin.uniques.onPortalDetailsUpdated); window.addHook('iitcLoaded', window.plugin.uniques.registerFieldForSyncing); window.addPortalHighlighter('Uniques', window.plugin.uniques.highlight); }