forked from SaiCode-DEV/Waze-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWME Vue.user.js
More file actions
60 lines (51 loc) · 1.61 KB
/
WME Vue.user.js
File metadata and controls
60 lines (51 loc) · 1.61 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
// ==UserScript==
// @name Vue Loader
// @namespace https://github.com/SaiCode-DEV
// @version 1.0.0
// @description Loads Vue.js into the current page if it is not already loaded.
// @author SaiCode
// @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
// @grant GM_xmlhttpRequest
// ==/UserScript==
/* global $ */
/* jshint esversion:6 */
(function main() {
"use strict";
const VUE_URL = "https://unpkg.com/vue@3/dist/vue.global.js";
async function init() {
const sandboxed = typeof unsafeWindow !== "undefined";
const pageWindow = sandboxed ? unsafeWindow : window;
// Check if Vue is already loaded
if (typeof pageWindow.Vue !== "undefined") {
console.log("Vue.js is already loaded.");
return;
}
console.log("Loading Vue.js...");
await new Promise((resolve, reject) => {
$.getScript(VUE_URL)
.done(() => {
console.log("Vue.js has been successfully loaded.");
resolve();
})
.fail((jqxhr, settings, exception) => {
console.error("Failed to load Vue.js:", exception);
reject(exception);
});
});
if (typeof pageWindow.Vue !== "undefined") {
console.log("Vue.js has been loaded successfully.");
} else {
console.error("Error loading Vue.js.");
}
}
function bootstrap(tries = 1) {
if (typeof $ !== "undefined") {
init();
} else if (tries < 100) {
setTimeout(() => bootstrap(tries + 1), 100);
} else {
console.error("Vue Loader could not be initialized.");
}
}
bootstrap();
})();