2017-09-24 01:54:46 +02:00
// Extension settings are in this file. Site configuration is in Sites.js
// todo: move keybinds here
if ( Debug . debug )
console . log ( "Loading: Settings.js" ) ;
2017-12-29 23:34:40 +01:00
var _se _init = async function ( neverFlushStored ) {
2018-02-01 00:26:16 +01:00
// if(Debug.flushStoredSettings && neverFlushStored === false)
// StorageManager.delopt("uw-settings");
2017-12-29 23:34:40 +01:00
if ( Debug . debug )
console . log ( "[Settings::_se_init()] -------- starting init! ---------" ) ;
var newSettings = await StorageManager . getopt _async ( "uw-settings" ) ;
if ( Debug . debug )
2018-02-01 00:26:16 +01:00
console . log ( "[Settings::_se_init()] settings saved in localstorage are:" , newSettings , " - if that's empty, it's gonna be replaced by this:" , JSON . stringify ( this ) , ")" ) ;
2017-12-29 23:34:40 +01:00
2018-02-01 00:26:16 +01:00
if ( ( Object . keys ( newSettings ) . length === 0 && newSettings . constructor === Object ) ) {
2018-02-02 00:21:29 +01:00
console . log ( "[Settings::_se_init()] replacing settings" ) ;
2018-02-01 00:26:16 +01:00
StorageManager . setopt ( { "uw-settings" : JSON . stringify ( this ) } ) ;
2017-12-29 23:34:40 +01:00
}
else {
2018-02-02 00:21:29 +01:00
var actualSettings = JSON . parse ( newSettings [ "uw-settings" ] ) ;
if ( Debug . debug )
console . log ( "[Settings::_se_init()] parsed settings:" , actualSettings ) ;
for ( var k in actualSettings )
this [ k ] = actualSettings [ k ] ;
2017-12-29 23:34:40 +01:00
}
if ( Debug . debug )
console . log ( "[Settings::_se_init] settings have been loaded/reloaded. Current state: " , this ) ;
2017-12-17 22:56:07 +01:00
}
2018-02-01 00:26:16 +01:00
var _se _save = function ( settings ) {
2017-12-29 23:34:40 +01:00
StorageManager . delopt ( "uw-settings" ) ;
2018-02-01 00:26:16 +01:00
if ( settings !== undefined ) {
StorageManager . setopt ( { "uw-settings" : JSON . stringify ( settings ) } ) ;
}
else {
StorageManager . setopt ( { "uw-settings" : JSON . stringify ( this ) } ) ;
}
if ( Debug . debug )
console . log ( "[Settings::_se_save()] saving settings:" , JSON . stringify ( settings ) ) ;
2017-12-29 23:34:40 +01:00
}
var _se _reload = function ( ) {
this . init ( true ) ;
}
2018-02-04 17:39:26 +01:00
var _se _isBlacklisted = function ( site ) {
return this . blacklist . indexOf ( site ) > - 1 ;
}
var _se _isWhitelisted = function ( site ) {
return this . whitelist . indexOf ( site ) > - 1 ;
}
2017-12-29 23:34:40 +01:00
var Settings = {
2017-09-24 01:54:46 +02:00
arDetect : {
2017-12-29 23:34:40 +01:00
enabled : "global" , // thats my csgo rank kappa
2018-02-15 00:17:58 +01:00
allowedMisaligned : 0.05 , // top and bottom letterbox thickness can differ by this much.
// Any more and we don't adjust ar.
2018-01-02 03:36:29 +01:00
allowedArVariance : 0.075 , // amount by which old ar can differ from the new (1 = 100%)
2017-12-29 23:34:40 +01:00
timer _playing : 30 ,
timer _paused : 3000 ,
2017-12-31 18:26:59 +01:00
timer _error : 3000 ,
hSamples : 1280 ,
vSamples : 720 ,
staticSampleCols : 9 , // we take a column at [0-n]/n-th parts along the width and sample it
randomSampleCols : 0 , // we add this many randomly selected columns to the static columns
staticSampleRows : 9 , // forms grid with staticSampleCols. Determined in the same way. For black frame checks
2017-09-24 01:54:46 +02:00
blacklist : [ ] , // banned on enabled: "global"
2018-02-15 00:17:58 +01:00
whitelist : [ ] , // enabled on enabled: "whitelist-only", disabled on "disabled"
guardLine : { // all pixels on the guardline need to be black, or else we trigger AR recalculation
// (if AR fails to be recalculated, we reset AR)
enabled : true ,
ignoreEdgeMargin : 0.20 , // we ignore anything that pokes over the black line this close to the edge
// (relative to width of the sample)
ignoreThis : "we just don't want to remove the comma in previous line. this reserved."
} ,
arSwitchLimiter : { // to be implemented
switches : 2 , // we can switch this many times
period : 2.0 // per this period
}
2017-09-24 01:54:46 +02:00
} ,
arChange : {
samenessTreshold : 0.025 , // if aspect ratios are within 2.5% within each other, don't resize
} ,
miscFullscreenSettings : {
2017-12-29 23:34:40 +01:00
videoFloat : "center"
2017-12-17 22:56:07 +01:00
} ,
2017-12-31 18:26:59 +01:00
colors : {
// criticalFail: "background: #fa2; color: #000"
} ,
2018-02-01 00:26:16 +01:00
whitelist : [ ] ,
blacklist : [ "vimeo.com" ] ,
2018-02-04 17:39:26 +01:00
isBlacklisted : _se _isBlacklisted ,
isWhitelisted : _se _isWhitelisted ,
2017-12-29 23:34:40 +01:00
init : _se _init ,
save : _se _save ,
reload : _se _reload ,
2017-09-24 01:54:46 +02:00
}