-
Notifications
You must be signed in to change notification settings - Fork 1
/
iitc-glympsemap.user.js
795 lines (730 loc) · 36 KB
/
iitc-glympsemap.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
// ==UserScript==
// @name IITC plugin: Glympse
// @category Layer
// @author MaxEtMoritz
// @version 0.0.1
// @namespace https://github.com/MaxEtMoritz/iitc-glympse
// @downloadURL https://github.com/MaxEtMoritz/iitc-glympse/raw/master/iitc-glympsemap.user.js
// @updateURL https://github.com/MaxEtMoritz/iitc-glympse/raw/master/iitc-glympsemap.user.js
// @description View a Glympse tag directly on the Intel map.
// @match *://intel.ingress.com/*
// @grant none
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeBAMAAADJHrORAAAAKlBMVEUA9DhAebw5b7Y5b7Y5b7Y5b7ZYhsH///+fudzi6vRIpdttlclPwO45b7bf8WGPAAAAAXRSTlMAQObYZgAAANhJREFUGNNlkTsOwjA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p9kvbegQt77lXGAaMys7hhWHlnJD+LTWJTf2RtSIwoB0uH+VF+FmER7jsG+ln6nTL9d/H0sygLHtN6FmUMTSTRZGBZZO80KCSaNrBIy/FFoyGEGH33+P0F6jMrr2+zQxUAAAAASUVORK5CYII=
// ==/UserScript==
function wrapper(PluginInfo) {
// ensure plugin framework is there, even if iitc is not yet loaded
// eslint-disable-next-line func-names
if (typeof window.plugin !== 'function') window.plugin = function () { };
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
// eslint-disable-next-line func-names
window.plugin.glympse = function () { };
// #region global vars
let user = '';
let password = '';
let apiKey = '';
let glympsetag = '';
let updateSpeed = 5000;
/** @type {string} */
let accesstoken;
/** @type {Member[]} */
let allMembers = [];
/** @type {L.LayerGroup} */
let glympseLayers;
let next = 0;
let updateLoop = null;
const style = /* css */`
.glympse-arrowhead{
background:
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHMAAAA6CAYAAACDFGZCAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV\
9bpSKVDmaQopChOlkQFXGUKhbBQmkrtOpgcukXNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APE0clJ0UVK/F9SaBHjwXE/3t173L0D/M0qU82eCUDVLCO\
diIu5/KoYfEUQEYQhYERipp7MLGbhOb7u4ePrXYxneZ/7cwwoBZMBPpF4jumGRbxBPLNp6Zz3iQVWlhTic+Jxgy5I/Mh12eU3ziWH/TxTMLLpeWKB\
WCx1sdzFrGyoxNPEUUXVKN+fc1nhvMVZrdZZ+578haGCtpLhOs1hJLCEJFIQIaOOCqqwEKNVI8VEmvbjHv6I40+RSyZXBYwcC6hBheT4wf/gd7dmc\
WrSTQrFgd4X2/4YBYK7QKth29/Htt06AQLPwJXW8deawOwn6Y2OFj0CwtvAxXVHk/eAyx1g6EmXDMmRAjT9xSLwfkbflAcGb4H+Nbe39j5OH4Asdb\
V8AxwcAmMlyl73eHdfd2//nmn39wOB03Kti5BSDg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fRM9ebl6Wafnt2CADP8eBFAUQkID7JW91+XxU6Y0Dxf94HY8wmIvnb2nMGgoE\
/pQbN//M//FPBNA2Ew2EYBoWqqJBLMuRSCeVSGZqqwTAM2NaGVt7zGCJ6HhUIBhAMBRvTirtrpQaFoRs1s0OoejMhBKIkQZI8vYSQqtb1W6ueVkJ+\
zAFA4cp7kqHof2/o5ilfQCS25cCxvCpPIIIX8jYKl2aX8Q3v31yvN8tcF8BGGOZ5uI7DeJ7/FZHER/79rz7/y7tcJZEM3fg7atBZyScR27bh2M5tr\
aIIQg6bVlbt8wK3w7Drup5WkTzy3tuv/pKrGaf8pK5o5y3TjgkCD0EkTBSJwxPB4Tiu9oEhrKbhwN1eex9Yepuvk21er7elu2NFsCGUY67LMcbAcV\
xJEMkvfv43v//ODuOUH9M1/SHLtJKbYVIUxUMDcBet1TDLcVxJIMIvfvSDb70DAP8PVJAbPuuLQskAAAAASUVORK5CYII=')
left
no-repeat;
background-size: cover;
}
.glympse-arrowhead.expired{
background-position: right;
}
`;
// #endregion
/**
* Enum describing the travel modes supported by Glympse
* @const
* @readonly
* @enum {string}
*/
const travelMode = Object.freeze({
drive: 'car',
cycle: 'bike',
walk: 'foot',
transit: 'public transport',
airline: 'plane',
});
/**
* All important data for a Glympse member.
* @typedef {object} Member
* @property {string} id - Member's Glympse ID
* @property {string} invite - ticket ID for this member
* @property {boolean | undefined} expired - if ticket is expired
* @property {L.Marker} marker - Marker at the member's last known position
* @property {L.Polyline} line - member's location history
* @property {string} name - member's nickname
* @property {number} next - latest event timestamp
* @property {string | undefined} avatar - url to the member's avatar image
* @property {string | undefined} travelType - how the member is travelling; e.g. walk, drive, cycle
* @property {Date} last - last time location updated
* @property {number | undefined} heading - last heading of the member, if known
* @property {number | undefined} speed - last speed of the member, if known. in km/h
*/
/**
* @callback Predicate
* @template T type of elements
* @param {T} value value
* @param {number} index index in array
* @param {T[]} obj the array
* @returns {boolean} if this is the one we want
*/
/**
* Utility function to find the last element in an {@link array} matching the specified {@link predicate}.
* This is achieved by reversing the array and then calling {@link Array.find()|find()} on it.
* There is a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast findLast()} function, but support in browsers is limited.
* if present, this one is used instead.
* @template T - Type of the array elements
* @param {T[]} array - the array to search
* @param {Predicate<T>} predicate - the condition the element has to match.
* @returns {T | undefined} - the last matching array element or {@link undefined} if none was found.
*/
function findLast(array, predicate) {
if (array.findLast) { return array.findLast(predicate); }
return array.slice().reverse().find(predicate);
}
/**
* Utility function to contact Glympse API and auto-add access token.
* @param {string} endpointAndQuery API endpoint and querystring, no leading slash.
* @param {RequestInit} config fetch request configuration
* @param {boolean} addAccessToken add the token or not? set false for e.g. login request.
* @returns {Promise<any>} Promise that resolves to JSON response if everything worked ("response" part of api response without result and meta)
* @throws {Error} If API errors occur, a string with error detail is thrown.
*/
async function glympseApi(endpointAndQuery, config = {}, addAccessToken = true) {
if (addAccessToken) {
if (!config.headers) { config.headers = {}; }
config.headers.Authorization = `Bearer ${accesstoken}`;
}
const response = await fetch(`https://api.glympse.com/v2/${endpointAndQuery}`, config);
if (!response.ok) {
throw new Error(`${response.status} - ${response.statusText}: ${await response.text()}`);
}
return response.json().then((v) => {
if (v.result && v.result !== 'ok') {
if (v.meta && v.meta.error) {
throw new Error(`${v.meta.error}${v.meta.error_detail ? ` - ${v.meta.error_detail}` : ''}`);
} else {
throw new Error(v.result);
}
} else {
return v.response ?? v;
}
});
}
// #region https://muffinman.io/blog/javascript-time-ago-function/
const MONTH_NAMES = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December',
];
function getFormattedDate(date, prefomattedDate = false, hideYear = false) {
const day = date.getDate();
const month = MONTH_NAMES[date.getMonth()];
const year = date.getFullYear();
const hours = date.getHours();
let minutes = date.getMinutes();
if (minutes < 10) {
// Adding leading zero to minutes
minutes = `0${minutes}`;
}
if (prefomattedDate) {
// Today at 10:20
// Yesterday at 10:20
return `${prefomattedDate} at ${hours}:${minutes}`;
}
if (hideYear) {
// 10. January at 10:20
return `${day}. ${month} at ${hours}:${minutes}`;
}
// 10. January 2017. at 10:20
return `${day}. ${month} ${year}. at ${hours}:${minutes}`;
}
// --- Main function
function timeAgo(dateParam) {
if (!dateParam) {
return null;
}
const date = typeof dateParam === 'object' ? dateParam : new Date(dateParam);
const DAY_IN_MS = 86400000; // 24 * 60 * 60 * 1000
const today = new Date();
const yesterday = new Date(today - DAY_IN_MS);
const seconds = Math.round((today - date) / 1000);
const minutes = Math.round(seconds / 60);
const isToday = today.toDateString() === date.toDateString();
const isYesterday = yesterday.toDateString() === date.toDateString();
const isThisYear = today.getFullYear() === date.getFullYear();
if (seconds < 5) {
return 'now';
} if (seconds < 60) {
return `${seconds} seconds ago`;
} if (seconds < 90) {
return 'about a minute ago';
} if (minutes < 60) {
return `${minutes} minutes ago`;
} if (isToday) {
return getFormattedDate(date, 'Today'); // Today at 10:20
} if (isYesterday) {
return getFormattedDate(date, 'Yesterday'); // Yesterday at 10:20
} if (isThisYear) {
return getFormattedDate(date, false, true); // 10. January at 10:20
}
return getFormattedDate(date); // 10. January 2017. at 10:20
}
// #endregion
// #region https://github.com/bbecquet/Leaflet.RotatedMarker
/* eslint-disable no-underscore-dangle, camelcase, func-names */
function setupRotatedMarker() {
// save these original methods before they are overwritten
const proto_initIcon = L.Marker.prototype._initIcon;
const proto_setPos = L.Marker.prototype._setPos;
const oldIE = (L.DomUtil.TRANSFORM === 'msTransform');
L.Marker.addInitHook(function () {
const iconOptions = this.options.icon && this.options.icon.options;
let iconAnchor = iconOptions && this.options.icon.options.iconAnchor;
if (iconAnchor) {
iconAnchor = (`${iconAnchor[0]}px ${iconAnchor[1]}px`);
}
this.options.rotationOrigin = this.options.rotationOrigin || iconAnchor || 'center bottom';
this.options.rotationAngle = this.options.rotationAngle || 0;
// Ensure marker keeps rotated during dragging
this.on('drag', (e) => { e.target._applyRotation(); });
});
L.Marker.include({
_initIcon() {
proto_initIcon.call(this);
},
_setPos(pos) {
proto_setPos.call(this, pos);
this._applyRotation();
},
_applyRotation() {
if (this.options.rotationAngle) {
this._icon.style[`${L.DomUtil.TRANSFORM}Origin`] = this.options.rotationOrigin;
if (oldIE) {
// for IE 9, use the 2D rotation
this._icon.style[L.DomUtil.TRANSFORM] = `rotate(${this.options.rotationAngle}deg)`;
} else {
// for modern browsers, prefer the 3D accelerated version
this._icon.style[L.DomUtil.TRANSFORM] += ` rotateZ(${this.options.rotationAngle}deg)`;
}
}
},
setRotationAngle(angle) {
this.options.rotationAngle = angle;
this.update();
return this;
},
setRotationOrigin(origin) {
this.options.rotationOrigin = origin;
this.update();
return this;
},
});
}
/* eslint-enable no-underscore-dangle, camelcase, func-names */
// #endregion
/**
* Update the popup for a specific {@link Member}
* @param {Member} m - the member to update
*/
function updatePopup(m) {
let htmlstring = /* html */`
<div style="width:180px;">
<h3 style="text-align:center;">${m.name}</h3>
`;
if (m.avatar) {
htmlstring += /* html */`
<img src="${m.avatar}" width="90" height="90" style="margin-left:45px;">
`;
}
if (m.expired) { htmlstring += '<br>Sharing Expired.'; }
htmlstring += /* html */`
<dl>
<dt>travelling:</dt>
<dd>By ${travelMode[m.travelType]}</dd>
`;
if (typeof (m.speed) === 'number') {
htmlstring += /* html */`
<dt>speed:</dt>
<dd>${m.speed.toFixed(1)} km/h</dd>
`;
}
htmlstring += /* html */`
<dt>last update:</dt>
<dd>${timeAgo(m.last)}</dd>
</dl>
</div>
`;
m.marker.setPopupContent(htmlstring);
}
function startUpdateLoop() {
updateLoop = setInterval(async () => {
const groups = await glympseApi(`groups/${encodeURIComponent(glympsetag)}/events?next=${next}`);
// beware: events or group response type possible!
if (groups.type === 'events') {
next = groups.next;
groups.items.forEach((item) => {
if (item.type === 'invite') {
// new user sharing
const existingMember = allMembers.find((m) => m.id === item.member);
if (existingMember) {
existingMember.invite = item.invite;
existingMember.expired = false;
existingMember.next = 0;
existingMember.line.setLatLngs([]);
const ic = existingMember.marker.getIcon();
ic.options.className = 'glympse-arrowhead';
existingMember.marker.setIcon(ic);
updatePopup(existingMember);
} else {
const newMember = {
id: item.member,
name: item.member, // user's nickname not known yet, will get sent on user update --> "properties" array (bc. next is 0)
invite: item.invite,
next: 0,
marker: L.marker([0, 0], {
title: item.member,
draggable: false,
icon: L.divIcon({
className: 'glympse-arrowhead',
iconSize: [29, 30],
iconAnchor: [15, 15],
}),
rotationOrigin: 'center center',
}).bindPopup().addTo(glympseLayers),
line: L.polyline([], { color: 'red', interactive: false }).addTo(glympseLayers),
};
allMembers.push(newMember);
updatePopup(newMember);
}
} else {
console.debug(`unhandled event ${item.type}: `, item);
}
// there is type 'join', probably new user watching the glympse tag
// TODO: is there a type 'leave' event or similar? how exactly is it called? - probably the ticket is set to expired?
});
} else {
// type == 'group'
next = groups.events;
// TODO: does the response include all members then? i assume so...
console.debug('present member count: ', allMembers.length, ', received member count: ', groups.members.length);
groups.members.forEach((m) => {
const existingMember = allMembers.find((pm) => pm.id === m.id);
if (existingMember) { existingMember.invite = m.invite; } else {
const newMember = {
id: m.id,
name: m.id, // user's nickname not known yet, will get sent on user update --> "properties" array (bc. next is 0)
invite: m.invite,
next: 0,
marker: L.marker([0, 0], {
title: m.name,
draggable: false,
icon: L.divIcon({
className: 'glympse-arrowhead',
iconSize: [29, 30],
iconAnchor: [15, 15],
}),
rotationOrigin: 'center center',
}).bindPopup().addTo(glympseLayers),
line: L.polyline([], { color: 'red', interactive: false }).addTo(glympseLayers),
};
allMembers.push(newMember);
updatePopup(newMember);
}
});
}
const tooManyPromises = [];
allMembers.forEach((m) => {
if (m.expired) { return; }
tooManyPromises.push(glympseApi(`invites/${m.invite}?next=${m.next}&uncompressed=true`).then((response) => {
// update all member's locations
if (response.location) {
response.location.forEach((l) => {
m.line.addLatLng([l[1] / 1000000, l[2] / 1000000]);
});
m.marker.setLatLng(m.line.getLatLngs()[m.line.getLatLngs().length - 1]);
const latestLocationWithAdditionalInfo = findLast(response.location, ((e) => e.length >= 5));
if (latestLocationWithAdditionalInfo) {
// speed is null if denied by user, null * 0.036 = 0 ==> check for null before multiplication
if (typeof latestLocationWithAdditionalInfo[3] === 'number') {
m.speed = latestLocationWithAdditionalInfo[3] * 0.036;
}
m.heading = latestLocationWithAdditionalInfo[4];
m.marker.setRotationAngle(m.heading);
}
}
m.next = response.next;
m.last = new Date(response.last);
// handle nickname change
let newNickName;
if (response.properties && response.properties.findIndex((prop) => prop.n === 'name') !== -1) {
newNickName = response.properties.find((prop) => prop.n === 'name');
} else if (response.data && response.data.findIndex((prop) => prop.n === 'name') !== -1) {
newNickName = response.data.find((prop) => prop.n === 'name');
}
if (newNickName) {
m.name = newNickName.v;
m.marker.options.title = newNickName.v;
}
// handle invite expiry change
let expired;
if (response.properties) {
expired = response.properties.find((prop) => prop.n === 'expired')?.v;
} else if (response.data) {
expired = response.data.find((prop) => prop.n === 'expired')?.v;
}
if (typeof (expired) === 'boolean') {
m.expired = expired;
const ic = m.marker.getIcon();
if (m.expired) {
ic.options.className = 'glympse-arrowhead expired';
} else {
ic.options.className = 'glympse-arrowhead';
}
m.marker.setIcon(ic);
}
// avatar change
m.avatar = response.properties
?.find((p) => p.n === 'avatar')
?.v
?? response.data
?.find((p) => p.n === 'avatar')
?.v
?? m.avatar;
// travel type change
m.travelType = response.properties
?.find((p) => p.n === 'travel_mode')
?.v
.type
?? response.data
?.find((p) => p.n === 'travel_mode')
?.v
.type
?? m.travelType;
updatePopup(m);
}));
});
await Promise.all(tooManyPromises);
}, updateSpeed);
}
async function fetchInitialData() {
let groups;
try {
groups = await glympseApi(`groups/${encodeURIComponent(glympsetag)}`);
} catch (e) {
if (e.message) {
alert(/* html */`Error while loading Glympse tag:<br>
<code>${e.message}</code><br>
please make sure you entered an existing Glympse tag.`, true);
} else {
alert(e);
}
return;
}
allMembers = groups.members;
next = groups.events + 1;
const tooManyPromises = [];
const latLngs = [];
allMembers.forEach((m) => {
let thisMemberHasError = false;
tooManyPromises.push(glympseApi(`invites/${m.invite}?uncompressed=true`).catch((e) => {
// sometimes the invite code is set in group members list but upon trying to retrieve it the API complains that it's no longer available.
// if that happens, just skip that member.
thisMemberHasError = true;
if (e.message && !e.message.includes('Unable to retrieve invite_code')) {
alert(e.message);
} else if (!e.message) {
alert(e);
}
allMembers.splice(allMembers.indexOf(m), 1);
}).then((response) => {
if (thisMemberHasError) return;
response.location.forEach((l) => {
latLngs.push([l[1] / 1000000, l[2] / 1000000]);
});
const latestLocationWithAdditionalInfo = findLast(response.location, ((e) => e.length >= 5));
if (latestLocationWithAdditionalInfo) {
// speed is null if denied by user, null * 0.036 = 0 ==> check for null before multiplication
if (typeof latestLocationWithAdditionalInfo[3] === 'number') {
m.speed = latestLocationWithAdditionalInfo[3] * 0.036;
}
m.heading = latestLocationWithAdditionalInfo[4];
}
m.name = response.properties.find((p) => p.n === 'name').v;
m.next = response.next;
m.last = new Date(response.last);
m.expired = response.properties.find((p) => p.n === 'expired')?.v;
m.avatar = response.properties.find((p) => p.n === 'avatar')?.v;
m.travelType = response.properties.find((p) => p.n === 'travel_mode')?.v.type;
m.line = L.polyline(latLngs, { color: 'red', interactive: false }).addTo(glympseLayers);
let className = 'glympse-arrowhead';
if (m.expired) { className += ' expired'; }
m.marker = L.marker(latLngs[latLngs.length - 1], {
title: m.name,
draggable: false,
icon: L.divIcon({
className,
iconSize: [29, 30],
iconAnchor: [15, 15],
}),
rotationOrigin: 'center center',
}).bindPopup().addTo(glympseLayers);
if (m.heading) {
m.marker.setRotationAngle(m.heading);
}
updatePopup(m);
}));
});
await Promise.all(tooManyPromises);
startUpdateLoop();
}
async function logIntoApi() {
try {
const response = await glympseApi(
`account/login?id=${encodeURIComponent(user)}&password=${encodeURIComponent(password)}&api_key=${apiKey}`,
{ method: 'POST' },
false,
);
accesstoken = response.access_token;
// TODO: handle expires_in
/*
* probably not need to handle: according to the docs, this value is in seconds.
* when trying i got a value of 632720000.
* even if this would be milliseconds, it would last a bit more than a week...
*/
if (glympsetag) { fetchInitialData(); }
} catch (/** @type {Error} */ e) {
alert(/* html */`login unsuccessful:<br><code>${e.message}</code>`, true);
}
}
function openSettings() {
const dial = window.dialog({
html: /* html */`
<h3>API settings</h3>
<div>
<label for="glympseID">username:</label>
<input type="text" id="glympseID" value="${user ?? ''}" required>
</div>
<div>
<label for="glympsePassword">password:</label>
<input type="text" id="glympsePassword" value="${password ?? ''}" required>
</div>
<div>
<label for="glympseApiToken">API token:</label>
<input type="text" id="glympseApiToken" value="${apiKey ?? ''}" required>
<p>Possibilities to get the API token:</p>
<ul>
<li>Get yourself a trial token at <a href="https://developer.glympse.com/account/apps" target="_blank">Glympse Developers</a></li>
<li>Open a Glympse tag in browser with dev tools open.
Look for the login network request to the Glympse API and use the Glympse viewer's token.<br>
Note that this is against Glympse's ToS
</li>
</ul>
</div>
<h3>Other settings</h3>
<div>
<label for="glympsetag">Glympse tag:</label>
!<input type="text" id="glympsetag" title="don't enter the '!'" value="${glympsetag ?? ''}" required>
</div>
<div>
<label for="refreshrate">update speed:</label>
<input type="number" id="refreshrate" min="1000" value="${updateSpeed ?? 5000}" required>
<p>refresh rate in milliseconds.</p>
</div>
`,
buttons: [{
text: 'Save',
click: () => {
const settings = {
user: document.getElementById('glympseID').value,
password: document.getElementById('glympsePassword').value,
apiKey: document.getElementById('glympseApiToken').value,
glympsetag: document.getElementById('glympsetag').value,
updateSpeed: document.getElementById('refreshrate').value,
};
if (!/^[\p{L}_\d]*$/u.test(settings.glympsetag)) {
settings.glympsetag = null;
alert(`Glympse tag invalid. Only letters, digits or underscore allowed.
Don't add the '!'.
Unsetting it...`);
}
if (!settings.updateSpeed) { settings.updateSpeed = 5000; }
if (settings.updateSpeed < 1000) { settings.updateSpeed = 1000; }
clearInterval(updateLoop);
user = settings.user;
password = settings.password;
apiKey = settings.apiKey;
glympsetag = settings.glympsetag;
updateSpeed = settings.updateSpeed;
localStorage.setItem('plugin-glympse', JSON.stringify(settings));
glympseLayers.clearLayers();
allMembers = [];
if (user && password && apiKey && glympsetag) {
logIntoApi();
} else {
window.map.removeLayer(glympseLayers);
}
dial.dialog('close');
},
}],
title: 'Glympse Settings',
});
}
// #region Setup
const setup = function setup() {
// init script
setupRotatedMarker();
glympseLayers = new L.LayerGroup(null, { attribution: 'Realtime locations by <a href="https://glympse.com">Glympse</a>' });
const toolboxLink = document.getElementById('toolbox').appendChild(document.createElement('a'));
toolboxLink.addEventListener('click', openSettings);
toolboxLink.innerText = 'Glympse Settings';
toolboxLink.type = 'button';
const styleElem = document.head.appendChild(document.createElement('style'));
styleElem.innerText = style;
// glympseLayers.addTo(map)
// read settings from local storage
const jsonstring = localStorage.getItem('plugin-glympse');
if (jsonstring) {
const settings = JSON.parse(jsonstring);
user = settings.user;
password = settings.password;
apiKey = settings.apiKey;
glympsetag = settings.glympsetag;
updateSpeed = settings.updateSpeed;
}
window.map.addEventListener('overlayadd', (e) => {
if (e.name === 'Glympse') {
if (user && password && apiKey && glympsetag) {
if (!accesstoken) {
logIntoApi();
} else {
fetchInitialData();
}
} else {
alert('invalid settings.\nPlease complete them.', false, openSettings);
}
}
});
window.map.addEventListener('overlayremove', (e) => {
if (e.name === 'Glympse') {
if (updateLoop) {
clearInterval(updateLoop);
}
allMembers = [];
glympseLayers.clearLayers();
}
});
window.addLayerGroup('Glympse', glympseLayers);
if (window.isLayerGroupDisplayed('Glympse')) {
if (!user || !password || !apiKey) {
window.map.removeLayer(glympseLayers);
return;
}
// log in to glympse api
logIntoApi();
}
};
// #endregion
// PLUGIN END //////////////////////////////////////////////////////////
// add the script info data to the function as a property
setup.info = PluginInfo;
if (!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
// if IITC has already booted, immediately run the 'setup' function
if (window.iitcLoaded && typeof setup === 'function') setup();
}
/*
* wrapper end
* inject code into site context
*/
const script = document.createElement('script');
const 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);