|
1 | 1 | // ==UserScript== |
2 | 2 | // @name WFES - Nomination Notify |
3 | 3 | // @namespace https://github.com/AlterTobi/WFES/ |
4 | | -// @version 0.2.4 |
| 4 | +// @version 0.3.0 |
5 | 5 | // @description show nomination status updates |
6 | 6 | // @author AlterTobi |
7 | 7 | // @match https://wayfarer.nianticlabs.com/* |
|
99 | 99 | return dict; |
100 | 100 | } |
101 | 101 |
|
| 102 | + function getCurrentDateStr(){ |
| 103 | + return new Date().toISOString().substr(0,10); |
| 104 | + } |
| 105 | + |
102 | 106 | function detectChange(){ |
103 | 107 | let nomList = window.wfes.nominations.list; |
104 | 108 | let historyDict = JSON.parse(localStorage.getItem(lStoreList)) || []; |
| 109 | + const missingDict = detectMissing(); |
105 | 110 |
|
106 | 111 | if ( 0 === historyDict.length){ |
107 | 112 | // first run, import from Wayfarer+, if exists |
|
115 | 120 | }else{ |
116 | 121 | // Only makes sense to look for change if we have data |
117 | 122 | // of the previous state! |
118 | | - let today = new Date().toISOString().substr(0,10); |
| 123 | + let today = getCurrentDateStr(); |
119 | 124 |
|
120 | 125 | for (let i = 0; i < nomList.length; i++){ |
121 | 126 | let nom = nomList[i]; |
|
139 | 144 | myDates.UPGRADE = today; |
140 | 145 | createNotification(`${nom.title} was upgraded!`); |
141 | 146 | } |
142 | | - |
| 147 | + |
| 148 | + // was missing? |
| 149 | + if ((historicalData.status === "MISSING")){ |
| 150 | + createNotification(`${nom.title} returned`); |
| 151 | + } |
143 | 152 | // In queue -> In voting |
144 | 153 | if ((historicalData.status !== "VOTING") && (nom.status === "VOTING")){ |
145 | 154 | createNotification(`${nom.title} went into voting!`); |
|
159 | 168 | myDates[states[j]] = today; |
160 | 169 | } |
161 | 170 | } |
162 | | - |
| 171 | + |
163 | 172 | nom.Dates = myDates; |
164 | 173 | nomList[i] = nom; |
165 | 174 | } |
166 | 175 |
|
167 | 176 | // 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 | + } |
169 | 204 | } |
| 205 | + return missingDict; |
170 | 206 | } |
171 | 207 |
|
172 | 208 | function NominationSelected() { |
|
0 commit comments