Skip to content

Commit 991b43c

Browse files
committed
add detection of missing nominations (possibly in review by niantic staff)
1 parent b746224 commit 991b43c

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

wfes-NominationNotify.user.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name WFES - Nomination Notify
33
// @namespace https://github.com/AlterTobi/WFES/
4-
// @version 0.2.4
4+
// @version 0.3.0
55
// @description show nomination status updates
66
// @author AlterTobi
77
// @match https://wayfarer.nianticlabs.com/*
@@ -99,9 +99,14 @@
9999
return dict;
100100
}
101101

102+
function getCurrentDateStr(){
103+
return new Date().toISOString().substr(0,10);
104+
}
105+
102106
function detectChange(){
103107
let nomList = window.wfes.nominations.list;
104108
let historyDict = JSON.parse(localStorage.getItem(lStoreList)) || [];
109+
const missingDict = detectMissing();
105110

106111
if ( 0 === historyDict.length){
107112
// first run, import from Wayfarer+, if exists
@@ -115,7 +120,7 @@
115120
}else{
116121
// Only makes sense to look for change if we have data
117122
// of the previous state!
118-
let today = new Date().toISOString().substr(0,10);
123+
let today = getCurrentDateStr();
119124

120125
for (let i = 0; i < nomList.length; i++){
121126
let nom = nomList[i];
@@ -139,7 +144,11 @@
139144
myDates.UPGRADE = today;
140145
createNotification(`${nom.title} was upgraded!`);
141146
}
142-
147+
148+
// was missing?
149+
if ((historicalData.status === "MISSING")){
150+
createNotification(`${nom.title} returned`);
151+
}
143152
// In queue -> In voting
144153
if ((historicalData.status !== "VOTING") && (nom.status === "VOTING")){
145154
createNotification(`${nom.title} went into voting!`);
@@ -159,14 +168,41 @@
159168
myDates[states[j]] = today;
160169
}
161170
}
162-
171+
163172
nom.Dates = myDates;
164173
nomList[i] = nom;
165174
}
166175

167176
// Store the new state
168-
localSave(lStoreList,makeNominationDictionary(nomList));
177+
178+
let nomDict = makeNominationDictionary(nomList);
179+
let fullDict = Object.assign(nomDict,missingDict);
180+
localSave(lStoreList,fullDict);
181+
}
182+
}
183+
184+
function detectMissing(){
185+
// check if saved nomination is not in current list
186+
// might be in review by Niantic staff
187+
let nomDict = makeNominationDictionary(window.wfes.nominations.list);
188+
let historyDict = JSON.parse(localStorage.getItem(lStoreList)) || [];
189+
let today = getCurrentDateStr();
190+
let missingDict = {};
191+
let myDates = {};
192+
let miss = {};
193+
194+
for (let histID in historyDict){
195+
if (undefined === nomDict[histID]){
196+
// missing
197+
miss = historyDict[histID];
198+
if ((miss.status !== "MISSING")){
199+
miss.Dates.MISSING = today;
200+
createNotification(`${miss.title} is missing`);
201+
missingDict[histID] = miss;
202+
}
203+
}
169204
}
205+
return missingDict;
170206
}
171207

172208
function NominationSelected() {

0 commit comments

Comments
 (0)