Write a super star brush class script with JavaScript, isn’t it fragrant?

Time:2020-10-25

In this paper, JS beginners Xiaobai, the God disturbed!!

preface

My sophomore was obsessed with reptiles, so I taught myself HTML, CSS, and JS, but they were always used to analyze and analyze pages when writing crawlers. During the epidemic, I chose too many superstar Erya online courses. Of course, I was reluctant to spend money on them. So I thought of my old friend JS, and something interesting happened,

Brief introduction of ideas

Superstar page video playback using HTML5 video tag to achieve playback.HTML <video>elementIt is used to embed media player in HTML or XHTML documents to support video playback within documents. You can also<video>Tags are used for audio content, but elements may be more appropriate for user experience. Therefore, by using JS to operate the video attributes, plus some loops to judge whether the video has been played or not, and automatically find the next chapter, the video can be played automatically

The source code is posted below

//Get the URL of all chapters
 var article=document.querySelectorAll(".ncells a");
 var checkIsFinish=document.querySelectorAll(".jobUnfinishCount");
 var i=0;
 var flag=0;
 for(i=0;i<checkIsFinish.length;i++){
 if(checkIsFinish[i].value==2){
 break;
 }
 }
​
 //Go through the first chapter
 article[++i].click();
 //Timing task, timing detection of video playback
 window.setInterval(function(){
 //Judge the difference between the first video of online class and the video of other chapters
 if(flag==0&&document.querySelector("#dct3")!=null){
 document.querySelector("#dct2").click();
 flag=1;
 }
 var first=document.querySelector("iframe").contentDocument;
 var second=first.querySelector("iframe").contentDocument;
 //Check if the video is played
 if($("iframe").contents().find(".ans-job-finished").length != 0){
 console.log (the "completion");
 article[++i].click();
 article[i].click();
 flag=0;
 }else{
 var media=second.querySelector("video");
 media.volume=0 ; // set mute
 //Cycle detection is suspended so that it can play automatically when the page is minimized
 if(media.paused){
 console.log ("pause detected");
 media.play();
 }
 }
 },10000);
I want to tell you that I don’t know if I can use this code now (you are still a person?) Because I missed the online course perfectly this semester, I can’t check the usability of the code now. The layout elements of the page may change in such a long time. But you know the idea, the process of their own implementation will be very interesting, after the realization will be very successful.

last

I am learning crawlers to add my WeChat to the official account. I have done the FIF spoken language brush task through the crawler (now the code is invalid, but I can tell you the way of thinking). You can also visit my GitHub warehouse, and I clone a big God written project to dream space newspaper task, and simply change it.Grab the taskThose who are interested can study it.


Great resources!!!

followXiaobai doesn’t want to be a farmerThe official account of WeChat.

Background replyJava core technology volumeKeyword claim《Java core technology volume》pdf

replyjvmClaim《Deep understanding of Java virtual machine》PDF and《Write your own JVM

replyDesign patternsClaim《Headfirst design pattern》pdf

replycomputer networkClaim《Computer network top down》pdf

Last but not least

I don’t want to be a code farmer. I usually write some technical blogs, recommend excellent programmers, bloggers and excellent java learning resources. I hope to make progress and grow together with you.

If there are any mistakes in the above contents, please point out. Thank you

Official account click on the exchange, add my WeChat, exchange programming together!

The official account: Xiao Bai does not want to be a code farmer.
Write a super star brush class script with JavaScript, isn't it fragrant?