Finished converting console.logs to logger
This commit is contained in:
parent
2de8d64b29
commit
df5b2b5165
@ -253,9 +253,7 @@ class ActionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleKeydown(event) {
|
handleKeydown(event) {
|
||||||
if(Debug.debug && Debug.keyboard ){
|
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeydown] we pressed a key: ", "color: #ff0", event.key , " | keydown: ", event.keydown, "event:", event)
|
||||||
console.log("%c[ActionHandler::handleKeydown] we pressed a key: ", "color: #ff0", event.key , " | keydown: ", event.keydown, "event:", event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.preventAction()) {
|
if (this.preventAction()) {
|
||||||
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeydown] we are in a text box or something. Doing nothing.");
|
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeydown] we are in a text box or something. Doing nothing.");
|
||||||
|
@ -1,20 +1,83 @@
|
|||||||
|
import currentBrowser from '../conf/BrowserDetect';
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
constructor(conf) {
|
constructor(conf) {
|
||||||
this.conf = conf;
|
this.initLogger();
|
||||||
|
if (conf) {
|
||||||
|
this.conf = conf;
|
||||||
|
}
|
||||||
this.history = [];
|
this.history = [];
|
||||||
this.startTime = performance.now();
|
this.startTime = performance.now();
|
||||||
this.temp_disable = false;
|
this.temp_disable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initLogger() {
|
||||||
|
const ths = this;
|
||||||
|
const br = currentBrowser.firefox ? browser : chrome;
|
||||||
|
br.storage.onChanged.addListener( (changes, area) => {
|
||||||
|
if (Debug.debug && Debug.debugStorage) {
|
||||||
|
console.log("[Logger::<storage/on change>] Settings have been changed outside of here. Updating active settings. Changes:", changes, "storage area:", area);
|
||||||
|
if (changes['uwLogger'] && changes['uwLogger'].newValue) {
|
||||||
|
console.log("[Logger::<storage/on change>] new settings object:", JSON.parse(changes.uwLogger.newValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(changes['uwLogger'] && changes['uwLogger'].newValue) {
|
||||||
|
ths.conf = JSON.parse(changes.uwLogger.newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async init() {
|
||||||
|
this.conf = await this.getSaved();
|
||||||
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.log = [];
|
this.log = [];
|
||||||
this.startTime = performance.now();
|
this.startTime = performance.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
setConf(conf) {
|
setConf(conf) {
|
||||||
this.conf = conf;
|
this.conf = conf; // effective immediately
|
||||||
|
// also persist settings:
|
||||||
|
if (currentBrowser.firefox || currentBrowser.edge) {
|
||||||
|
extensionConf.version = this.version;
|
||||||
|
return browser.storage.local.set( {'uwLogger': JSON.stringify(this.conf)});
|
||||||
|
} else if (currentBrowser.chrome) {
|
||||||
|
return chrome.storage.local.set( {'uwLogger': JSON.stringify(this.logger)});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getSaved() {
|
||||||
|
let ret;
|
||||||
|
|
||||||
|
if (currentBrowser.firefox) {
|
||||||
|
ret = await browser.storage.local.get('uwLogger');
|
||||||
|
} else if (currentBrowser.chrome) {
|
||||||
|
ret = await new Promise( (resolve, reject) => {
|
||||||
|
chrome.storage.local.get('uwLogger', (res) => resolve(res));
|
||||||
|
});
|
||||||
|
} else if (currentBrowser.edge) {
|
||||||
|
ret = await new Promise( (resolve, reject) => {
|
||||||
|
browser.storage.local.get('uwLogger', (res) => resolve(res));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Debug.debug && Debug.debugStorage) {
|
||||||
|
try {
|
||||||
|
console.log("[Logger::getSaved] Got settings:", JSON.parse(ret.uwLogger));
|
||||||
|
} catch (e) {
|
||||||
|
console.log("[Logger::getSaved] No settings.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(ret.uwLogger);
|
||||||
|
} catch(e) {
|
||||||
|
return {logToFile: false, logToConsole: false, consoleOptions: {}, fileOptions: {}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// allow syncing of start times between bg and page scripts.
|
// allow syncing of start times between bg and page scripts.
|
||||||
// may result in negative times in the log file, but that doesn't
|
// may result in negative times in the log file, but that doesn't
|
||||||
// really matter
|
// really matter
|
||||||
|
@ -389,14 +389,8 @@ class ArDetector {
|
|||||||
if( execTime > this.settings.active.arDetect.autoDisable.maxExecutionTime ){
|
if( execTime > this.settings.active.arDetect.autoDisable.maxExecutionTime ){
|
||||||
// this.detectionTimeoutEventCount++;
|
// this.detectionTimeoutEventCount++;
|
||||||
|
|
||||||
// if(Debug.debug){
|
|
||||||
// console.log("[ArDetect::getTimeout] Exec time exceeded maximum allowed execution time. This has now happened " + this.detectionTimeoutEventCount + " times in a row.");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if( this.detectionTimeoutEventCount >= this.settings.active.arDetect.autoDisable.consecutiveTimeoutCount ){
|
// if( this.detectionTimeoutEventCount >= this.settings.active.arDetect.autoDisable.consecutiveTimeoutCount ){
|
||||||
// if (Debug.debug){
|
|
||||||
// console.log("[ArDetect::getTimeout] Maximum execution time was exceeded too many times. Automatic aspect ratio detection has been disabled.");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Comms.sendToBackgroundScript({cmd: 'disable-autoar', reason: 'Automatic aspect ratio detection was taking too much time and has been automatically disabled in order to avoid lag.'});
|
// Comms.sendToBackgroundScript({cmd: 'disable-autoar', reason: 'Automatic aspect ratio detection was taking too much time and has been automatically disabled in order to avoid lag.'});
|
||||||
// _ard_stop();
|
// _ard_stop();
|
||||||
@ -581,10 +575,6 @@ class ArDetector {
|
|||||||
// we don't do any corrections on frames confirmed black
|
// we don't do any corrections on frames confirmed black
|
||||||
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Black frame analysis suggests this frame is black or too dark. Doing nothing.`, "color: #fa3", bfanalysis);
|
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Black frame analysis suggests this frame is black or too dark. Doing nothing.`, "color: #fa3", bfanalysis);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
// if (Debug.debug && Debug.arDetect) {
|
|
||||||
// console.log("%c[ArDetect::frameCheck] Black frame analysis suggests this frame is not completely black. Doing further analysis,", "color: #3fa", bfanalysis);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ class GuardLine {
|
|||||||
// should succeed by default. Also need to check bottom, for cases where only one edge is known
|
// should succeed by default. Also need to check bottom, for cases where only one edge is known
|
||||||
|
|
||||||
if(! fallbackMode && (! this.blackbar.top || ! this.blackbar.bottom)) {
|
if(! fallbackMode && (! this.blackbar.top || ! this.blackbar.bottom)) {
|
||||||
// console.log("NO EDGE WAS DETECTED. THIS TEST IS POINTLESS. btw guardline")
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class EdgeDetect{
|
|||||||
|
|
||||||
constructor(ardConf){
|
constructor(ardConf){
|
||||||
this.conf = ardConf;
|
this.conf = ardConf;
|
||||||
|
this.logger = ardConf.logger;
|
||||||
this.settings = ardConf.settings;
|
this.settings = ardConf.settings;
|
||||||
|
|
||||||
this.sampleWidthBase = this.settings.active.arDetect.edgeDetection.sampleWidth << 2; // corrected so we can work on imageData
|
this.sampleWidthBase = this.settings.active.arDetect.edgeDetection.sampleWidth << 2; // corrected so we can work on imageData
|
||||||
@ -43,9 +44,7 @@ class EdgeDetect{
|
|||||||
bars = this.edgePostprocess(edgeCandidates, this.conf.canvas.height);
|
bars = this.edgePostprocess(edgeCandidates, this.conf.canvas.height);
|
||||||
// }
|
// }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (Debug.debug) {
|
this.logger.log('error', 'arDetect', '%c[EdgeDetect::findBars] find bars failed.', 'background: #f00, color: #000', e);
|
||||||
console.log("%c[EdgeDetect::findBars] find bars failed.", "background: #f00, color: #000", e);
|
|
||||||
}
|
|
||||||
return {status: EdgeStatus.AR_UNKNOWN}
|
return {status: EdgeStatus.AR_UNKNOWN}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -58,89 +57,80 @@ class EdgeDetect{
|
|||||||
|
|
||||||
findCandidates(image, sampleCols, guardLineOut){
|
findCandidates(image, sampleCols, guardLineOut){
|
||||||
try {
|
try {
|
||||||
let upper_top, upper_bottom, lower_top, lower_bottom;
|
let upper_top, upper_bottom, lower_top, lower_bottom;
|
||||||
|
|
||||||
// const cols_a = sampleCols.slice(0);
|
// const cols_a = sampleCols.slice(0);
|
||||||
const cols_a = new Array(sampleCols.length);
|
const cols_a = new Array(sampleCols.length);
|
||||||
const res_top = [];
|
const res_top = [];
|
||||||
|
|
||||||
for (let i = 0; i < cols_a.length; i++) {
|
for (let i = 0; i < cols_a.length; i++) {
|
||||||
cols_a[i] = {
|
cols_a[i] = {
|
||||||
id: i,
|
id: i,
|
||||||
value: sampleCols[i],
|
value: sampleCols[i],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const cols_b = cols_a.slice(0);
|
const cols_b = cols_a.slice(0);
|
||||||
const res_bottom = [];
|
const res_bottom = [];
|
||||||
|
|
||||||
// console.log("[EdgeDetect::findCandidates] cols a, b (initial):", cols_a, cols_b);
|
this.colsThreshold = sampleCols.length * this.settings.active.arDetect.edgeDetection.minColsForSearch;
|
||||||
|
if (this.colsThreshold == 0)
|
||||||
|
this.colsThreshold = 1;
|
||||||
this.colsThreshold = sampleCols.length * this.settings.active.arDetect.edgeDetection.minColsForSearch;
|
|
||||||
if (this.colsThreshold == 0)
|
this.blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
||||||
this.colsThreshold = 1;
|
this.imageThreshold = this.blackbarThreshold + this.settings.active.arDetect.blackbar.imageThreshold;
|
||||||
|
|
||||||
this.blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
// if guardline didn't fail and imageDetect did, we don't have to check the upper few pixels
|
||||||
this.imageThreshold = this.blackbarThreshold + this.settings.active.arDetect.blackbar.imageThreshold;
|
// but only if upper and lower edge are defined. If they're not, we need to check full height
|
||||||
|
if(guardLineOut){
|
||||||
// if guardline didn't fail and imageDetect did, we don't have to check the upper few pixels
|
if(guardLineOut.imageFail && !guardLineOut.blackbarFail && this.conf.guardLine.blackbar.top) {
|
||||||
// but only if upper and lower edge are defined. If they're not, we need to check full height
|
upper_top = this.conf.guardLine.blackbar.top;
|
||||||
if(guardLineOut){
|
upper_bottom = this.conf.canvas.height >> 1;
|
||||||
if(guardLineOut.imageFail && !guardLineOut.blackbarFail && this.conf.guardLine.blackbar.top) {
|
lower_top = upper_bottom;
|
||||||
upper_top = this.conf.guardLine.blackbar.top;
|
lower_bottom = this.conf.guardLine.blackbar.bottom;
|
||||||
upper_bottom = this.conf.canvas.height >> 1;
|
} else if (! guardLineOut.imageFail && !guardLineOut.blackbarFail && this.conf.guardLine.blackbar.top) {
|
||||||
lower_top = upper_bottom;
|
// ta primer se lahko zgodi tudi zaradi kakšnega logotipa. Ker nočemo, da nam en jeben
|
||||||
lower_bottom = this.conf.guardLine.blackbar.bottom;
|
// logotip vsili reset razmerja stranic, se naredimo hrvata in vzamemo nekaj varnostnega
|
||||||
} else if (! guardLineOut.imageFail && !guardLineOut.blackbarFail && this.conf.guardLine.blackbar.top) {
|
// pasu preko točke, ki jo označuje guardLine.blackbar. Recimo 1/8 višine platna na vsaki strani.
|
||||||
// ta primer se lahko zgodi tudi zaradi kakšnega logotipa. Ker nočemo, da nam en jeben
|
// a logo could falsely trigger this case, so we need to add some extra margins past
|
||||||
// logotip vsili reset razmerja stranic, se naredimo hrvata in vzamemo nekaj varnostnega
|
// the point marked by guardLine.blackbar. Let's say 1/8 of canvas height on either side.
|
||||||
// pasu preko točke, ki jo označuje guardLine.blackbar. Recimo 1/8 višine platna na vsaki strani.
|
upper_top = 0;
|
||||||
// a logo could falsely trigger this case, so we need to add some extra margins past
|
upper_bottom = this.conf.guardLine.blackbar.top + (this.conf.canvas.height >> 3);
|
||||||
// the point marked by guardLine.blackbar. Let's say 1/8 of canvas height on either side.
|
lower_top = this.conf.guardLine.blackbar.bottom - (this.conf.canvas.height >> 3);
|
||||||
upper_top = 0;
|
lower_bottom = this.conf.canvas.height - 1;
|
||||||
upper_bottom = this.conf.guardLine.blackbar.top + (this.conf.canvas.height >> 3);
|
} else {
|
||||||
lower_top = this.conf.guardLine.blackbar.bottom - (this.conf.canvas.height >> 3);
|
upper_top = 0;
|
||||||
lower_bottom = this.conf.canvas.height - 1;
|
upper_bottom = (this.conf.canvas.height >> 1) /*- parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
||||||
} else {
|
lower_top = (this.conf.canvas.height >> 1) /*+ parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
||||||
|
lower_bottom = this.conf.canvas.height - 1;
|
||||||
|
}
|
||||||
|
} else{
|
||||||
upper_top = 0;
|
upper_top = 0;
|
||||||
upper_bottom = (this.conf.canvas.height >> 1) /*- parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
upper_bottom = (this.conf.canvas.height >> 1) /*- parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
||||||
lower_top = (this.conf.canvas.height >> 1) /*+ parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
lower_top = (this.conf.canvas.height >> 1) /*+ parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
||||||
lower_bottom = this.conf.canvas.height - 1;
|
lower_bottom = this.conf.canvas.height - 1;
|
||||||
}
|
}
|
||||||
} else{
|
|
||||||
upper_top = 0;
|
|
||||||
upper_bottom = (this.conf.canvas.height >> 1) /*- parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
|
||||||
lower_top = (this.conf.canvas.height >> 1) /*+ parseInt(this.conf.canvas.height * this.settings.active.arDetect.edgeDetection.middleIgnoredArea);*/
|
|
||||||
lower_bottom = this.conf.canvas.height - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Debug.debug && Debug.debugArDetect){
|
this.logger.log('info', 'arDetect', '[EdgeDetect::findCandidates] searching for candidates on ranges', upper_top, '<->', upper_bottom, ';', lower_top, '<->', lower_bottom);
|
||||||
console.log("[EdgeDetect::findCandidates] searching for candidates on ranges", upper_top, "<->", upper_bottom, ";", lower_top, "<->", lower_bottom);
|
|
||||||
}
|
var upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
|
||||||
|
var upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
|
||||||
|
var lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
|
||||||
|
var lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
|
// if(Debug.debugCanvas.enabled){
|
||||||
|
// this._columnTest_dbgc(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
||||||
|
// this._columnTest_dbgc(image, lower_top_corrected, lower_bottom_corrected, cols_b, res_bottom, true);
|
||||||
|
// } else {
|
||||||
|
this._columnTest3_cross(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
||||||
|
this._columnTest3_cross(image, lower_top_corrected, lower_bottom_corrected, cols_b, res_bottom, true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
this.logger.log('info', 'arDetect', '[EdgeDetect::findCandidates] candidates found -->', {res_top: res_top, res_bottom: res_bottom});
|
||||||
|
|
||||||
var upper_top_corrected = upper_top * this.conf.canvasImageDataRowLength;
|
return {res_top: res_top, res_bottom: res_bottom};
|
||||||
var upper_bottom_corrected = upper_bottom * this.conf.canvasImageDataRowLength;
|
|
||||||
var lower_top_corrected = lower_top * this.conf.canvasImageDataRowLength;
|
|
||||||
var lower_bottom_corrected = lower_bottom * this.conf.canvasImageDataRowLength;
|
|
||||||
|
|
||||||
// if(Debug.debugCanvas.enabled){
|
|
||||||
// this._columnTest_dbgc(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
|
||||||
// this._columnTest_dbgc(image, lower_top_corrected, lower_bottom_corrected, cols_b, res_bottom, true);
|
|
||||||
// } else {
|
|
||||||
this._columnTest3_cross(image, upper_top_corrected, upper_bottom_corrected, cols_a, res_top, false);
|
|
||||||
this._columnTest3_cross(image, lower_top_corrected, lower_bottom_corrected, cols_b, res_bottom, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (Debug.debug && Debug.debugArDetect){
|
|
||||||
console.log("[EdgeDetect::findCandidates] candidates found -->", {res_top: res_top, res_bottom: res_bottom});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return {res_top: res_top, res_bottom: res_bottom};
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("[EdgeDetect::findCandidates] there was an error", e);
|
this.logger.log('error', 'debug', '[EdgeDetect::findCandidates] there was an error while finding candidates:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +323,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("\n\nuwu fucky wucky:", e, "\n\n")
|
this.logger.log('error', 'debug', '[EdgeDetect::edgeDetect] There was an error:', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -22,8 +22,6 @@ class PageInfo {
|
|||||||
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|
||||||
console.log("this.logger:", logger, this.logger)
|
|
||||||
|
|
||||||
if (comms){
|
if (comms){
|
||||||
this.comms = comms;
|
this.comms = comms;
|
||||||
}
|
}
|
||||||
@ -77,7 +75,7 @@ class PageInfo {
|
|||||||
this.comms.unregisterVideo(video.id)
|
this.comms.unregisterVideo(video.id)
|
||||||
video.destroy();
|
video.destroy();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("unabel to destroy video!", e)
|
this.logger.log('error', ['debug', 'init'], '[PageInfo::destroy] unable to destroy video! Error:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +195,7 @@ class PageInfo {
|
|||||||
} else {
|
} else {
|
||||||
this.logger.log('info', 'videoRescan', "[PageInfo::rescan] found new video candidate:", video, "NOTE:: Video initialization starts here:\n--------------------------------\n")
|
this.logger.log('info', 'videoRescan', "[PageInfo::rescan] found new video candidate:", video, "NOTE:: Video initialization starts here:\n--------------------------------\n")
|
||||||
|
|
||||||
v = new VideoData(video, this.settings, this, this.logger);
|
v = new VideoData(video, this.settings, this);
|
||||||
// console.log("[PageInfo::rescan] v is:", v)
|
|
||||||
v.initArDetection();
|
v.initArDetection();
|
||||||
this.videos.push(v);
|
this.videos.push(v);
|
||||||
|
|
||||||
@ -213,9 +210,6 @@ class PageInfo {
|
|||||||
//
|
//
|
||||||
// if we're left withotu videos on the current page, we unregister the page.
|
// if we're left withotu videos on the current page, we unregister the page.
|
||||||
// if we have videos, we call register.
|
// if we have videos, we call register.
|
||||||
// if(Debug.debug) {
|
|
||||||
// console.log("[PageInfo::rescan] Comms:", this.comms, "\nvideos.length:", this.videos.length, "\nold video count:", oldVideoCount)
|
|
||||||
// }
|
|
||||||
if (this.comms) {
|
if (this.comms) {
|
||||||
if (this.videos.length != oldVideoCount) { // only if number of videos changed, tho
|
if (this.videos.length != oldVideoCount) { // only if number of videos changed, tho
|
||||||
if (this.videos.length > 0) {
|
if (this.videos.length > 0) {
|
||||||
|
@ -5,14 +5,14 @@ import ArDetector from '../ar-detect/ArDetector';
|
|||||||
|
|
||||||
class VideoData {
|
class VideoData {
|
||||||
|
|
||||||
constructor(video, settings, pageInfo, logger){
|
constructor(video, settings, pageInfo){
|
||||||
this.arSetupComplete = false;
|
this.arSetupComplete = false;
|
||||||
this.video = video;
|
this.video = video;
|
||||||
this.destroyed = false;
|
this.destroyed = false;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.pageInfo = pageInfo;
|
this.pageInfo = pageInfo;
|
||||||
this.extensionMode = pageInfo.extensionMode;
|
this.extensionMode = pageInfo.extensionMode;
|
||||||
this.logger = logger;
|
this.logger = pageInfo.logger;
|
||||||
|
|
||||||
this.vdid = (Math.random()*100).toFixed();
|
this.vdid = (Math.random()*100).toFixed();
|
||||||
this.userCssClassName = `uw-fuck-you-and-do-what-i-tell-you_${this.vdid}`;
|
this.userCssClassName = `uw-fuck-you-and-do-what-i-tell-you_${this.vdid}`;
|
||||||
@ -40,15 +40,10 @@ class VideoData {
|
|||||||
this.logger.log('info', 'debug', "%c[VideoData::ctor] Initial resizer reset!", {background: '#afd', color: '#132'});
|
this.logger.log('info', 'debug', "%c[VideoData::ctor] Initial resizer reset!", {background: '#afd', color: '#132'});
|
||||||
this.resizer.reset();
|
this.resizer.reset();
|
||||||
|
|
||||||
|
this.logger.log('info', ['debug', 'init'], '[VideoData::ctor] Created videoData with vdid', this.vdid, '\nextension mode:', this.extensionMode)
|
||||||
if (Debug.init) {
|
|
||||||
console.log("[VideoData::ctor] Created videoData with vdid", this.vdid,"\nextension mode:", this.extensionMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pageInfo.initMouseActionHandler(this);
|
this.pageInfo.initMouseActionHandler(this);
|
||||||
|
|
||||||
this.video.classList.add(this.userCssClassName); // this also needs to be applied BEFORE we initialize resizer!
|
this.video.classList.add(this.userCssClassName); // this also needs to be applied BEFORE we initialize resizer!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onVideoDimensionsChanged(mutationList, observer) {
|
onVideoDimensionsChanged(mutationList, observer) {
|
||||||
@ -283,10 +278,6 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isPlaying() {
|
isPlaying() {
|
||||||
// console.log("is playing? video:", this.video, "ctime:", this.video.currentTime,
|
|
||||||
// "paused/ended:", this.video.paused, this.video.ended,
|
|
||||||
// "is playing?", this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended);
|
|
||||||
|
|
||||||
return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended;
|
return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ class Resizer {
|
|||||||
this.resizerId = (Math.random(99)*100).toFixed(0);
|
this.resizerId = (Math.random(99)*100).toFixed(0);
|
||||||
|
|
||||||
if (this.settings.active.pan) {
|
if (this.settings.active.pan) {
|
||||||
// console.log("can pan:", this.settings.active.miscSettings.mousePan.enabled, "(default:", this.settings.active.miscSettings.mousePan.enabled, ")")
|
|
||||||
this.canPan = this.settings.active.miscSettings.mousePan.enabled;
|
this.canPan = this.settings.active.miscSettings.mousePan.enabled;
|
||||||
} else {
|
} else {
|
||||||
this.canPan = false;
|
this.canPan = false;
|
||||||
@ -192,7 +191,6 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! this.video) {
|
if (! this.video) {
|
||||||
// console.log("No video detected.")
|
|
||||||
this.conf.destroy();
|
this.conf.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,14 +213,12 @@ class Resizer {
|
|||||||
var stretchFactors = this.scaler.calculateCrop(ar);
|
var stretchFactors = this.scaler.calculateCrop(ar);
|
||||||
|
|
||||||
if(! stretchFactors || stretchFactors.error){
|
if(! stretchFactors || stretchFactors.error){
|
||||||
this.logger.log('error', 'debug', "[Resizer::setAr] <rid:"+this.resizerId+"> failed to set AR due to problem with calculating crop. Error:", (stretchFactors ? stretchFactors.error : stretchFactors));
|
this.logger.log('error', 'debug', `[Resizer::setAr] <rid:${this.resizerId}> failed to set AR due to problem with calculating crop. Error:`, (stretchFactors ? stretchFactors.error : stretchFactors));
|
||||||
if (stretchFactors.error === 'no_video'){
|
if (stretchFactors.error === 'no_video'){
|
||||||
this.conf.destroy();
|
this.conf.destroy();
|
||||||
}
|
}
|
||||||
if (stretchFactors.error === 'illegal_video_dimensions') {
|
if (stretchFactors.error === 'illegal_video_dimensions') {
|
||||||
if(Debug.debug){
|
this.loggger.log('error', 'debug', `[Resizer::setAr] <rid:${this.resizerId}> Illegal video dimensions found. We will pause everything.`)
|
||||||
console.log("[Resizer::setAr] <rid:"+this.resizerId+"> Illegal video dimensions found. We will pause everything.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -269,7 +265,6 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
panHandler(event, forcePan) {
|
panHandler(event, forcePan) {
|
||||||
// console.log("this.conf.canPan:", this.conf.canPan)
|
|
||||||
if (this.canPan || forcePan) {
|
if (this.canPan || forcePan) {
|
||||||
if(!this.conf.player || !this.conf.player.element) {
|
if(!this.conf.player || !this.conf.player.element) {
|
||||||
return;
|
return;
|
||||||
|
@ -120,16 +120,9 @@ class Scaler {
|
|||||||
actualHeight: 0, // height of the video (excluding letterbox) when <video> tag height is equal to height
|
actualHeight: 0, // height of the video (excluding letterbox) when <video> tag height is equal to height
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(Debug.debug){
|
|
||||||
// console.log("[Scaler::calculateCrop] Player dimensions?", this.conf.player.dimensions.width, "×", this.conf.player.dimensions.height, "| obj:", this.conf.player.dimensions);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (fileAr < ar.ratio){
|
if (fileAr < ar.ratio){
|
||||||
// imamo letterbox zgoraj in spodaj -> spremenimo velikost videa (a nikoli širše od ekrana)
|
// imamo letterbox zgoraj in spodaj -> spremenimo velikost videa (a nikoli širše od ekrana)
|
||||||
// letterbox -> change video size (but never to wider than monitor width)
|
// letterbox -> change video size (but never to wider than monitor width)
|
||||||
// if (Debug.debug && Debug.scaler) {
|
|
||||||
// console.log(`%c[Scaler::calculateCrop] Trying to determine scaling factors. Aspect ratios:\n file: ${fileAr.toFixed(3)}\n player: ${playerAr.toFixed(3)}\n target: ${ar.ratio.toFixed(3)}\n-----------------------`, "color: #2ba");
|
|
||||||
// }
|
|
||||||
videoDimensions.xFactor = Math.min(ar.ratio, playerAr) / fileAr;
|
videoDimensions.xFactor = Math.min(ar.ratio, playerAr) / fileAr;
|
||||||
videoDimensions.yFactor = videoDimensions.xFactor;
|
videoDimensions.yFactor = videoDimensions.xFactor;
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,8 +30,11 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setup() {
|
async setup() {
|
||||||
this.settings = new Settings();
|
// logger is the first thing that goes up
|
||||||
|
this.logger = new Logger();
|
||||||
|
await this.logger.init();
|
||||||
|
|
||||||
|
this.settings = new Settings({logger: this.logger});
|
||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
this.comms = new CommsServer(this);
|
this.comms = new CommsServer(this);
|
||||||
|
|
||||||
@ -42,7 +45,6 @@ class UWServer {
|
|||||||
chrome.tabs.onActivated.addListener(function(m) {ths.onTabSwitched(m)});
|
chrome.tabs.onActivated.addListener(function(m) {ths.onTabSwitched(m)});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("will schedule gcframe")
|
|
||||||
this.scheduleGc();
|
this.scheduleGc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,18 +56,13 @@ class UWServer {
|
|||||||
|
|
||||||
async injectCss(css, sender) {
|
async injectCss(css, sender) {
|
||||||
try {
|
try {
|
||||||
if (Debug.debug) {
|
|
||||||
console.log("[uwbg::injectCss] Injecting CSS:", css, sender);
|
|
||||||
}
|
|
||||||
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
if (BrowserDetect.firefox || BrowserDetect.edge) {
|
||||||
browser.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
browser.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.chrome) {
|
||||||
chrome.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
chrome.tabs.insertCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (Debug.debug) {
|
this.logger.log('error','debug', '[UwServer::injectCss] Error while injecting css:', {error: e, css, sender});
|
||||||
console.error("Error while injecting css:", {error: e, css, sender});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async removeCss(css, sender) {
|
async removeCss(css, sender) {
|
||||||
@ -76,7 +73,9 @@ class UWServer {
|
|||||||
// this doesn't work currently, but hopefully chrome will get this feature in the future
|
// this doesn't work currently, but hopefully chrome will get this feature in the future
|
||||||
chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
chrome.tabs.removeCSS(sender.tab.id, {code: css, cssOrigin: 'user', frameId: sender.frameId});
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) {
|
||||||
|
this.logger.log('error','debug', '[UwServer::injectCss] Error while removing css:', {error: e, css, sender});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async replaceCss(oldCss, newCss, sender) {
|
async replaceCss(oldCss, newCss, sender) {
|
||||||
@ -99,7 +98,6 @@ class UWServer {
|
|||||||
clearTimeout(ths._gctimeout);
|
clearTimeout(ths._gctimeout);
|
||||||
ths.gcFrames();
|
ths.gcFrames();
|
||||||
|
|
||||||
|
|
||||||
ths._gctimeoutgcTimeout = ths.scheduleGc(5000);
|
ths._gctimeoutgcTimeout = ths.scheduleGc(5000);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
@ -124,26 +122,20 @@ class UWServer {
|
|||||||
async onTabSwitched(activeInfo){
|
async onTabSwitched(activeInfo){
|
||||||
this.hasVideos = false;
|
this.hasVideos = false;
|
||||||
|
|
||||||
if(Debug.debug)
|
|
||||||
console.log("[uw-bg::onTabSwitched] TAB CHANGED, GETTING INFO FROM MAIN TAB");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.currentTabId = activeInfo.tabId; // just for readability
|
this.currentTabId = activeInfo.tabId; // just for readability
|
||||||
|
|
||||||
var tab;
|
let tab;
|
||||||
if (BrowserDetect.firefox) {
|
if (BrowserDetect.firefox) {
|
||||||
var tab = await browser.tabs.get(this.currentTabId);
|
tab = await browser.tabs.get(this.currentTabId);
|
||||||
} else if (BrowserDetect.chrome) {
|
} else if (BrowserDetect.chrome) {
|
||||||
var tab = await this._promisifyTabsGet(chrome, this.currentTabId);
|
tab = await this._promisifyTabsGet(chrome, this.currentTabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSite = this.extractHostname(tab.url);
|
this.currentSite = this.extractHostname(tab.url);
|
||||||
|
this.logger.log('info', 'debug', '[UwServer::onTabSwitched] user switched tab. New site:', this.currentSite);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
this.logger.log('error', 'debug', '[UwServer::onTabSwitched] there was a problem getting currnet site:', e)
|
||||||
}
|
|
||||||
|
|
||||||
if(Debug.debug) {
|
|
||||||
console.log("TAB SWITCHED!", this.currentSite)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedSubitem = {
|
this.selectedSubitem = {
|
||||||
@ -176,9 +168,7 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerVideo(sender) {
|
registerVideo(sender) {
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'comms', '[UWServer::registerVideo] Registering video.\nsender:', sender);
|
||||||
console.log("[UWServer::registerVideo] registering video.\nsender:", sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabHostname = this.extractHostname(sender.tab.url);
|
const tabHostname = this.extractHostname(sender.tab.url);
|
||||||
const frameHostname = this.extractHostname(sender.url);
|
const frameHostname = this.extractHostname(sender.url);
|
||||||
@ -221,15 +211,11 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'comms', '[UWServer::registerVideo] Video registered. current videoTabs:', this.videoTabs);
|
||||||
console.log("[UWServer::registerVideo] video registered. current videoTabs:", this.videoTabs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterVideo(sender) {
|
unregisterVideo(sender) {
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'comms', '[UwServer::unregisterVideo] Unregistering video.\nsender:', sender);
|
||||||
console.log("[UWServer::unregisterVideo] unregistering video.\nsender:", sender);
|
|
||||||
}
|
|
||||||
if (this.videoTabs[sender.tab.id]) {
|
if (this.videoTabs[sender.tab.id]) {
|
||||||
if ( Object.keys(this.videoTabs[sender.tab.id].frames).length <= 1) {
|
if ( Object.keys(this.videoTabs[sender.tab.id].frames).length <= 1) {
|
||||||
delete this.videoTabs[sender.tab.id]
|
delete this.videoTabs[sender.tab.id]
|
||||||
@ -239,15 +225,11 @@ class UWServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'comms', '[UwServer::unregisterVideo] Video has been unregistered. Current videoTabs:', this.videoTabs);
|
||||||
console.log("[UWServer::ungisterVideo] video unregistered. current videoTabs:", this.videoTabs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedTab(menu, subitem) {
|
setSelectedTab(menu, subitem) {
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'comms', '[UwServer::setSelectedTab] saving selected tab for', menu, ':', subitem);
|
||||||
console.log("[uw-bg::setSelectedTab] saving selected tab for", menu, ":", subitem)
|
|
||||||
}
|
|
||||||
this.selectedSubitem[menu] = subitem;
|
this.selectedSubitem[menu] = subitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,39 @@ class UW {
|
|||||||
console.log("[uw::main] loading configuration ...");
|
console.log("[uw::main] loading configuration ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logger init is the first thing that needs to run
|
||||||
|
try {
|
||||||
|
if (!this.logger) {
|
||||||
|
const loggingOptions = {
|
||||||
|
logToFile: false,
|
||||||
|
logToConsole: true,
|
||||||
|
fileOptions: {
|
||||||
|
// really the same stuff as consoleOptions
|
||||||
|
},
|
||||||
|
consoleOptions: {
|
||||||
|
enabled: true, // if logging is enabled at all
|
||||||
|
'debug': true,
|
||||||
|
'init': true,
|
||||||
|
'keyboard': false,
|
||||||
|
'mousemove': false,
|
||||||
|
'actionHandler': false,
|
||||||
|
'comms': true,
|
||||||
|
'playerDetect': true,
|
||||||
|
'resizer': true,
|
||||||
|
'scaler': true,
|
||||||
|
'stretcher': true,
|
||||||
|
'videoRescan': false,
|
||||||
|
'arDetect': false,
|
||||||
|
'arDetect_verbose': false,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// this.logger = new Logger(this.settings.getLoggingOptions);
|
||||||
|
this.logger = new Logger(loggingOptions);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("logger init failed!", e)
|
||||||
|
}
|
||||||
|
|
||||||
// init() is re-run any time settings change
|
// init() is re-run any time settings change
|
||||||
if (this.pageInfo) {
|
if (this.pageInfo) {
|
||||||
// if this executes, logger must have been initiated at some point before this point
|
// if this executes, logger must have been initiated at some point before this point
|
||||||
@ -49,43 +82,15 @@ class UW {
|
|||||||
this.comms.destroy();
|
this.comms.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!this.settings) {
|
if (!this.settings) {
|
||||||
var ths = this;
|
var ths = this;
|
||||||
this.settings = new Settings(undefined, () => ths.init());
|
this.settings = new Settings({updateCallback: () => ths.init(), logger: this.logger});
|
||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (!this.logger) {
|
|
||||||
const loggingOptions = {
|
|
||||||
logToFile: false,
|
|
||||||
logToConsole: true,
|
|
||||||
fileOptions: {
|
|
||||||
// really the same stuff as consoleOptions
|
|
||||||
},
|
|
||||||
consoleOptions: {
|
|
||||||
enabled: true, // if logging is enabled at all
|
|
||||||
'debug': true,
|
|
||||||
'init': true,
|
|
||||||
'keyboard': false,
|
|
||||||
'mousemove': false,
|
|
||||||
'actionHandler': false,
|
|
||||||
'comms': true,
|
|
||||||
'playerDetect': true,
|
|
||||||
'resizer': true,
|
|
||||||
'scaler': true,
|
|
||||||
'stretcher': true,
|
|
||||||
'videoRescan': false,
|
|
||||||
'arDetect': false,
|
|
||||||
'arDetect_verbose': false,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// this.logger = new Logger(this.settings.getLoggingOptions);
|
|
||||||
this.logger = new Logger(loggingOptions);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error("logger init failed!", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.comms = new CommsClient('content-client-port', this.settings, this.logger);
|
this.comms = new CommsClient('content-client-port', this.settings, this.logger);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div v-if="settingsInitialized">
|
||||||
|
|
||||||
<!-- POPUPS -->
|
<!-- POPUPS -->
|
||||||
<div v-if="anyOpenedPopups"
|
<div v-if="anyOpenedPopups"
|
||||||
@ -136,6 +136,7 @@ export default {
|
|||||||
selectedTab: "general",
|
selectedTab: "general",
|
||||||
selectedTabTitle: "General settings",
|
selectedTabTitle: "General settings",
|
||||||
settings: {},
|
settings: {},
|
||||||
|
logger: {},
|
||||||
settingsInitialized: false,
|
settingsInitialized: false,
|
||||||
editActionPopupVisible: false,
|
editActionPopupVisible: false,
|
||||||
editActionIndex: -1,
|
editActionIndex: -1,
|
||||||
@ -148,8 +149,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
this.settings = new Settings(undefined, this.updateSettings);
|
this.logger = new Logger();
|
||||||
|
await this.logger.init();
|
||||||
|
|
||||||
|
this.settings = new Settings({updateCallback: this.updateSettings, logger: this.logger});
|
||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
|
|
||||||
this.settingsInitialized = true;
|
this.settingsInitialized = true;
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -610,7 +610,6 @@ export default {
|
|||||||
ctx.drawWindow(window,0, 0, 10, 10, "rgba(0,0,0,0)");
|
ctx.drawWindow(window,0, 0, 10, 10, "rgba(0,0,0,0)");
|
||||||
this.fallbackModeAvailable = true;
|
this.fallbackModeAvailable = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.log("DrawWindow failed:", e)
|
|
||||||
this.fallbackModeAvailable = false;
|
this.fallbackModeAvailable = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -634,7 +633,6 @@ export default {
|
|||||||
return 'user-defined';
|
return 'user-defined';
|
||||||
},
|
},
|
||||||
setConfirmationThresholds(sens) {
|
setConfirmationThresholds(sens) {
|
||||||
console.log("setting conf treshold", sens)
|
|
||||||
if (sens === 'sensitive') {
|
if (sens === 'sensitive') {
|
||||||
this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 3;
|
this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 3;
|
||||||
this.settings.active.arDetect.edgeDetection.confirmationThreshold = 1;
|
this.settings.active.arDetect.edgeDetection.confirmationThreshold = 1;
|
||||||
|
@ -104,11 +104,6 @@ export default {
|
|||||||
}
|
}
|
||||||
this.customArgumentValue = this.action.customArg;
|
this.customArgumentValue = this.action.customArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("this.actionList", ActionList, this.ActionList)
|
|
||||||
// for(const a in ActionList) {
|
|
||||||
// console.log(a);
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
// console.log("global browser", browser, global.browser)
|
|
||||||
// global.browser = require('webextension-polyfill')
|
|
||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="popup flex flex-column no-overflow">
|
<div v-if="settingsInitialized"
|
||||||
|
class="popup flex flex-column no-overflow"
|
||||||
|
>
|
||||||
<div class="header flex-row flex-nogrow flex-noshrink">
|
<div class="header flex-row flex-nogrow flex-noshrink">
|
||||||
<span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small>
|
<span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small>
|
||||||
</div>
|
</div>
|
||||||
@ -178,6 +180,8 @@ import ExtensionMode from '../common/enums/extension-mode.enum';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
|
const logger = new Logger();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedTab: 'video',
|
selectedTab: 'video',
|
||||||
selectedFrame: '__all',
|
selectedFrame: '__all',
|
||||||
@ -192,7 +196,9 @@ export default {
|
|||||||
site: null,
|
site: null,
|
||||||
currentZoom: 1,
|
currentZoom: 1,
|
||||||
execAction: new ExecAction(),
|
execAction: new ExecAction(),
|
||||||
settings: new Settings(undefined, () => this.updateConfig()),
|
settings: {},
|
||||||
|
settingsInitialized: false,
|
||||||
|
logger: {},
|
||||||
siteTabDisabled: false,
|
siteTabDisabled: false,
|
||||||
videoTabDisabled: false,
|
videoTabDisabled: false,
|
||||||
canShowVideoTab: {canShow: true, warning: true},
|
canShowVideoTab: {canShow: true, warning: true},
|
||||||
@ -200,7 +206,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
this.logger = new Logger();
|
||||||
|
await this.logger.init();
|
||||||
|
|
||||||
|
this.settings = new Settings({updateCallback: () => this.updateConfig(), logger: logger});
|
||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
|
this.settingsInitialized = true;
|
||||||
|
|
||||||
this.port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
this.port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
||||||
this.execAction.setSettings(this.settings);
|
this.execAction.setSettings(this.settings);
|
||||||
|
|
||||||
@ -243,14 +255,10 @@ export default {
|
|||||||
},
|
},
|
||||||
getSite() {
|
getSite() {
|
||||||
try {
|
try {
|
||||||
if (Debug.debug) {
|
this.logger.log('info','popup', '[popup::getSite] Requesting current site ...')
|
||||||
console.log("[popup.js] requesting current site");
|
|
||||||
}
|
|
||||||
this.port.postMessage({cmd: 'get-current-site'});
|
this.port.postMessage({cmd: 'get-current-site'});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (Debug.debug) {
|
this.logger.log('error','popup','[popup::getSite] sending get-current-site failed for some reason. Reason:', e);
|
||||||
console.log("[popup::getSite] sending get-current-site failed for some reason. Reason:", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getRandomColor() {
|
getRandomColor() {
|
||||||
@ -293,10 +301,7 @@ export default {
|
|||||||
this.canShowVideoTab = {canShow: canShow, warning: warning};
|
this.canShowVideoTab = {canShow: canShow, warning: warning};
|
||||||
},
|
},
|
||||||
processReceivedMessage(message, port) {
|
processReceivedMessage(message, port) {
|
||||||
if (Debug.debug && Debug.comms) {
|
this.logger.log('info', 'popup', '[popup::processReceivedMessage] received message:', message)
|
||||||
console.log("[popup.js] received message set-c", message);
|
|
||||||
console.log("[popup.js] message cloned set-c", JSON.parse(JSON.stringify(message)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.cmd === 'set-current-site'){
|
if (message.cmd === 'set-current-site'){
|
||||||
if (this.site) {
|
if (this.site) {
|
||||||
|
@ -161,7 +161,6 @@ export default {
|
|||||||
}
|
}
|
||||||
site = this.site;
|
site = this.site;
|
||||||
}
|
}
|
||||||
// console.log("SETTINGS FOR SITE", site, "option", option, JSON.parse(JSON.stringify(this.settings.active.sites)))
|
|
||||||
if (this.settings.active.sites[site]) {
|
if (this.settings.active.sites[site]) {
|
||||||
return this.settings.active.sites[site][option];
|
return this.settings.active.sites[site][option];
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,14 +155,12 @@ export default {
|
|||||||
settings: Object,
|
settings: Object,
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
console.log("created!")
|
|
||||||
try {
|
try {
|
||||||
this.videoManualQs = this.settings.active.sites[this.site].DOM.video.manual || this.videoManualQs;
|
this.videoManualQs = this.settings.active.sites[this.site].DOM.video.manual || this.videoManualQs;
|
||||||
this.videoQs = this.settings.active.sites[this.site].DOM.video.querySelectors;
|
this.videoQs = this.settings.active.sites[this.site].DOM.video.querySelectors;
|
||||||
this.videoCss = this.settings.active.sites[this.site].DOM.video.additionalCss;
|
this.videoCss = this.settings.active.sites[this.site].DOM.video.additionalCss;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// that's here just in case relevant settings for this site don't exist yet
|
// that's here just in case relevant settings for this site don't exist yet
|
||||||
console.log("failed to load settings for the site — for video stuff")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -172,16 +170,13 @@ export default {
|
|||||||
this.playerParentNodeIndex = this.settings.active.sites[this.site].DOM.player.videoAncestor;
|
this.playerParentNodeIndex = this.settings.active.sites[this.site].DOM.player.videoAncestor;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// that's here just in case relevant settings for this site don't exist yet
|
// that's here just in case relevant settings for this site don't exist yet
|
||||||
console.log("failed to load settings for the site — for video stuff")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.playerCss = this.settings.active.sites[this.site].css || '';
|
this.playerCss = this.settings.active.sites[this.site].css || '';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// that's here just in case relevant settings for this site don't exist yet
|
// that's here just in case relevant settings for this site don't exist yet
|
||||||
console.log("failed to load settings for the site — for video stuff")
|
|
||||||
}
|
}
|
||||||
console.log("created — got settings:", this.settings)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
ensureSettings(scope) {
|
ensureSettings(scope) {
|
||||||
|
Loading…
Reference in New Issue
Block a user