Release v2.1.0 (sans readme)

This commit is contained in:
Tamius Han 2018-02-04 17:39:26 +01:00
parent b13eff44e3
commit 2c0f0ed607
8 changed files with 67 additions and 34 deletions

View File

@ -1,6 +1,6 @@
// Set prod to true when releasing
// _prod = true;
_prod = false;
_prod = true;
// _prod = false;
Debug = {
debug: true,

View File

@ -54,6 +54,14 @@ var _se_reload = function(){
this.init(true);
}
var _se_isBlacklisted = function(site){
return this.blacklist.indexOf(site) > -1;
}
var _se_isWhitelisted = function(site){
return this.whitelist.indexOf(site) > -1;
}
var Settings = {
arDetect: {
enabled: "global", // thats my csgo rank kappa
@ -81,6 +89,8 @@ var Settings = {
},
whitelist: [],
blacklist: ["vimeo.com"],
isBlacklisted: _se_isBlacklisted,
isWhitelisted: _se_isWhitelisted,
init: _se_init,
save: _se_save,
reload: _se_reload,

View File

@ -40,7 +40,12 @@ var _pd_getPlayerDimensions = function(element){
height: screen.height
};
}
if(element == null){
if(Debug.debug)
console.log("[PlayerDetect::_pd_getPlayerDimensions] element is not valid, doing nothing.", element)
return;
}
var playerCandidateNode = element;
// in case our <video> is bigger than player in one dimension but smaller in the other

View File

@ -115,7 +115,19 @@ var _res_setAr = function(ar, playerDimensions){
GlobalVars.lastAr = {type: "static", ar: ar};
var vid = GlobalVars.video;
if(vid == null || vid==undefined || vid.videoWidth == 0 || vid.videoHeight == 0){
vid = document.getElementsByTagName("video")[0];
GlobalVars.video = vid;
if(vid == null || vid==undefined || vid.videoWidth == 0 || vid.videoHeight == 0){
if(Debug.debug)
console.log("[Resizer::_res_setAr] You thought there is a video, didn't you? Tricked you. Never would be.", vid);
return;
}
}
if(Debug.debug)
console.log("[Resizer::_res_setAr] video:",vid,"width:", vid.videoWidth, "height:", vid.videoHeight);
// Dejansko razmerje stranic datoteke/<video> značke
// Actual aspect ratio of the file/<video> tag
@ -123,10 +135,10 @@ var _res_setAr = function(ar, playerDimensions){
if(ar == "default")
ar = fileAr;
if(Debug.debug)
console.log("[Resizer::_res_setAr] ar is " ,ar, ", playerDimensions are ", playerDimensions);
console.log("[Resizer::_res_setAr] ar is " ,ar, ", file ar is", fileAr, ", playerDimensions are ", playerDimensions);
var videoDimensions = {
width: 0,
@ -157,13 +169,13 @@ var _res_setAr = function(ar, playerDimensions){
}
if(Debug.debug){
console.log("[Resizer::_res_setArFs] Video dimensions: ",videoDimensions, "playerDimensions:",playerDimensions);
console.log("[Resizer::_res_setAr] Video dimensions: ",videoDimensions, "playerDimensions:",playerDimensions);
}
var cssValues = _res_computeOffsets(videoDimensions, playerDimensions);
if(Debug.debug){
console.log("[Resizer::_res_setArFs] Offsets for css are: ",cssValues);
console.log("[Resizer::_res_setAr] Offsets for css are: ",cssValues);
}
_res_applyCss(cssValues);

View File

@ -77,6 +77,22 @@ async function _uwbg_onTabSwitched(activeInfo){
// todo: change extension icon depending on whether there's a video on the page or not
}
async function _uwbg_check4videos(){
if(BgVars.hasVideos)
return;
var videoFrameList = Comms.sendToEach({"cmd":"has-videos"});
if(Debug.debug)
console.log("[uw-bg::check4videos] got updated list of frames and whether they have videos", videoFrameList);
var hasVideos = false;
for(frame of videoFrameList){
hasVideos |= frame.response.hasVideos;
}
BgVars.hasVideos = hasVideos;
}
async function _uwbg_registerVideo(tabId){
var tabs = await Comms.getActiveTab();

View File

@ -48,32 +48,17 @@ async function main(){
if(Debug.debug)
console.log("uw::document.ready | document is ready. Starting ar script ...");
if(SitesConf.getMode(window.location.hostname) == "blacklist" ){
if(Settings.isBlacklisted(window.location.hostname)){
if(Debug.debug)
console.log("uw::document.ready | site", window.location.hostname, "is blacklisted.");
return;
}
if( ExtensionConf.mode == "none" ){
if(Debug.debug)
console.log("uw::document.ready | Extension is soft-disabled via popup");
return;
}
if( ExtensionConf.mode == "whitelist" && SitesConf.getMode(window.location.hostname) != "whitelist"){
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;
}
}
if(Settings.arDetect.enabled == "global"){
if(Debug.debug)
console.log("[uw::main] Aspect ratio detection is enabled. Starting ArDetect");
// ArDetect.arSetup();
ArDetect.arSetup();
}
else{
if(Debug.debug)
@ -98,9 +83,16 @@ function ghettoOnChange(){
if(_video_recheck_counter++ > _video_recheck_period){
_video_recheck_counter = 0;
if(GlobalVars.video === null){
if ( GlobalVars.video == null ||
GlobalVars.video == undefined ||
GlobalVars.video.videoWidth == 0 ||
GlobalVars.video.videoHeight == 0 ){
var video = document.getElementsByTagName("video")[0];
if(video !== undefined){
if ( video !== undefined &&
video !== null &&
video.videoWidth > 0 &&
video.videoHeight > 0 ){
GlobalVars.video = video;
Comms.sendToBackgroundScript({"cmd":"register-video"});
}

View File

@ -229,10 +229,8 @@ function openMenu(menu){
}
}
// if(menu != "noVideo"){
// selectedMenu = menu;
// MenuTab[menu].classList.add("selected");
// }
selectedMenu = menu;
MenuTab[menu].classList.add("selected");
}
function _arctl_onclick(command){
@ -422,7 +420,7 @@ document.addEventListener("click", (e) => {
var command = getcmd(e);
if(command)
sendMessage(command);
Comms.sendToAll(command);
return true;
});

View File

@ -160,7 +160,7 @@
Settings for this site
</div>
<div id="_menu_aspectratio" class="menu-item selected _menu_aspectratio">
Aspect ratio and alignment
Letterbox removal and alignment
</div>
<div id="_menu_csshacks" class="menu-item disabled hidden _menu_hacks">
CSS hacks for this site
@ -204,7 +204,7 @@
<div id="no-videos-warning" class="warning">No videos were detected on this page. The buttons may not work at all. Check that this site is not blacklisted and reload the page.</div>
<div class="row">
<span class="label">Force aspect ratio:</span>
<span class="label">Cropping mode:</span>
<div class="button-row">
<a class="button _changeAr _ar_auto w24">Auto-detect<br/><span id="_b_changeAr_autoar_key" class="smallcaps small darker"></span></a>
<a class="button _changeAr _ar_reset w24">Reset<br/><span id="_b_changeAr_reset_key" class="smallcaps small darker"></span></a>