Misc fixes

This commit is contained in:
Tamius Han 2018-08-29 00:41:26 +02:00
parent 1feeaed257
commit 6c93a19248
7 changed files with 35 additions and 14 deletions

View File

@ -255,7 +255,7 @@ class CommsServer {
this.sendToAll({cmd: 'reload-settings', newConf: this.settings.active}); this.sendToAll({cmd: 'reload-settings', newConf: this.settings.active});
} else if (message.cmd === 'set-video-float') { } else if (message.cmd === 'set-video-float') {
this.sendToActive(message); this.sendToActive(message);
this.settings.active.miscFullscreenthis.settings.videoFloat = message.newFloat; this.settings.active.miscFullscreenSettings.videoFloat = message.newFloat;
this.settings.save(); this.settings.save();
this.sendToAll({cmd: 'reload-settings', newConf: this.settings.active}); this.sendToAll({cmd: 'reload-settings', newConf: this.settings.active});

View File

@ -5,7 +5,7 @@ class ObjectCopy {
var out = JSON.parse(JSON.stringify(target)); var out = JSON.parse(JSON.stringify(target));
if(! existing) { if(! existing) {
if(Settings.debug) { if(Debug.debug) {
console.log("[ObjectCopy::addNew] There's no existing value. Returning target value."); console.log("[ObjectCopy::addNew] There's no existing value. Returning target value.");
} }

View File

@ -10,10 +10,28 @@ class Settings {
if(BrowserDetect.firefox) { if(BrowserDetect.firefox) {
browser.storage.onChanged.addListener( (changes, area) => { browser.storage.onChanged.addListener( (changes, area) => {
if (Debug.debug) {
console.log("[Settings::<storage/on change>] Settings have been changed outside of here. Updating active settings. Changes:", changes, "storage area:", area);
if (changes['uwSettings'] && changes['uwSettings'].newValue) {
console.log("[Settings::<storage/on change>] new settings object:", JSON.parse(changes.uwSettings.newValue));
}
}
if(changes['uwSettings'] && changes['uwSettings'].newValue) { if(changes['uwSettings'] && changes['uwSettings'].newValue) {
ths.active = JSON.parse(changes.uwSettings.newValue); ths.active = JSON.parse(changes.uwSettings.newValue);
} }
}); });
} else if (BrowserDetect.chrome) {
chrome.storage.onChanged.addListener( (changes, area) => {
if (Debug.debug) {
console.log("[Settings::<storage/on change>] Settings have been changed outside of here. Updating active settings. Changes:", changes, "storage area:", area);
if (changes['uwSettings'] && changes['uwSettings'].newValue) {
console.log("[Settings::<storage/on change>] new settings object:", JSON.parse(changes.uwSettings.newValue));
}
}
if(changes['uwSettings'] && changes['uwSettings'].newValue) {
ths.active = JSON.parse(changes.uwSettings.newValue);
}
})
} }
} }
@ -76,7 +94,9 @@ class Settings {
return undefined; return undefined;
} }
} else if (BrowserDetect.chrome) { } else if (BrowserDetect.chrome) {
const ret = chrome.storage.sync.get('uwSettings'); const ret = new Promise( (resolve, reject) => {
chrome.storage.sync.get('uwSettings', (res) => resolve(res));
});
return ret['uwSettings']; return ret['uwSettings'];
} }
} }
@ -90,7 +110,7 @@ class Settings {
extensionConf.version = this.version; extensionConf.version = this.version;
return this.useSync ? browser.storage.sync.set( {'uwSettings': JSON.stringify(extensionConf)}): browser.storage.local.set( {'uwSettings': JSON.stringify(extensionConf)}); return this.useSync ? browser.storage.sync.set( {'uwSettings': JSON.stringify(extensionConf)}): browser.storage.local.set( {'uwSettings': JSON.stringify(extensionConf)});
} else if (BrowserDetect.chrome) { } else if (BrowserDetect.chrome) {
return chrome.storage.sync.set( {'uwSettings': extensionConf}); return chrome.storage.sync.set( {'uwSettings': JSON.stringify(extensionConf)});
} }
} }

