Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
allenpoon committed Mar 3, 2017
1 parent 7210d1e commit 4cc5be6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"YouTube Enhancer",
"version":"11.1.7",
"version":"11.1.8",
"manifest_version":2,
"description":"Enhance user experience in YouTube",
"content_scripts":[
Expand Down
63 changes: 32 additions & 31 deletions src/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

this.video.loop=true;
if( this.duration.to+0.001<p.getDuration()){
if( p.getPlayerState()===1){
if(p.getPlayerState()===1){
this.setTimer(()=>this.setLoop());
}
}
Expand All @@ -85,7 +85,7 @@

this.video.loop=false;
if(this.duration.to+0.05<p.getDuration()){
if( p.getPlayerState()===1){
if(p.getPlayerState()===1){
this.setTimer(()=>this.setCrop());
}
}
Expand Down Expand Up @@ -291,12 +291,12 @@
from:p.duration.from,
to:p.duration.to,
curMode:p.curMode
},
()=>(p.duration={})
}
);
p.duration={};
p.setStop();
p.videoID=null;
}
p.setStop();
p.videoID=null;
},
RemoveUIRef:function(){
this.parent.ui={};
Expand Down Expand Up @@ -442,48 +442,49 @@
p.duration.to=info.to;
p.toggle(info.curMode);
}
this.state.durationLoading=this.state.durationLoaded=p.IndexedDB.isReqOpen;
this.state.durationLoaded=true;
});
}
},
// changing:false,
// state:{},
main:function(){
let p=this.parent;
let newVideoID=p.player.getVideoData().video_id;
if(this.state&&this.state.curVideoID!=newVideoID){
this.changing=false;
delete this.state;
}
if(!this.changing&&p.isVideoChanged()){
let newVideoID=p.player.getVideoData().video_id;
if(newVideoID){
if(!this.state){
if(p.videoID){
p.unload.main();
}
p.unload.main();
this.state={};
this.state.curVideoID=newVideoID;
this.main();
}else{
let result=true;
}

this.changing=true;
for(let x in this){
this[x].constructor==Function&&this[x]();
}
this.changing=false;
let result=true;

for(let x in this.state){
if(!this.state[x]){
result=false;
break;
}
}
this.changing=true;
for(let x in this){
this[x].constructor==Function&&this[x]();
}
this.changing=false;

if(result){
// allow event trigger
p.videoID=newVideoID;
delete this.state;
}else{
setTimeout(()=>this.main());
for(let x in this.state){
if(!this.state[x]){
result=false;
break;
}
}

if(result){
// allow event trigger
p.videoID=newVideoID;
delete this.state;
}else{
setTimeout(()=>this.main(),100);
}
}
}
}
Expand Down
Loading

0 comments on commit 4cc5be6

Please sign in to comment.