Opens the Google Maps editor based on WME's map center.
当前为
// ==UserScript==
// @name WME Open GMaps Editor
// @namespace https://github.com/WazeDev/wme-open-gmaps-editor
// @version 0.0.3
// @description Opens the Google Maps editor based on WME's map center.
// @author Gavin Canon-Phratsachack (https://github.com/gncnpk)
// @match https://beta.waze.com/*editor*
// @match https://www.waze.com/*editor*
// @exclude https://www.waze.com/*user/*editor/*
// @exclude https://www.waze.com/discuss/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=waze.com
// @license MIT
// @grant none
// ==/UserScript==
(function() {
'use strict';
let wmeSdk;
const zoomLevels = {
1: 52428800,
2: 26214400,
3: 13107200,
4: 6553600,
5: 3276800,
6: 1638400,
7: 819200,
8: 409600,
9: 204800,
10: 102400,
11: 51200,
12: 25600,
13: 12800,
14: 6400,
15: 3200,
16: 1600,
17: 800,
18: 400,
19: 200,
20: 100,
21: 50,
22: 25
}
window.SDK_INITIALIZED.then(initialize)
async function initialize() {
wmeSdk = await getWmeSdk({
scriptId: 'wme-open-gmaps-editor',
scriptName: 'WME Open GMaps Editor'
})
wmeSdk.Events.on({eventHandler: replaceGoogleLink, eventName: "wme-map-move-end"})
wmeSdk.Events.on({eventHandler: replaceGoogleLink, eventName: "wme-map-zoom-changed"})
replaceGoogleLink();
}
function replaceGoogleLink() {
const coords = wmeSdk.Map.getMapCenter();
const mapZoom = wmeSdk.Map.getZoomLevel();
let url = `https://www.google.com/maps/place/@${coords.lat},${coords.lon},${zoomLevels[mapZoom]}m/data=!10m2!1e3!2e14!5m1!1e1`
document.getElementsByClassName("wz-map-ol-control-google-map-permalink")[0].children[0].href = url;
}
})();