mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-23 06:20:54 +00:00
Update developer mode. Make sure the extension will still work if dev mode is left on while the local dev server isn't running.
This commit is contained in:
parent
73df7bceae
commit
9de1ad501d
3 changed files with 27 additions and 14 deletions
|
@ -15,13 +15,26 @@ function ffz_init()
|
|||
|
||||
var debug = localStorage.ffzDebugMode == "true";
|
||||
|
||||
if ( debug )
|
||||
script.src = "//localhost:8000/script/script.js";
|
||||
else
|
||||
script.src = "//cdn.frankerfacez.com/script/script.min.js";
|
||||
if ( debug ) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "http://localhost:8000/dev_server", true);
|
||||
xhr.onload = function(e) {
|
||||
var resp = JSON.parse(xhr.responseText);
|
||||
console.log("FFZ: Development Server is present. Version " + resp.version + " running from: " + resp.path);
|
||||
script.src = "//localhost:8000/script/script.js";
|
||||
document.body.classList.add("ffz-dev");
|
||||
document.head.appendChild(script);
|
||||
};
|
||||
xhr.onerror = function(e) {
|
||||
console.log("FFZ: Development Server is not present. Using CDN.");
|
||||
script.src = "//cdn.frankerfacez.com/script/script.min.js";
|
||||
document.head.appendChild(script);
|
||||
};
|
||||
return xhr.send(null);
|
||||
}
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
if(head) head.appendChild(script);
|
||||
script.src = "//cdn.frankerfacez.com/script/script.min.js";
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
ffz_init();
|
Loading…
Add table
Add a link
Reference in a new issue