View File

@ -235,7 +235,6 @@ class ArDetector {
} }
var e = await this.settings.get(); var e = await this.settings.get();
console.log("settings?", this.settings.active, e);
// run anything that needs to be run after frame check // run anything that needs to be run after frame check
this.postFrameCheck(); this.postFrameCheck();
@ -477,9 +476,9 @@ class ArDetector {
var newCanvasWidth = window.innerHeight * (this.video.videoWidth / this.video.videoHeight); var newCanvasWidth = window.innerHeight * (this.video.videoWidth / this.video.videoHeight);
var newCanvasHeight = window.innerHeight; var newCanvasHeight = window.innerHeight;
if(this.settings.active.miscFullscreenthis.settings.videoFloat == "center") if(this.settings.active.miscFullscreenSettings.videoFloat == "center")
this.canvasDrawWindowHOffset = Math.round((window.innerWidth - newCanvasWidth) * 0.5); this.canvasDrawWindowHOffset = Math.round((window.innerWidth - newCanvasWidth) * 0.5);
else if(this.settings.active.miscFullscreenthis.settings.videFloat == "left") else if(this.settings.active.miscFullscreenSettings.videFloat == "left")
this.canvasDrawWindowHOffset = 0; this.canvasDrawWindowHOffset = 0;
else else
this.canvasDrawWindowHOffset = window.innerWidth - newCanvasWidth; this.canvasDrawWindowHOffset = window.innerWidth - newCanvasWidth;

View File

@ -158,8 +158,6 @@ class Resizer {
return; return;
} }
console.log("shcedulasdasdasds")
if(this.cssWatcherTimeout) { if(this.cssWatcherTimeout) {
clearTimeout(this.cssWatcherTimer); clearTimeout(this.cssWatcherTimer);
} }

View File

@ -56,7 +56,11 @@ async function init(){
return; return;
} }
pageInfo = new PageInfo(comms, settings); try {
pageInfo = new PageInfo(comms, settings);
} catch (e) {
console.log("[uw::init] FAILED TO START EXTENSION. Error:", e);
}
if(Debug.debug){ if(Debug.debug){
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo); console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);

View File

@ -148,9 +148,9 @@
<div class="row"> <div class="row">
<span class="label">Options for this site:</span> <span class="label">Options for this site:</span>
<div class="button-row"> <div class="button-row">
<a id="_ext_site_options_blacklist" class="button _ext _ext_site_options _blacklist">Blacklist</a>
<a id="_ext_site_options_default" class="button _ext _ext_site_options _default" >Default</a>
<a id="_ext_site_options_whitelist" class="button _ext _ext_site_options _whitelist">Whitelist</a> <a id="_ext_site_options_whitelist" class="button _ext _ext_site_options _whitelist">Whitelist</a>
<a id="_ext_site_options_default" class="button _ext _ext_site_options _default" >Default</a>
<a id="_ext_site_options_blacklist" class="button _ext _ext_site_options _blacklist">Blacklist</a>
</div> </div>
</div> </div>
</div> </div>
@ -171,9 +171,9 @@
<div class="row"> <div class="row">
<span class="label">Options for this site:</span> <span class="label">Options for this site:</span>
<div class="button-row"> <div class="button-row">
<a id="_ar_site_options_disabled" class="button _autoAr _ar_site_options _disabled">Blacklist</a>
<a id="_ar_site_options_default" class="button _autoAr _ar_site_options _default" >Default</a>
<a id="_ar_site_options_enabled" class="button _autoAr _ar_site_options _enabled" >Whitelist</a> <a id="_ar_site_options_enabled" class="button _autoAr _ar_site_options _enabled" >Whitelist</a>
<a id="_ar_site_options_default" class="button _autoAr _ar_site_options _default" >Default</a>
<a id="_ar_site_options_disabled" class="button _autoAr _ar_site_options _disabled">Blacklist</a>
</div> </div>
</div> </div>
</div> </div>