unfuck progress before switching branches.

This commit is contained in:
Tamius Han 2018-03-07 21:42:40 +01:00
parent 18f1ea26a7
commit ba841c6ea3
4 changed files with 39 additions and 14 deletions

View File

@ -41,17 +41,21 @@ var _pd_getPlayerDimensions = function(element){
return;
}
var playerCandidateNode = element;
try{
var trustCandidateAfterGrows = 2; // if candidate_width or candidate_height increases in either dimensions this many
// times, we say we found our player. (This number ignores weird elements)
// in case our <video> is bigger than player in one dimension but smaller in the other
// if site is coded properly, player can't be wider than that
var candidate_width = Math.max(element.offsetWidth, screen.width);
var candidate_height = Math.max(element.offsetHeight, screen.height);
var candidate_width = Math.max(element.offsetWidth, window.width);
var candidate_height = Math.max(element.offsetHeight, window.height);
var playerCandidateNode = element;
// <video> can't be root in a document, so we can do this
element = element.parentNode;
var grows = trustCandidateAfterGrows;
while(element != undefined){
// odstranimo čudne elemente, ti bi pokvarili zadeve
// remove weird elements, those would break our stuff
@ -59,19 +63,23 @@ var _pd_getPlayerDimensions = function(element){
element = element.parentNode;
continue;
}
if ( element.offsetHeight <= candidate_height &&
element.offsetWidth <= candidate_width ){
playerCandidateNode = element;
candidate_width = element.offsetWidth;
candidate_height = element.offsetHeight;
grows = trustCandidateAfterGrows;
if(Debug.debug){
console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height, "node:", playerCandidateNode);
}
}
else if(trustCandidateAfterGrows --<= 0){
else if(grows --<= 0){
if(Debug.debug && Debug.playerDetect){
console.log("Current element grew in comparrison to the child. We probably found the player. breaking loop, returning current result");
}
@ -80,7 +88,10 @@ var _pd_getPlayerDimensions = function(element){
element = element.parentNode;
}
}
catch(e){
console.log("pdeeee,",e);
}
var dims = {
width: candidate_width,
height: candidate_height,

View File

@ -61,8 +61,10 @@ var _arSetup = function(cwidth, cheight){
// imamo video, pa tudi problem. Ta problem bo verjetno kmalu popravljen, zato setup začnemo hitreje kot prej
// we have a video, but also a problem. This problem will prolly be fixed very soon, so setup is called with
// less delay than before
if(vid.videoWidth === 0 || vid.videoHeight === 0){
_ard_setup_timer = setTimeout(_arSetup, 100);
if(vid.videoWidth === 0 || vid.videoHeight === 0 ){
if(! _ard_timer)
_ard_setup_timer = setTimeout(_arSetup, 100);
return;
}
@ -248,10 +250,17 @@ var _ard_processAr = function(video, width, height, edge_h, edge_w, fallbackMode
var clearTimeoutCount = 0;
var _ard_vdraw = function (timeout){
var _ard_vdraw = function (timeout, force_reset){
// don't allow more than 1 instance
if(_ard_timer){
++clearTimeoutCount;
clearTimeout(_ard_timer);
}
_ard_timer = setTimeout(function(){
_ard_timer = null;
_ard_vdraw_but_for_reals();
},
timeout);
@ -260,8 +269,9 @@ var _ard_vdraw = function (timeout){
var executions = 0;
setInterval(function(){
console.log("this many executions in last second:", executions);
console.log("STATS FOR LAST SECOND\nexecutions:", executions,"; vdraw timeouts cleared:", clearTimeoutCount);
executions = 0;
clearTimeoutCount = 0;
}, 1000);
var _ard_vdraw_but_for_reals = function() {

View File

@ -60,7 +60,7 @@ async function main(){
}
browser.runtime.onMessage.addListener(receiveMessage);
setInterval( ghettoOnChange, 33);
setInterval( ghettoOnChange, 10000);
setInterval( ghettoUrlWatcher, 500);
// ko se na ticevki zamenja video, console.log pravi da ultrawidify spremeni razmerje stranic. preglej element
@ -79,7 +79,7 @@ async function main(){
// here we check (in the most ghetto way) whether player size has changed. If it has, we retrigger resizer.
var _video_recheck_counter = 0;
var _video_recheck_period = 60; // on this many retries
var _video_recheck_period = 1; // on this many retries
function ghettoOnChange(){

View File

@ -200,6 +200,10 @@
</div>
<div id="autoar-basic-settings" class="suboption hidden">
Automatic aspect ratio mode detection.
</div>
<div id="aspect-ratio-settings" class="suboption hidden">
<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>