2018-01-24 23:15:54 +01:00
|
|
|
|
if(Debug.debug){
|
2017-09-24 01:54:46 +02:00
|
|
|
|
console.log("\n\n\n\n\n\n ——— Sᴛλʀᴛɪɴɢ Uʟᴛʀᴀᴡɪᴅɪꜰʏ ———\n << ʟᴏᴀᴅɪɴɢ ᴍᴀɪɴ ꜰɪʟᴇ >>\n\n\n\n");
|
2018-01-24 23:15:54 +01:00
|
|
|
|
try {
|
|
|
|
|
if(window.self !== window.top){
|
|
|
|
|
console.log("%cWe aren't in an iframe.", "color: #afc, background: #174");
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
console.log("%cWe are in an iframe!", "color: #fea, background: #d31", window.self, window.top);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("%cWe are in an iframe!", "color: #fea, background: #d31");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 13:49:25 +02:00
|
|
|
|
|
2018-08-30 00:56:15 +02:00
|
|
|
|
class UW {
|
|
|
|
|
constructor(){
|
|
|
|
|
this.pageInfo = undefined;
|
|
|
|
|
this.comms = undefined;
|
|
|
|
|
this.settings = undefined;
|
|
|
|
|
this.keybinds = undefined;
|
|
|
|
|
}
|
2018-08-07 23:31:28 +02:00
|
|
|
|
|
2018-08-30 00:56:15 +02:00
|
|
|
|
async init(){
|
|
|
|
|
if (Debug.debug) {
|
|
|
|
|
console.log("[uw::main] loading configuration ...");
|
|
|
|
|
}
|
2018-08-22 23:16:08 +02:00
|
|
|
|
|
2018-08-30 00:56:15 +02:00
|
|
|
|
// init() is re-run any time settings change
|
|
|
|
|
if (this.pageInfo) {
|
|
|
|
|
if(Debug.debug){
|
|
|
|
|
console.log("[uw::init] Destroying existing pageInfo", this.pageInfo);
|
|
|
|
|
}
|
|
|
|
|
this.pageInfo.destroy();
|
|
|
|
|
}
|
|
|
|
|
if (this.comms) {
|
|
|
|
|
this.comms.destroy();
|
|
|
|
|
}
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
2018-08-30 00:56:15 +02:00
|
|
|
|
if (!this.settings) {
|
|
|
|
|
var ths = this;
|
|
|
|
|
this.settings = new Settings(undefined, () => ths.init());
|
|
|
|
|
await this.settings.init();
|
2018-06-27 23:55:37 +02:00
|
|
|
|
}
|
2018-08-30 00:56:15 +02:00
|
|
|
|
|
|
|
|
|
this.comms = new CommsClient('content-client-port', this.settings);
|
|
|
|
|
|
|
|
|
|
// če smo razširitev onemogočili v nastavitvah, ne naredimo ničesar
|
|
|
|
|
// If extension is soft-disabled, don't do shit
|
|
|
|
|
if(! this.settings.canStartExtension()){
|
|
|
|
|
if(Debug.debug) {
|
|
|
|
|
console.log("[uw::init] EXTENSION DISABLED, THEREFORE WONT BE STARTED")
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
this.pageInfo = new PageInfo(this.comms, this.settings);
|
|
|
|
|
if(Debug.debug){
|
|
|
|
|
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", this.pageInfo);
|
|
|
|
|
}
|
|
|
|
|
this.comms.setPageInfo(this.pageInfo);
|
|
|
|
|
|
|
|
|
|
this.keybinds = new Keybinds(this.pageInfo);
|
|
|
|
|
this.keybinds.setup();
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log("[uw::init] FAILED TO START EXTENSION. Error:", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-12-31 18:26:59 +01:00
|
|
|
|
}
|
2018-05-24 20:50:37 +02:00
|
|
|
|
}
|
2018-08-30 00:56:15 +02:00
|
|
|
|
|
|
|
|
|
var uw = new UW();
|
|
|
|
|
uw.init();
|