retiring whitelist/blacklist arrays in Settings, SitesConf is making a comeback instead
This commit is contained in:
parent
a5422abfcd
commit
15aeefbd8c
@ -89,10 +89,12 @@ reintroduce settings page (rebindable keys, blacklist/whitelist management, some
|
||||
|
||||
Various improvements to automatic aspect ratio detection:
|
||||
|
||||
* **Fixed the issues with insane memory usage (#25, #32) and lag that appeared in certain cases after the extension has been running for a while**
|
||||
* **Fixed the situation with insane memory usage due to the automatic aspect ratio detection (#25, #32) and lag that appeared in certain cases after the extension has been running for a while.** There's still fun stuff going on — see notes below.
|
||||
* Improved accuracy of automatic detection. This should fix the issue of rapid switching in dark videos or videos with otherwise uneven edges (#12 - [video](https://www.youtube.com/watch?v=NaTGwlfRB_c); #24 - [video](https://www.youtube.com/watch?v=xvZqHgFz51I) (see the car at the beginning))
|
||||
|
||||
Improved accuracy has increased the base RAM usage. Expect 30-300 MB (in some cases up to 500 MB) per video that's currently playing. (Videos that aren't playing (e.g. videos that are paused or ended) do (should) ***not*** use any meaningful amount of RAM).
|
||||
Improved accuracy has increased the base RAM usage. Expect 30-500 MB per video that's currently playing if you opened the Firefox just for youtube. I've spent 2 hours watching videos on youtube and RAM usage of the extension was 30-400 MB most of the time.
|
||||
|
||||
In some weird cases, though, RAM usage could sway between 30 MB to ~2 gigs? while the video is playing. (Videos that aren't playing (e.g. videos that are paused or ended) do (should) ***not*** use any meaningful amount of RAM).
|
||||
|
||||
* Overpass font is now bundled with this extension, meaning the popup should appear the way it was meant to appear™.
|
||||
|
||||
|
@ -7,7 +7,7 @@ if(Debug.debug)
|
||||
var _se_init = async function(neverFlushStored){
|
||||
|
||||
// if(Debug.flushStoredSettings && neverFlushStored === false)
|
||||
StorageManager.delopt("uw-settings");
|
||||
// StorageManager.delopt("uw-settings");
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[Settings::_se_init()] -------- starting init! ---------");
|
||||
@ -70,8 +70,15 @@ var _se_isWhitelisted = function(site){
|
||||
}
|
||||
|
||||
var Settings = {
|
||||
extensionMode: "whitelist", // how should this extension work?
|
||||
// 'blacklist' - work everywhere except blacklist
|
||||
// 'whitelist' - only work on whitelisted sites
|
||||
// 'disabled' - work nowhere
|
||||
arDetect: {
|
||||
enabled: "global", // thats my csgo rank kappa
|
||||
mode: "blacklist", // how should autodetection work?
|
||||
// 'blacklist' - work by default, problem sites need to be blocked
|
||||
// 'whitelist' - only work if site has been specifically approved
|
||||
// 'disabled' - don't work at all
|
||||
allowedMisaligned: 0.05, // top and bottom letterbox thickness can differ by this much.
|
||||
// Any more and we don't adjust ar.
|
||||
allowedArVariance: 0.075, // amount by which old ar can differ from the new (1 = 100%)
|
||||
@ -90,8 +97,6 @@ var Settings = {
|
||||
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
|
||||
blacklist: [], // banned on enabled: "global"
|
||||
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,
|
||||
@ -131,10 +136,6 @@ var Settings = {
|
||||
colors:{
|
||||
// criticalFail: "background: #fa2; color: #000"
|
||||
},
|
||||
whitelist: [],
|
||||
blacklist: ["vimeo.com", "reddit.com", "imgur.com"],
|
||||
isBlacklisted: _se_isBlacklisted,
|
||||
isWhitelisted: _se_isWhitelisted,
|
||||
init: _se_init,
|
||||
save: _se_save,
|
||||
reload: _se_reload,
|
||||
|
@ -1,131 +1,168 @@
|
||||
// functions here. load from storage happens later down the line
|
||||
var _sc_nonfsAutoar = function() {
|
||||
var hostname = window.location.hostname;
|
||||
// var _sc_SITES = {
|
||||
// "vimeo.com" : {
|
||||
// extraCss: [],
|
||||
// bannedCss: [],
|
||||
// nonfsPlayerMod: function(){
|
||||
// // hack player to take all the width
|
||||
// $("head").append('<style type="text/css">.uw_forceFullWidth {width: 100% !important} .uw_forceCenter{text-align: center;}</style>');
|
||||
//
|
||||
// var e = document.getElementsByClassName("player_outro_area")[0];
|
||||
// e.classList.add("uw_forceFullWidth");
|
||||
// e.classList.add("uw_forceCenter");
|
||||
// e = document.getElementsByClassName("player_container")[0];
|
||||
// e.classList.add("uw_forceFullWidth");
|
||||
// e.classList.add("uw_forceCenter");
|
||||
//
|
||||
// $("video")[0].style.display = "inline-block";
|
||||
// },
|
||||
// fsPlayerMod: function(){
|
||||
// // hack player to take all the width
|
||||
// $("head").append('<style type="text/css">.uw_forceFullWidth {width: 100% !important} .uw_forceCenter{text-align: center;}</style>');
|
||||
//
|
||||
// var e = document.getElementsByClassName("player_outro_area")[0];
|
||||
// e.classList.add("uw_forceFullWidth");
|
||||
// e.classList.add("uw_forceCenter");
|
||||
// e = document.getElementsByClassName("player_container")[0];
|
||||
// e.classList.add("uw_forceFullWidth");
|
||||
// e.classList.add("uw_forceCenter");
|
||||
//
|
||||
// $("video")[0].style.display = "inline-block";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
var _sc_init(){
|
||||
|
||||
if( _sc_SITES[hostname] === undefined)
|
||||
return _sc_SITES["DEFAULT"].autoAr.nonfs;
|
||||
|
||||
return _sc_SITES[hostname].autoAr.nonfs;
|
||||
}
|
||||
|
||||
var _sc_getPlayerTag = function(){
|
||||
var hostname = window.location.hostname;
|
||||
|
||||
if( _sc_SITES[hostname] === undefined)
|
||||
return undefined;
|
||||
|
||||
if( _sc_SITES[hostname].autoAr.playerIdentificationType === undefined)
|
||||
return undefined;
|
||||
|
||||
|
||||
if( _sc_SITES[hostname].autoAr.playerIdentificationType == "id")
|
||||
return document.getElementById(_sc_SITES[hostname].autoAr.playerIdentificationString);
|
||||
|
||||
if( _sc_SITES[hostname].autoAr.playerIdentificationType == "className")
|
||||
return document.getElementsByClassName(_sc_SITES[hostname].autoAr.playerIdentificationString)[0];
|
||||
|
||||
return undefined;
|
||||
var _sc_reload() {
|
||||
_sc_init();
|
||||
}
|
||||
|
||||
// popravi vse, kar je narobe z ne-celozaslonskim predvajalnikom (če je funkcija definirana)
|
||||
// fix everything that's wrong with the non-fs player, if the function is defined
|
||||
var _sc_prepareNonfsPlayer = function(){
|
||||
var hostname = window.location.hostname;
|
||||
|
||||
if( SITES[hostname] === undefined)
|
||||
return;
|
||||
|
||||
if( SITES[hostname].autoAr.nonfsPlayerMod === undefined )
|
||||
return;
|
||||
|
||||
SITES[hostname].autoAr.nonfsPlayerMod();
|
||||
}
|
||||
|
||||
var _sc_getMode = function(site){
|
||||
if(! this || !this.sites || ! this.sites[site] )
|
||||
return "global";
|
||||
|
||||
return this.sites[site].enabled;
|
||||
var _sc_save() {
|
||||
StorageManager.delopt("uw-siteopts");
|
||||
StorageManager.setopt({"uw-siteopts": JSON.stringify(_sc_sites)});
|
||||
}
|
||||
|
||||
|
||||
var _sc_createEmptySite() {
|
||||
return {
|
||||
status: "follow-global",
|
||||
arStatus: "follow-global",
|
||||
statusEmbedded: "follow-global",
|
||||
};
|
||||
}
|
||||
|
||||
var _sc_callback = function(conf) {
|
||||
if (conf === null || conf === {} || conf === [] || conf == ""){
|
||||
StorageManager.setopt( {"sitesconf": _sc_SITES} );
|
||||
this.sites = _sc_SITES;
|
||||
}
|
||||
var _sc_siteEnabled(site){
|
||||
|
||||
this.sites = conf;
|
||||
}
|
||||
|
||||
var _sc_init = function() {
|
||||
return StorageManager.getopt("sitesconf", _sc_callback);
|
||||
}
|
||||
|
||||
|
||||
// Privzete nastavitve. Kasneje jih zamenjamo s tistimi v localStorage (če obstajajo)
|
||||
// this is the default config. We replace it with the ones in localStorage (if they exist)
|
||||
|
||||
/* Konfiguracija za posamezno stran:
|
||||
* Config for a given page
|
||||
*
|
||||
* <location.hostname>: {
|
||||
* enabled: string, // whitelist, blacklist, global
|
||||
* type: string,
|
||||
* autoAr: { // konfiguracija za samodejno zaznavanje razmerja stranic | conf for aspect ratio autodetection
|
||||
* active: bool // aktivno zaznavanje — zaznavamo letterbox na sliki | active detection: scan the image
|
||||
* passive: bool // pasivno zaznavanje — za ar vprašamo imdb in ostale | passive detection: query imdb
|
||||
* // for aspect ratio [DEPRECATED]
|
||||
* nonfs: bool // zaznavanje razmerja stranic izven celozaslonskega načina | detect ar if not in
|
||||
* // fullscreen? [DEPRECATED]
|
||||
* playerIdentificationString: string
|
||||
* playerIdentificationType: string // "className" | "id"
|
||||
* nonfsExtra: function // non-fs hacks are generally site-specific, which means we need to write site-specific code
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var _sc_SITES = {
|
||||
"vimeo.com" : {
|
||||
extraCss: [],
|
||||
bannedCss: [],
|
||||
nonfsPlayerMod: function(){
|
||||
// hack player to take all the width
|
||||
$("head").append('<style type="text/css">.uw_forceFullWidth {width: 100% !important} .uw_forceCenter{text-align: center;}</style>');
|
||||
|
||||
var e = document.getElementsByClassName("player_outro_area")[0];
|
||||
e.classList.add("uw_forceFullWidth");
|
||||
e.classList.add("uw_forceCenter");
|
||||
e = document.getElementsByClassName("player_container")[0];
|
||||
e.classList.add("uw_forceFullWidth");
|
||||
e.classList.add("uw_forceCenter");
|
||||
|
||||
$("video")[0].style.display = "inline-block";
|
||||
},
|
||||
fsPlayerMod: function(){
|
||||
// hack player to take all the width
|
||||
$("head").append('<style type="text/css">.uw_forceFullWidth {width: 100% !important} .uw_forceCenter{text-align: center;}</style>');
|
||||
|
||||
var e = document.getElementsByClassName("player_outro_area")[0];
|
||||
e.classList.add("uw_forceFullWidth");
|
||||
e.classList.add("uw_forceCenter");
|
||||
e = document.getElementsByClassName("player_container")[0];
|
||||
e.classList.add("uw_forceFullWidth");
|
||||
e.classList.add("uw_forceCenter");
|
||||
|
||||
$("video")[0].style.display = "inline-block";
|
||||
// če za stran nismo določili načina delovanja, potem storimo privzeto stvar
|
||||
// if we haven't defined options for a site, we do the default thing
|
||||
if( _sc_sites[site] == undefined || _sc_sites[site].status == "follow-global"){
|
||||
if ( Settings.extensionMode == "blacklist" ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( _sc_sites[site].status == "whitelisted" )
|
||||
return true;
|
||||
|
||||
if( _sc_sites[site].status == "blacklisted" )
|
||||
return false;
|
||||
|
||||
// sem ne bi smeli priti, vendar pa za varnost naredimo en return
|
||||
// we shouldn't come here but let's do a safety return
|
||||
return false;
|
||||
}
|
||||
|
||||
var _sc_arEnabled(site){
|
||||
if( _sc_sites[site] == undefined || _sc_sites[site].arStatus == "follow-global" ){
|
||||
if(Settings.arDetect.mode == "blacklist" ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( _sc_sites[site].arStatus == "whitelisted" )
|
||||
return true;
|
||||
|
||||
if( _sc_sites[site].arStatus == "blacklisted" )
|
||||
return false;
|
||||
}
|
||||
|
||||
var _sc_updateSiteStatus(site, status){
|
||||
// status: {}
|
||||
// status.status - optional
|
||||
// status.arStatus - optional
|
||||
// status.statusEmbedded - optional
|
||||
//
|
||||
// <==[ Valid values for options: ]==>
|
||||
//
|
||||
// status, arStatus, statusEmbedded:
|
||||
//
|
||||
// * whitelisted — always allow
|
||||
// * follow-global — allow if default is to allow, block if default is to block
|
||||
// * blacklisted — never allow
|
||||
|
||||
if( _sc_sites[site] == undefined ){
|
||||
_sc_sites[site] = _sc_createEmptySite();
|
||||
}
|
||||
|
||||
if(status.status != undefined ){
|
||||
_sc_sites[site].status = status.status;
|
||||
}
|
||||
if(status.arStatus != undefined ){
|
||||
_sc_sites[site].arStatus = status.arStatus;
|
||||
}
|
||||
if(status.statusEmbedded != undefined ){
|
||||
_sc_sites[site].statusEmbedded = status.statusEmbedded;
|
||||
}
|
||||
|
||||
_sc_save();
|
||||
}
|
||||
|
||||
// Nastavitve za posamezno stran
|
||||
// Config for a given page:
|
||||
//
|
||||
// <hostname> : {
|
||||
// status: <option> // should extension work on this site?
|
||||
// arStatus: <option> // should we do autodetection on this site?
|
||||
// statusEmbedded: <option> // should we do autodetection on this site?
|
||||
// }
|
||||
//
|
||||
// Veljavne vrednosti za možnosti
|
||||
// Valid values for options:
|
||||
//
|
||||
// status, arStatus, statusEmbedded:
|
||||
//
|
||||
// * whitelisted — always allow
|
||||
// * follow-global — allow if default is to allow, block if default is to block
|
||||
// * blacklisted — never allow
|
||||
//
|
||||
|
||||
var _sc_sites = {
|
||||
"youtube.com" : {
|
||||
status: "whitelisted", // should extension work on this site?
|
||||
arStatus: "follow-global", // should we enable autodetection
|
||||
statusEmbedded: "whitelisted", // should extension work for this site when embedded on other sites?
|
||||
override: false // ignore value localStorage in favour of this
|
||||
},
|
||||
"netflix.com" : {
|
||||
status: "whitelisted",
|
||||
arStatus: "blacklisted",
|
||||
statusEmbedded: "whitelisted",
|
||||
override: false
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var SitesConf = {
|
||||
nonfsArDetectEnabled: _sc_nonfsAutoar,
|
||||
getPlayerTag: _sc_getPlayerTag,
|
||||
prepareNonfsPlayer: _sc_prepareNonfsPlayer,
|
||||
getMode: _sc_getMode,
|
||||
siteopts: _sc_sites,
|
||||
init: _sc_init,
|
||||
sites: null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user