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-05-26 23:08:49 +02:00
|
|
|
|
var pageInfo;
|
|
|
|
|
var comms;
|
2018-05-13 13:49:25 +02:00
|
|
|
|
|
2018-05-13 21:05:11 +02:00
|
|
|
|
async function init(){
|
2017-12-17 22:56:07 +01:00
|
|
|
|
if(Debug.debug)
|
2017-12-29 23:34:40 +01:00
|
|
|
|
console.log("[uw::main] loading configuration ...");
|
2017-12-17 22:56:07 +01:00
|
|
|
|
|
2018-05-26 23:08:49 +02:00
|
|
|
|
comms = new CommsClient('content-client-port');
|
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
// load settings
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// var isSlave = true;
|
|
|
|
|
// await Settings.init(isSlave);
|
2018-05-26 23:08:49 +02:00
|
|
|
|
var settingsLoaded = await comms.requestSettings();
|
|
|
|
|
if(!settingsLoaded){
|
|
|
|
|
console.log("[uw::main] failed to get settings (settingsLoaded=",settingsLoaded,") Waiting for settings the old fashioned way");
|
|
|
|
|
comms.requestSettings_fallback();
|
|
|
|
|
await comms.waitForSettings();
|
|
|
|
|
console.log("[uw::main] settings loaded.");
|
|
|
|
|
}
|
|
|
|
|
// await Settings.init();
|
2018-04-25 20:39:52 +02:00
|
|
|
|
|
2018-05-13 21:05:11 +02:00
|
|
|
|
// za sporočilca poslušamo v vsakem primeru, tudi če je razširitev na spletnem mestu onemogočena
|
|
|
|
|
// we listen for messages in any case, even if extension is disabled on current site.
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// browser.runtime.onMessage.addListener(receiveMessage);
|
2018-04-25 20:39:52 +02:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// await SitesConf.init();
|
2018-05-13 21:05:11 +02:00
|
|
|
|
// če je trenutno mesto onemogočeno, potem zaključimo na tem mestu
|
|
|
|
|
// if current site is disabled, we quit here
|
2018-01-28 02:35:05 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(! SitesConf.isEnabled(window.location.hostname)){
|
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw:main] | site", window.location.hostname, "is blacklisted.");
|
2018-05-13 21:05:11 +02:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// return;
|
|
|
|
|
// }
|
2018-05-13 21:05:11 +02:00
|
|
|
|
|
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("[uw::main] configuration should be loaded now");
|
|
|
|
|
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
2018-05-13 21:05:11 +02:00
|
|
|
|
pageInfo = new PageInfo();
|
2018-05-26 23:08:49 +02:00
|
|
|
|
comms.setPageInfo(pageInfo);
|
2018-05-13 21:05:11 +02:00
|
|
|
|
|
|
|
|
|
if(Debug.debug){
|
|
|
|
|
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);
|
2017-12-31 18:26:59 +01:00
|
|
|
|
}
|
2018-05-24 20:50:37 +02:00
|
|
|
|
}
|
2018-01-20 22:59:31 +01:00
|
|
|
|
|
2018-05-26 23:08:49 +02:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// comms
|
|
|
|
|
// function receiveMessage(message, sender, sendResponse) {
|
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw::receiveMessage] we received a message.", message);
|
2018-01-20 22:59:31 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(message.cmd == "has-videos"){
|
|
|
|
|
// var anyVideos = GlobalVars.video != null;
|
2018-02-26 22:38:17 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw::receiveMessage] are there any videos on this page?", anyVideos, GlobalVars.video, this);
|
2018-02-26 22:38:17 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(BrowserDetect.usebrowser == "firefox")
|
|
|
|
|
// return Promise.resolve({response: {"hasVideos": anyVideos }});
|
2018-05-21 22:43:56 +02:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// try{
|
|
|
|
|
// sendResponse({response: {"hasVideos":anyVideos}});
|
|
|
|
|
// return true;
|
2018-05-21 22:43:56 +02:00
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// catch(chromeIsShitError){}
|
|
|
|
|
// return;
|
2018-05-21 22:43:56 +02:00
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// else if(message.cmd == "get-config"){
|
2018-01-08 22:48:45 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// var config = {};
|
|
|
|
|
// config.videoAlignment = ExtensionConf.miscFullscreenSettings.videoFloat;
|
|
|
|
|
// config.arConf = {};
|
|
|
|
|
// config.arConf.enabled_global = ExtensionConf.arDetect.enabled == "global";
|
2018-01-10 23:16:07 +01:00
|
|
|
|
|
|
|
|
|
|
2018-05-27 01:29:02 +02:00
|
|
|
|
// var keybinds = ExtensionConf.keyboard.shortcuts;
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw-bg::_uwbg_rcvmsg] Keybinds.fetch returned this:", keybinds);
|
2018-03-11 18:00:47 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// config.keyboardShortcuts = keybinds;
|
2018-01-10 23:16:07 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// // predvidevajmo, da je enako. Če je drugače, bomo popravili ko dobimo odgovor
|
|
|
|
|
// // assume current is same as global & change that when you get response from content script
|
|
|
|
|
// config.arConf.enabled_current = ArDetect.isRunning();
|
2018-01-10 23:16:07 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(BrowserDetect.usebrowser == "firefox")
|
|
|
|
|
// return Promise.resolve({response: config});
|
2018-01-10 23:16:07 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// try{
|
|
|
|
|
// sendResponse({response: config});
|
|
|
|
|
// }
|
|
|
|
|
// catch(chromeIsShitError){};
|
2018-01-27 20:13:23 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// return true;
|
|
|
|
|
// }
|
2018-01-08 22:48:45 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// else if(message.cmd == "force-ar"){
|
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw::receiveMessage] we're being commanded to change aspect ratio to", message.newAr);
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// if(message.arType == "legacy"){
|
|
|
|
|
// ArDetect.stop();
|
|
|
|
|
// Resizer.legacyAr(message.newAr);
|
2018-03-13 23:55:38 +01:00
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// else{
|
|
|
|
|
// ArDetect.stop();
|
|
|
|
|
// Resizer.setAr(message.newAr);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else if(message.cmd == "force-video-float"){
|
|
|
|
|
// if(Debug.debug)
|
|
|
|
|
// console.log("[uw::receiveMessage] we're aligning video to", message.newFloat);
|
|
|
|
|
|
|
|
|
|
// ExtensionConf.miscFullscreenSettings.videoFloat = message.newFloat;
|
2018-03-13 23:55:38 +01:00
|
|
|
|
// Settings.save(ExtensionConf);
|
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// else if(message.cmd == "stop-autoar"){
|
|
|
|
|
// ArDetect.stop();
|
|
|
|
|
// }
|
|
|
|
|
// else if(message.cmd == "update-settings"){
|
2018-03-13 23:55:38 +01:00
|
|
|
|
// if(Debug.debug){
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// console.log("[uw] we got sent new ExtensionConf to abide by:", cmd.newConf);
|
2018-03-13 23:55:38 +01:00
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// ExtensionConf = cmd.newConf;
|
2018-03-13 23:55:38 +01:00
|
|
|
|
// }
|
2018-05-24 20:50:37 +02:00
|
|
|
|
// // else if(message.cmd == "enable-autoar"){
|
|
|
|
|
// // if(Debug.debug){
|
|
|
|
|
// // console.log("[uw] enabling autoar.");
|
|
|
|
|
// // }
|
|
|
|
|
// // ExtensionConf.autoAr.mode == "blacklist";
|
|
|
|
|
// // Settings.save(ExtensionConf);
|
|
|
|
|
// // }
|
|
|
|
|
// // else if(message.cmd == "disable-autoar"){
|
|
|
|
|
// // if(Debug.debug){
|
|
|
|
|
// // console.log("[uw] disabling autoar.");
|
|
|
|
|
// // }
|
|
|
|
|
// // ExtensionConf.autoAr.mode == "disabled";
|
|
|
|
|
// // Settings.save(ExtensionConf);
|
|
|
|
|
// // }
|
|
|
|
|
// if(message.cmd == "testing"){
|
|
|
|
|
// if(Browserdetect.usebrowser = "firefox")
|
|
|
|
|
// return Promise.resolve({response: "test response hier"});
|
|
|
|
|
|
|
|
|
|
// sendResponse({response: "test response hier"});
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
2017-12-30 02:58:24 +01:00
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
|
init();
|