Skip to content

Commit

Permalink
Add typeof check to bootstrap, eliminate OL references
Browse files Browse the repository at this point in the history
  • Loading branch information
mapomatic committed Sep 28, 2023
1 parent ec9d4ef commit 8cf8f42
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions WME ClickSaver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name WME ClickSaver
// @namespace https://greasyfork.org/users/45389
// @version 2023.09.07.001
// @version 2023.09.27.001
// @description Various UI changes to make editing faster and easier.
// @author MapOMatic
// @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
Expand All @@ -16,7 +16,7 @@

/* global W */
/* global I18n */
/* global OL */
/* global OpenLayers */
/* global WazeWrap */

(function main() {
Expand Down Expand Up @@ -668,7 +668,7 @@
// Note: this doesn't work in a MultiAction for some reason.
const newRoadType = isPedestrianTypeSegment(segment) ? 1 : 5;
const feature = new Segment({ geometry: oldGeom, roadType: newRoadType });
feature.state = OL.State.INSERT;
feature.state = OpenLayers.State.INSERT;
W.model.actionManager.add(new AddSeg(feature, {
createNodes: !0,
openAllTurns: W.prefs.get('enableTurnsByDefault'),
Expand Down Expand Up @@ -971,6 +971,7 @@
}

function init() {
logDebug('Initializing...');
UpdateObject = require('Waze/Action/UpdateObject');
UpdateFeatureAddress = require('Waze/Action/UpdateFeatureAddress');
MultiAction = require('Waze/Action/MultiAction');
Expand Down Expand Up @@ -1035,8 +1036,7 @@
}

function bootstrap() {
if (typeof require !== 'undefined' && W && W.loginManager && W.loginManager.events.register && W.map && W.loginManager.user) {
logDebug('Initializing...');
if (typeof W === 'object' && W.userscripts?.state.isReady) {
init();
} else {
logDebug('Bootstrap failed. Trying again...');
Expand Down Expand Up @@ -1206,7 +1206,7 @@
}

function sandboxBootstrap() {
if (WazeWrap && WazeWrap.Ready) {
if (WazeWrap?.Ready) {
WazeWrap.Interface.ShowScriptUpdate(SCRIPT_NAME, SCRIPT_VERSION, UPDATE_MESSAGE, FORUM_URL);
loadScriptUpdateMonitor();
sandboxLoadSettings();
Expand Down

0 comments on commit 8cf8f42

Please sign in to comment.