// ==UserScript== // @name WPlace Go To via Google Map Link // @namespace http://tampermonkey.net/ // @version 1.0.2 // @description Adds a button to teleport to a place via a Google Maps URL // @author vladbarcelo // @match https://wplace.live/* // @license GPL3 // @grant unsafeWindow // @connect * // @run-at document-start // @downloadURL none // ==/UserScript== (function() { const interval = setInterval(() => { if (!document.querySelector('#goToMapPlaceBtn')) { document.querySelector('.flex.flex-col.gap-4.items-center').insertAdjacentHTML('beforeend', ``) const button = document.getElementById('goToMapPlaceBtn'); if (!button) return button.addEventListener('click', function() { const googleUrl = prompt('Enter Google Map URL') if (!googleUrl) return const [lat, lng] = googleUrl.split('?')[0].split('@')[1].split(',').map((v) => Number(v)) if (Number.isNaN(lat) || Number.isNaN(lng)) { alert('Bad URL entered, unable to parse') return } const wplaceData = { lat, lng, zoom: 13 } localStorage.setItem('location', JSON.stringify(wplaceData)) location.reload() }); } else { clearInterval(interval) } }, 1000) })();