2017-09-24 01:54:46 +02:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("\n\n\n\n\n\n ——— Sᴛλʀᴛɪɴɢ Uʟᴛʀᴀᴡɪᴅɪꜰʏ ———\n << ʟᴏᴀᴅɪɴɢ ᴍᴀɪɴ ꜰɪʟᴇ >>\n\n\n\n");
|
2017-04-27 20:03:36 +02:00
|
|
|
|
|
2017-12-02 21:09:08 +01:00
|
|
|
|
// load all settings from localStorage:
|
2017-01-04 23:23:41 +01:00
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
async function main(){
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
// load settings
|
2017-12-29 23:34:40 +01:00
|
|
|
|
await Settings.init();
|
2017-12-17 22:56:07 +01:00
|
|
|
|
var scpromise = SitesConf.init();
|
|
|
|
|
var kbpromise = Keybinds.init();
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
ExtensionConf.init();
|
|
|
|
|
|
|
|
|
|
// počakamo, da so nastavitve naložene
|
|
|
|
|
// wait for settings to load
|
|
|
|
|
await scpromise;
|
|
|
|
|
await kbpromise;
|
|
|
|
|
|
2016-11-16 19:52:09 +01:00
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("configuration should be loaded now");
|
|
|
|
|
// start autoar and setup everything
|
2016-11-16 19:52:09 +01:00
|
|
|
|
|
2017-12-02 21:09:08 +01:00
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
// $(document).ready(function() {
|
2017-09-24 01:54:46 +02:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("uw::document.ready | document is ready. Starting ar script ...");
|
2017-12-17 22:56:07 +01:00
|
|
|
|
|
2017-12-02 21:09:08 +01:00
|
|
|
|
if(SitesConf.getMode(window.location.hostname) == "blacklist" ){
|
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("uw::document.ready | site", window.location.hostname, "is blacklisted.");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
if( ExtensionConf.mode == "none" ){
|
2017-12-02 21:09:08 +01:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("uw::document.ready | Extension is soft-disabled via popup");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-12-17 22:56:07 +01:00
|
|
|
|
if( ExtensionConf.mode == "whitelist" && SitesConf.getMode(window.location.hostname) != "whitelist"){
|
2017-12-02 21:09:08 +01:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("uw::document.ready | extension is set to run on whitelisted sites only, but site ", window.location.hostname, "is not on whitelist.");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
|
|
|
|
|
2017-12-30 20:53:15 +01:00
|
|
|
|
if(Settings.arDetect.enable == "global")
|
|
|
|
|
ArDetect.arSetup();
|
2017-01-02 17:45:51 +01:00
|
|
|
|
|
2017-11-13 22:35:04 +01:00
|
|
|
|
document.addEventListener("mozfullscreenchange", function( event ) {
|
2017-12-29 23:34:40 +01:00
|
|
|
|
if(Debug.debug){
|
|
|
|
|
// console.log("[uw::mozfullscreenchange] full screen state is changing. event:", event);
|
|
|
|
|
console.log("[uw::mozfullscreenchange] are we in full screen?", FullScreenDetect.isFullScreen());
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-13 22:35:04 +01:00
|
|
|
|
if(FullScreenDetect.isFullScreen()){
|
|
|
|
|
// full screen is on
|
2017-12-29 23:34:40 +01:00
|
|
|
|
Resizer.restore();
|
2017-11-13 22:35:04 +01:00
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
Resizer.reset();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2017-12-29 23:34:40 +01:00
|
|
|
|
browser.runtime.onMessage.addListener(receiveMessage);
|
2017-12-17 22:56:07 +01:00
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 23:34:40 +01:00
|
|
|
|
|
|
|
|
|
// comms
|
|
|
|
|
function receiveMessage(message) {
|
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("[uw::receiveMessage] we received a message.", message);
|
|
|
|
|
|
2017-12-30 18:36:08 +01:00
|
|
|
|
|
|
|
|
|
if(message.cmd == "has-videos"){
|
|
|
|
|
var anyVideos = PageInfo.hasVideos();
|
|
|
|
|
return Promise.resolve({response: {"hasVideos": anyVideos }});
|
|
|
|
|
}
|
|
|
|
|
else if(message.cmd == "get-ardetect-active"){
|
|
|
|
|
var arDetect_active = ArDetect.isRunning();
|
|
|
|
|
return Promise.resolve({response: {"arDetect_active": arDetect_active }});
|
|
|
|
|
}
|
|
|
|
|
else if(message.cmd == "force-ar"){
|
2017-12-29 23:34:40 +01:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("[uw::receiveMessage] we're being commanded to change aspect ratio to", message.newAr);
|
|
|
|
|
|
|
|
|
|
if(message.newAr == "auto"){
|
|
|
|
|
ArDetect.stop(); // just in case
|
|
|
|
|
ArDetect.arSetup();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
ArDetect.stop();
|
|
|
|
|
|
|
|
|
|
// we aren't in full screen, but we will want aspect ratio to be fixed when we go to
|
|
|
|
|
Resizer.setFsAr(message.newAr);
|
|
|
|
|
}
|
2017-12-30 18:36:08 +01:00
|
|
|
|
}
|
|
|
|
|
else if(message.cmd == "force-video-float"){
|
2017-12-29 23:34:40 +01:00
|
|
|
|
if(Debug.debug)
|
|
|
|
|
console.log("[uw::receiveMessage] we're aligning video to", message.newFloat);
|
|
|
|
|
|
|
|
|
|
Settings.miscFullscreenSettings.videoFloat = message.newFloat;
|
|
|
|
|
Settings.save();
|
|
|
|
|
}
|
2017-12-30 18:36:08 +01:00
|
|
|
|
else if(message.cmd == "stop-autoar"){
|
2017-12-29 23:34:40 +01:00
|
|
|
|
ArDetect.stop();
|
|
|
|
|
}
|
2017-12-30 18:36:08 +01:00
|
|
|
|
else if(message.cmd == "reload-settings"){
|
2017-12-29 23:34:40 +01:00
|
|
|
|
Settings.reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-30 02:58:24 +01:00
|
|
|
|
|
|
|
|
|
|
2017-12-17 22:56:07 +01:00
|
|
|
|
main();
|