// ==UserScript==
// @name WFES - Wayfarer Stats
// @version 1.6.0
// @description save Wayfarer statistics in local browser storage
// @author AlterTobi
// @namespace https://github.com/AlterTobi/WFES/
// @homepage https://altertobi.github.io/Wayfarer-Extension-Scripts/
// @supportURL https://github.com/AlterTobi/Wayfarer-Extension-Scripts/issues
// @icon https://altertobi.github.io/Wayfarer-Extension-Scripts/assets/icon_32.png
// @icon64 https://altertobi.github.io/Wayfarer-Extension-Scripts/assets/icon_64.png
// @downloadURL https://altertobi.github.io/Wayfarer-Extension-Scripts/wfes-WayfarerStats.user.js
// @updateURL https://altertobi.github.io/Wayfarer-Extension-Scripts/wfes-WayfarerStats.meta.js
// @match https://wayfarer.nianticlabs.com/*
// @grant none
// ==/UserScript==
/* Copyright 2024 AlterTobi
This file is part of the Wayfarer Extension Scripts collection.
Wayfarer Extension Scripts are free software: you can redistribute and/or modify
them under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wayfarer Extension Scripts are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You can find a copy of the GNU General Public License at the
web space where you got this script from
https://altertobi.github.io/Wayfarer-Extension-Scripts/LICENSE.txt
If not, see .
*/
(function() {
"use strict";
const selfname = "wfes_wayfarerStats";
const maincount = 14;
// define names
const lStoreStats = selfname+"_Stats";
const lStorePogo = selfname+"_PoGoCount";
const lStoreCheck = selfname+"_IsChecked";
const lStoreCheckS2 = selfname+"_IsCheckedS2";
const lStoreUpgrades = selfname+"_myUpgrades";
const myCssId = "wayfarerStatsCSS";
const myStyle = `
th { text-align: center; }
td, th { padding: 5px; border: 1px solid; }
td { text-align: right; }
table { margin-top: 10px; font-family: monospace
background-color: #2d2d2d; width: 100%; }
#reversebox { margin: 0 10px; }
#s2box { margin: 0 10px; }
#buttonsdiv button { margin: 0 10px; }
#buttonsdiv, #statsdiv, #gamesdiv { margin-bottom: 2em; }
`;
const myStyle_nodark = `
table, td, th { border-color: black;}
`;
const WARN_POGO = `data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAAAFFQTFRF//////8z/8yZ/8xm/5lm/2Zm/zMzzMzMzMyZzMxmzGZmzDMz
zDMAmczMmZnMmZmZmTMzmTMAZpnMZpmZZmZmZjMzM2ZmMzMzMwAAADMzAAAAQu3hzgAAAR1JREFU
eNqc09GSgyAMBdC0QRFRQ6mI8v8fuglQRrednZ3eR4656IBw+zPwb0ZEpRTiR0bVdb3ljKN5Z1XM
lgfwyth1DZ1zdlQXPunVoTTLcs+p7Fzth1yd0e17sHZ6PB55vrFU9zbEdUvJCYuXengNh00D6Fg8
11fmb+LmQxR02qepsDOVbQghReBovaWdEwLvrgqPxxG3GGWWuD0eiRNjGAubWUsr8SxQeoJeiNZ1
OyrfpRbWRFpTijpnnpenOTO7dBYjzjLUD8vvBDCvK9VJYV/5llkegJM+PVa+l/W2K2WmdiQnnpeq
3jRG+DXKSqfzvkOdbOovl0n81ZsVr3cNhRsO7xfZDDNvvXjvCT/+BmgGosHgV3/JF/wjwACvbhgT
fnV1HwAAAABJRU5ErkJggg==`;
let PoGoStats, wfrStats, isChecked, isCheckedS2;
let isInitialized = false;
const body = document.getElementsByTagName("body")[0];
const head = document.getElementsByTagName("head")[0];
// init
function init() {
// get Values from localStorage
window.wfes.f.localGet(lStorePogo, []).then((PS)=>{
PoGoStats = PS;
window.wfes.f.localGet(lStoreStats, []).then((wf)=>{
wfrStats = wf;
window.wfes.f.localGet(lStoreCheck, false).then((ic)=>{
isChecked = ic;
window.wfes.f.localGet(lStoreCheckS2, false).then((s2c)=>{
isCheckedS2 = s2c;
isInitialized = true;
});
});
});
});
}
function YMDfromTime(time) {
const curdate = new Date();
curdate.setTime(time);
const Jahr = curdate.getFullYear().toString(),
Monat = ("0" + ( 1 + curdate.getMonth())).slice(-2),
Tag = ("0" + curdate.getDate()).slice(-2);
const ymd = Tag + "." + Monat + "." + Jahr;
return ymd;
}
function upgrades() {
/* die Upgrades zählen */
console.log(selfname + " zähle Upgrades");
const profile = window.wfes.g.profile();
const progress = profile.progress;
const total = profile.total;
let lastProgress = 0;
let lastTotal = 0;
window.wfes.f.localGet(lStoreUpgrades, []).then((myWFRupgrades)=>{
if (myWFRupgrades.length > 0) {
lastProgress = myWFRupgrades[myWFRupgrades.length-1].progress;
lastTotal = myWFRupgrades[myWFRupgrades.length-1].total;
}
if ((total !== lastTotal ) || (progress !== lastProgress)) {
const ut = new Date().getTime();
const curstats = {"datum":ut, "progress":progress, "total":total};
myWFRupgrades.push(curstats);
window.wfes.f.localSave(lStoreUpgrades, myWFRupgrades);
}
});
}
function wfrstats() {
let heute, last, ut;
// nur tun, wenn heute noch nicht und Stunde > 3
const jetzt = new Date();
const stunde = jetzt.getHours();
if (stunde < 3) {
heute = new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()-1 );
} else {
heute = new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate() );
}
const heuteTS = heute.getTime();
if (wfrStats.length > 0) {
last = wfrStats[wfrStats.length-1].datum;
} else {
last = 0;
}
if (heuteTS > last) {
console.log(selfname + " saving stats");
const profile = window.wfes.g.profile();
const reviewed = profile.finished;
const accepted = profile.accepted;
const rejected = profile.rejected;
const duplicated = profile.duplicated;
let curstats;
if ( last > 0 ) {
// nur wenn schon gespeicherte Werte vorhanden.
const einTag = 25*60*60*1000; // milliseconds
// 25hours because of DST
const letzter = new Date();
letzter.setTime(last);
let letzterTS = new Date(letzter.getFullYear(), letzter.getMonth(), letzter.getDate()).getTime();
while ( (heuteTS - letzterTS) > einTag ) {
letzterTS += einTag;
curstats = {"datum":letzterTS, "reviewed":reviewed, "accepted":accepted, "rejected":rejected, "duplicated":duplicated};
wfrStats.push(curstats);
}
}
if (stunde > 3) {
ut = jetzt.getTime();
} else {
ut = heuteTS;
}
curstats = {"datum":ut, "reviewed":reviewed, "accepted":accepted, "rejected":rejected, "duplicated":duplicated};
wfrStats.push(curstats);
window.wfes.f.localSave(lStoreStats, wfrStats);
} else {
console.log("stats already saved today");
}
}
function emptyPage(histText) {
// fake history Eintrag (wegen zurückbutton)
const stateObj = {info: "fake Chronik"};
history.pushState(stateObj, "wfr main page", histText);
window.addEventListener("popstate", function() {
location.reload();
});
isChecked = document.getElementById("reversebox").checked || false;
isCheckedS2 = document.getElementById("s2box").checked || false;
// Body leeren
body.innerHTML = null;
// styles & Co. entfernen
const removables = ["script", "style", "link"];
for (const r of removables) {
const rms = head.getElementsByTagName(r);
while (rms.length > 0) {
head.removeChild(rms[0]);
}
}
const fav = document.createElement("link");
fav.setAttribute("rel", "shortcut icon");
fav.setAttribute("href", "/imgpub/favicon.ico");
head.appendChild(fav);
}
/* PoGO zählen */
function handleReview() {
if (!isInitialized) {
return;
}
// hier die zu suchenden Begriffe rein
const pokeArr= [
"Pok[eéè]mon",
"Pok[eéè]stop",
"Stop",
"Trainer",
"Arena",
"Raid",
"Pogo",
"Lockmodul",
"Nester",
"Pokespot",
// spanisch
"parada",
"gimnasio"
];
function pruefeText(text, arr) {
let hasText = false;
for (const p of arr) {
const r = new RegExp(p, "im");
if (r.test(text)) {
hasText = true;
break; // den Rest können wir uns sparen :-)
}
}
return (hasText);
}
function set_warning(image) {
const elem = window.document.querySelector("div.wf-page-header");
elem.insertAdjacentHTML("beforeEnd", '');
}
const newPortalData = window.wfes.g.reviewPageData();
const statement = newPortalData.statement === undefined ? "" : newPortalData.statement.trim();
const type = newPortalData.type;
let subtype = 0;
let usertext = statement + " " +
newPortalData.title + " " +
newPortalData.description;
if ( ("NEW" === type) && ("" !== statement) ) {
subtype = 1;
}
if ( "EDIT" === type ) {
for (const d of newPortalData.descriptionEdits) {
usertext += " " + d.value;
}
for (const t of newPortalData.titleEdits) {
usertext += " " + t.value;
}
}
if ("" === usertext) {
console.warn(selfname + " kein Text - das ist ein Bug");
} else {
const hasPoketext = pruefeText(usertext, pokeArr);
// Statistik speichern
const jetzt = new Date();
const curstats = {
"datum" : jetzt.getTime(),
"typ" : type,
"subtyp" : subtype,
"pogo" : hasPoketext,
"hpwu" : false,
"latE6" : newPortalData.lat * 1E6,
"lngE6" : newPortalData.lng * 1E6,
"titel" : newPortalData.title
};
PoGoStats.push(curstats);
window.wfes.f.localSave(lStorePogo, PoGoStats);
if (hasPoketext) {
set_warning(WARN_POGO);
}
}
}
function handleProfile() {
if (!isInitialized) {
return;
}
wfrstats();
upgrades();
}
function handleShowcase() {
if (!isInitialized) {
return;
}
const section = document.getElementsByClassName("showcase")[0];
// --- helper functions ---
function addDivs() {
const cText = isChecked ? "checked" : "";
const s2Text = isCheckedS2 ? "checked" : "";
section.insertAdjacentHTML("beforeEnd",
'
' +
'' +
'reverse: " +
''+
'' +
'' +
'' +
'show S2 grid: " +
"
"
);
}
function showStatsTable() {
// Stats - Tabelle
const end = Math.max(0, wfrStats.length - maincount);
const week = Math.min(7, wfrStats.length - 1);
// Tabelle für die Statistik
document.getElementById("statsdiv").insertAdjacentHTML("beforeEnd", ' | total | yesterday | last ' + week + " days (sliding window) |
"+
'date | reviewed | created | rejected | dup | % | reviewed | created | rejected | dup | % | reviewed | created | rejected | dup | % |
'+
'
');
const innertable = document.getElementById("statstablebody");
// Statistik einfügen
let gproz, grev, gacc, grej, gdup, wproz, wrev, wacc, wrej, wdup, trev, tacc, trej, tdup;
trev = tacc = trej = tdup = 0;
for (let i = wfrStats.length - 1; i >= end; i--) {
const ymd = YMDfromTime(wfrStats[i].datum);
const prozent = wfrStats[i].reviewed > 0 ? 100*(wfrStats[i].accepted + wfrStats[i].rejected + wfrStats[i].duplicated)/ wfrStats[i].reviewed : 0;
if (i > 0) {
grev = wfrStats[i].reviewed - wfrStats[i-1].reviewed;
gacc = wfrStats[i].accepted - wfrStats[i-1].accepted;
grej = wfrStats[i].rejected - wfrStats[i-1].rejected;
gdup = wfrStats[i].duplicated - wfrStats[i-1].duplicated;
gproz = grev > 0 ? (100*(gacc+grej+gdup)/grev).toFixed(2) : " -- ";
trev += grev;
tacc += gacc;
trej += grej;
tdup += gdup;
} else {
gproz = grev = gacc = grej = gdup = " -- ";
}
if (i > week-1) {
wrev = wfrStats[i].reviewed - wfrStats[i-week].reviewed;
wacc = wfrStats[i].accepted - wfrStats[i-week].accepted;
wrej = wfrStats[i].rejected - wfrStats[i-week].rejected;
wdup = wfrStats[i].duplicated - wfrStats[i-week].duplicated;
wproz = wrev > 0 ? (100*(wacc+wrej+wdup)/wrev).toFixed(2) : " -- ";
} else {
wproz = wrev = wacc = wrej = wdup = " -- ";
}
innertable.insertAdjacentHTML("beforeEnd", "" + ymd +" | " + wfrStats[i].reviewed + " | "+
wfrStats[i].accepted + " | " + wfrStats[i].rejected + " | " + wfrStats[i].duplicated + " | " + prozent.toFixed(2) + "% | "+
"" + grev + " | " + gacc + " | " + grej + " | " + gdup + " | (" + gproz + "%) | " +
"" + wrev + " | " + wacc + " | " + wrej + " | " + wdup + " | (" + wproz + "%) |
");
}
const tproz = trev > 0 ? (100*(tacc+trej+tdup)/trev).toFixed(2) : " -- ";
const agr = tacc+trej+tdup;
const aproz = agr > 0 ? (100*tacc/agr).toFixed(2) : " -- ";
const rproz = agr > 0 ? (100*trej/agr).toFixed(2) : " -- ";
const dproz = agr > 0 ? (100*tdup/agr).toFixed(2) : " -- ";
innertable.insertAdjacentHTML("beforeEnd", ' | '+
"" + trev + " | " + tacc + " | " + trej + " | " + tdup + " | (" + tproz + "%) | " +
' |
' +
" | " + aproz + "% | " + rproz + "% | " + dproz + "% | | ");
}
function buttonFuncs() {
// Stats
function _writeLine(stats) {
const dupes = "undefined" === typeof(stats.duplicated) ? "" : stats.duplicated;
body.insertAdjacentHTML("beforeEnd", YMDfromTime(stats.datum) + ";" + stats.reviewed + ";" + stats.accepted + ";" + stats.rejected + ";" + dupes + "
");
}
document.getElementById("WFRStatsBtn").addEventListener("click", function() {
emptyPage("/#mystats");
if (isChecked) {
for (let i = wfrStats.length -1; i >= 0; i--) {
_writeLine(wfrStats[i]);
}
} else {
for (let i = 0; i < wfrStats.length; i++) {
_writeLine(wfrStats[i]);
}
}
window.wfes.f.localSave(lStoreCheck, isChecked);
});
// Upgrades
document.getElementById("WFRSUpgrBtn").addEventListener("click", function() {
emptyPage("/#myupgrades");
window.wfes.f.localGet(lStoreUpgrades, []).then((myup)=>{
if (isChecked) {
for (let i = myup.length -1; i >= 0; i--) {
body.insertAdjacentHTML("beforeEnd", myup[i].datum + ";" + myup[i].progress + ";" + myup[i].total + "
");
}
} else {
for (let i = 0; i < myup.length; i++) {
body.insertAdjacentHTML("beforeEnd", myup[i].datum + ";" + myup[i].progress + ";" + myup[i].total + "
");
}
}
window.wfes.f.localSave(lStoreCheck, isChecked);
});
});
function showMap() {
let histText, innerScript = "";
// Body leeren
emptyPage(histText);
if ("WFRHeatBtn" === this.id ) {
histText = "/#wfrheatmap";
window.wfes.f.localSave(lStoreCheckS2, isCheckedS2);
innerScript += `
function getPoints() {
return [`;
for (let i = PoGoStats.length - 1; i > PoGoStats.length -501; i--) {
// nur die neuesten 500
const lat = PoGoStats[i].latE6/1E6;
const lng = PoGoStats[i].lngE6/1E6;
innerScript += "new google.maps.LatLng("+lat+","+lng+"),";
if ( 0 === i) { break; }// weniger geht nicht
}
innerScript += `]}
heatmap = new google.maps.visualization.HeatmapLayer({
data: getPoints(),
opacity: 0.6,
map: map
});`;
if(isCheckedS2) {
innerScript += ` // S2 Grid
getGrid();
function idleGrid() {
overlay.updateGrid(map, 6, 'red', 2);
}
function getGrid() {
overlay.drawCellGrid(map, 6, 'red', 2);
map.addListener('idle', idleGrid);
}`;
}
} else if ("WFRMarkBtn" === this.id ) {
histText = "/#wfrmarker";
const iconBase = "https://icons.iconarchive.com/icons/icons-land/vista-map-markers/32/";
for (let i = PoGoStats.length - 1; i > PoGoStats.length -501; i--) {
// nur die neuesten 500
const lat = PoGoStats[i].latE6/1E6;
const lng = PoGoStats[i].lngE6/1E6;
let ti1, ti2, ico;
let color = "Azure";
ti1 = ti2 = "";
if (PoGoStats[i].pogo) { ti2 = "PoGo"; color = "Pink";}
if (PoGoStats[i].hpwu) { ti2 = "HPWU"; color = "Chartreuse";}
switch (PoGoStats[i].typ) {
case "EDIT":
ti1 = "Edit";
ico = "Map-Marker-Ball-Right-" + color + "-icon.png";
break;
case "NEW":
switch (PoGoStats[i].subtyp) {
case 0:
ti1 = "NEW R";
ico = "Map-Marker-Push-Pin-1-"+color+"-icon.png";
break;
case 1:
ti1 = "NEW P";
ico = "Map-Marker-Marker-Outside-"+color+"-icon.png";
break;
}
break;
case "PHOTO":
ti1 = "Photo";
ico = "Map-Marker-Flag-1-Right-" + color + "-icon.png";
break;
default:
ti1 = "unknowm";
ico = "Map-Marker-Chequered-Flag-Right-" + color + "-icon.png";
break;
}
const title = ti1 + " " + ti2;
const icon = iconBase + ico;
innerScript += "marker = new google.maps.Marker({" +
"position: {lat:"+lat+",lng:"+lng+"}," +
"map: map," +
"title: '" + title + "'," +
"icon: '"+ icon + "'"+
"});\n";
if ( 0 === i) { break; }// weniger geht nicht
}
}
const style = document.createElement("style");
style.innerHTML= `#map { height: 100%; }
html, body { height: 100%; margin: 0; padding: 0;}`;
head.appendChild(style);
body.insertAdjacentHTML("afterBegin", '');
let script = document.createElement("script");
script.type = "text/javascript";
if(isCheckedS2) {
script.innerHTML=`
class S2Overlay{constructor(){this.polyLines=[]}check_map_bounds_ready(t){return!!t&&void 0!==t.getBounds&&void 0!==t.getBounds()}until(t,e){let n=r=>{t(e)?r():setTimeout(t=>n(r),400)};return new Promise(n)}updateGrid(t,e,n,r=1,o=null,l=null){this.polyLines.forEach(t=>{t.setMap(null)});let a=this.drawCellGrid(t,e,n,r);return null!==o&&this.drawCellGrid(t,o,l,2),a}async drawCellGrid(t,e,n,r=1){await this.until(this.check_map_bounds_ready,t);let o=t.getBounds(),l={},a=[];if(e>=2&&e0;){$=a.pop();let s=$.getNeighbors();for(let c=0;ce[1]?e[0]>e[2]?0:2:e[1]>e[2]?1:2},r=function(t,e){var n,r;switch(t){case 0:n=e[1]/e[0],r=e[2]/e[0];break;case 1:n=-e[0]/e[1],r=e[2]/e[1];break;case 2:n=-e[0]/e[2],r=-e[1]/e[2];break;case 3:n=e[2]/e[0],r=e[1]/e[0];break;case 4:n=e[2]/e[1],r=-e[0]/e[1];break;case 5:n=-e[1]/e[2],r=-e[0]/e[2];break;default:throw{error:"Invalid face"}}return[n,r]};e.XYZToFaceUV=function(t){var e=n(t);t[e]<0&&(e+=3);var o=r(e,t);return[e,o]},e.FaceUVToXYZ=function(t,e){var n=e[0],r=e[1];switch(t){case 0:return[1,n,r];case 1:return[-n,1,r];case 2:return[-n,-r,1];case 3:return[-1,-r,-n];case 4:return[r,-1,-n];case 5:return[r,n,-1];default:throw{error:"Invalid face"}}};var o=function(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))};e.STToUV=function(t){return[o(t[0]),o(t[1])]};var l=function(t){return t>=0?.5*Math.sqrt(1+3*t):1-.5*Math.sqrt(1-3*t)};e.UVToST=function(t){return[l(t[0]),l(t[1])]},e.STToIJ=function(t,e){var n=1<=0;i--){var u=1<=0;n--)r=g-n,o=c[n],l=0,i=0,"1"===o?i=1:"2"===o?(l=1,i=1):"3"===o&&(l=1),a(u=Math.pow(2,r-1),_,l,i),_.x+=u*l,_.y+=u*i;if(s%2==1){var f=_.x;_.x=_.y,_.y=f}return e.S2Cell.FromFaceIJ(parseInt(s),[_.x,_.y],r)},e.S2Cell.FromLatLng=function(t,n){if(!t.lat&&0!==t.lat||!t.lng&&0!==t.lng)throw Error("Pass { lat: lat, lng: lng } to S2.S2Cell.FromLatLng");var r=e.LatLngToXYZ(t),o=e.XYZToFaceUV(r),l=e.UVToST(o[1]),a=e.STToIJ(l,n);return e.S2Cell.FromFaceIJ(o[0],a,n)},e.S2Cell.FromFaceIJ=function(t,n,r){var o=new e.S2Cell;return o.face=t,o.ij=n,o.level=r,o},e.S2Cell.prototype.toString=function(){return"F"+this.face+"ij["+this.ij[0]+","+this.ij[1]+"]@"+this.level},e.S2Cell.prototype.getLatLng=function(){var t=e.IJToST(this.ij,this.level,[.5,.5]),n=e.STToUV(t),r=e.FaceUVToXYZ(this.face,n);return e.XYZToLatLng(r)},e.S2Cell.prototype.getCornerLatLngs=function(){for(var t=[],n=[[0,0],[0,1],[1,1],[1,0]],r=0;r<4;r++){var o=e.IJToST(this.ij,this.level,n[r]),l=e.STToUV(o),a=e.FaceUVToXYZ(this.face,l);t.push(e.XYZToLatLng(a))}return t},e.S2Cell.prototype.getFaceAndQuads=function(){var t=i(this.ij[0],this.ij[1],this.level,this.face);return[this.face,t]},e.S2Cell.prototype.toHilbertQuadkey=function(){var t=i(this.ij[0],this.ij[1],this.level,this.face);return this.face.toString(10)+"/"+t.join("")},e.latLngToNeighborKeys=e.S2Cell.latLngToNeighborKeys=function(t,n,r){return e.S2Cell.FromLatLng({lat:t,lng:n},r).getNeighbors().map(function(t){return t.toHilbertQuadkey()})},e.S2Cell.prototype.getNeighbors=function(){var t=function(t,n,r){var o=1<=0&&n[1]>=0&&n[0]o&&(r=r.substr(0,o)),l=u.fromString(n.toString(10),!0,10).toString(2);l.length30)throw Error("'level' is not a number between 1 and 30 (but it should be)");return e.S2Cell.FromLatLng({lat:t,lng:n},r).toHilbertQuadkey()},e.stepKey=function(e,n){var r,o=t.dcodeIO&&t.dcodeIO.Long||require("long"),l=e.split("/"),a=l[0],i=l[1],u=l[1].length,$=o.fromString(i,!0,4);n>0?r=$.add(Math.abs(n)):n<0&&(r=$.subtract(Math.abs(n)));var s=r.toString(4);for("0"===s&&console.warning(Error("face/position wrapping is not yet supported"));s.length' +
'' +
' | Wayspot Nominations | ' +
'Wayspot Edits | Photo | ' +
'total |
---|
classic/redacted | ' +
'Prime/Pokémon Go |
' +
'');
const innertable = document.getElementById("gamesTBbody");
let redg, redp, prig, prip, edig, edip, phog, phop;
redg = redp = prig = prip = edig = edip = phog = phop = 0;
// Zählen
for (let i = 0; i < PoGoStats.length; i++) {
switch (PoGoStats[i].typ) {
case "EDIT":
edig++;
if (PoGoStats[i].pogo) { edip++; }
break;
case "NEW":
switch (PoGoStats[i].subtyp) {
case 0:
redg++;
if (PoGoStats[i].pogo) { redp++; }
break;
case 1:
prig++;
if (PoGoStats[i].pogo) { prip++; }
break;
default:
console.warn("PoGoTable: falscher subtyp: " + PoGoStats[i].subtyp);
}
break;
case "PHOTO":
phog++;
if (PoGoStats[i].pogo) { phop++; }
break;
default:
console.warn(selfname + " falscher typ: " + PoGoStats[i].typ);
}
}
const revg = redg + prig + edig + phog;
const revp = redp + prip + edip + phop;
const redpp = redg > 0 ? (100*redp/redg).toFixed(2) : " -- ";
const pripp = prig > 0 ? (100*prip/prig).toFixed(2) : " -- ";
const edipp = edig > 0 ? (100*edip/edig).toFixed(2) : " -- ";
const revpp = revg > 0 ? (100*revp/revg).toFixed(2) : " -- ";
const phopp = phog > 0 ? (100*phop/phog).toFixed(2) : " -- ";
// Tabelle füllen
const redgp = revg > 0 ? (100*redg/revg).toFixed(2) : " -- ";
const prigp = revg > 0 ? (100*prig/revg).toFixed(2) : " -- ";
const edigp = revg > 0 ? (100*edig/revg).toFixed(2) : " -- ";
const phogp = revg > 0 ? (100*phog/revg).toFixed(2) : " -- ";
innertable.insertAdjacentHTML("beforeEnd", 'reviews total | ' + redg + " | "+redgp+"% | "+
prig + " | "+prigp+"% | " + edig + " | "+edigp+"% | " + phog + " | "+phogp+"% | " + revg + " |
");
// PoGo Prozente
const redgpp = revp > 0 ? (100*redp/revp).toFixed(2) : " -- ";
const prigpp = revp > 0 ? (100*prip/revp).toFixed(2) : " -- ";
const edigpp = revp > 0 ? (100*edip/revp).toFixed(2) : " -- ";
const phogpp = revp > 0 ? (100*phop/revp).toFixed(2) : " -- ";
innertable.insertAdjacentHTML("beforeEnd", ' | thereof Pokémon | ' + redp + " | "+redgpp+"% | "+ prip +
" | "+prigpp+"% | " + edip + " | "+edigpp+"% | " + phop + " | "+phogpp+"% | " + revp + " |
");
innertable.insertAdjacentHTML("beforeEnd", ' | in percent | ' + redpp + '% | '+ pripp +
'% | ' + edipp + '% | ' + phopp + "% | " + revpp + "% |
");
}
// ---
// test darkMode
const _props = window.wfes.g.properties();
if ("DISABLED" === _props.darkMode) {
const style = myStyle + myStyle_nodark;
window.wfes.f.addCSS(myCssId, style);
} else {
window.wfes.f.addCSS(myCssId, myStyle);
}
addDivs();
showStatsTable();
showGamesTable();
buttonFuncs();
}
/* =========== MAIN ================================ */
// window.setTimeout(init, 200);
init(); // die promises sollten es richten :-)
// install Event Handlers
window.addEventListener("WFESReviewPageLoaded", () => {setTimeout(handleReview, 2000);});
window.addEventListener("WFESProfileLoaded", handleProfile);
window.addEventListener("WFESHomePageLoaded", handleShowcase);
console.log("Script loaded:", GM_info.script.name, "v" + GM_info.script.version);
})();