-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeoGuessr Pin Style Replacer-1.1.user.js
More file actions
63 lines (52 loc) · 2.31 KB
/
Copy pathGeoGuessr Pin Style Replacer-1.1.user.js
File metadata and controls
63 lines (52 loc) · 2.31 KB
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
// ==UserScript==
// @name GeoGuessr Pin Style Replacer
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Replaces new GeoGuessr markers with classic-style pins
// @author gummiangler
// @match https://www.geoguessr.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function replaceMarker(marker) {
const svg = marker.querySelector('svg');
if (!svg) return;
const image = svg.querySelector('image');
if (!image) return;
const src = image.getAttribute('href');
if (!src) return;
const classicMarker = document.createElement('div');
classicMarker.className = 'map-pin_mapPin__vG6pA result-map_roundPin__Ss8A9 map-pin_clickable__wa8cr';
classicMarker.innerHTML = `
<div class="styles_circle__hEhoz styles_variantFloating__YYaCX styles_colorWhite__Tjl0Y styles_borderColorWhite__YjsfD styles_borderSizeFactorOne__Qi3YW">
<div class="styles_rectangle__gM7BS" style="padding-top: 100%;">
<div class="styles_innerCircle__YpQ_Z">
<div class="styles_content__jovAP">
<img draggable="false" alt="" loading="lazy" decoding="async"
class="styles_image__vpfH1"
src="${src}"
style="position: absolute; height: 100%; width: 100%; inset: 0; object-fit: cover; color: transparent;">
</div>
</div>
</div>
</div>
`;
marker.replaceWith(classicMarker);
}
function initObserver() {
const observer = new MutationObserver(mutations => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.nodeType !== 1) continue;
if (node.matches('.polite-pin_wrapper__S5mx5')) {
replaceMarker(node);
}
node.querySelectorAll?.('.polite-pin_wrapper__S5mx5')?.forEach(replaceMarker);
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
}
window.addEventListener('load', initObserver);
})();