Developing Extensions for Google Chrome

Developing Extensions for Google Chrome 07: Improving the backend

11 videos

88 minutes

As long as you write code in the backend there are things to improve and debug errors, so in this video we will devote to it review the operation was unstable JavaScript code we've written before and correct for the backend work is solid  let's see how it's done in this video

I'm sorry I have to pause a recording time. Well he continued explaining, then that does this, one index the indexOf where this is found, it will search all the HTML code and the first time you are textually this We will say what position among all code, then the index're both going to look when you close this tag from the index and one

not any tag but after you have opened this tag, when you close this tag because the first closing after this has to be closed this tag and then the rate three when you find this closed tag, I mean when I finish and this way because in between will be the title equals something. and then also find when you close the label, the good element the label, the label is this, when it ends with the element that would be here

then name is a substring between the index and the index two three, so if the video puts this example video_sadsd and then the closing element our application will catch what is what we want to know the name of the video, and well you basically do the same but with different things, such as this would be the link, this would be the page but to put it inside an iframe

and then we do the same getEmbedlink the same three links and videoEmbedString important here too I had forgotten before videoName equals videoNameString if videoName remember is defined here so this variable serves you in all functions because of videoNameString this is defined in here so we only served in this block also important to understand that where you define the variable

that's where it is, if you want a global variable would have to set out all the blocks, then then getEmbedLink and you send the text of all the code of the web pages, three indexes and does exactly the same but just one here gets the index  good really does not do the same because there are only two indices is true so the index three is a bit useless do not know why I put

but pretty useless really better not even do them is a bit useless, then you will find the href, the watch is always the videos so it is unique and the first to find it will be the index of this, it will take from response.indexOf (STRING.b) this is, but here what we do is add to the index because we think the index will always give from the first letter and here in this case we want is just after the 'v'

then we say when we get that, then we add how many letters there, and the index closed two when you find a rate quote after one that is when you close this tag, and here we do the same videoEmbendString is the code of the page and a substring of the two indices and embedLink which is also a global variable is equal to STRING.c that are always links to embed YouTube videos more variable videoEmbedString

and then we have already done that look forever every two seconds which is the last video and this is how it's going to be checking our system if there is a new video or not, then now is the grace that having this here defined outside block also can access when we open this link so we have done basically with a very short script we will be able to access the variables in this script background

and now we will be able to make out which is the last video of a channel. Well we continue with another video if you remember in the last video we made this script, good rather have explained its operation but hey it does not matter is quite useful, is pretty good and we will already be used to check when a new video

But here is the code when notifies you when there is a new video that then we'll show later, this really does is take which it is the last video but do not tell us if there's a new video just catch it and then when we open up this can access it without having to wait to seek and everything, because we have already stored here and open it instantly

so now at a time when we go with the following script

To find new courses, subscribe. There will be no spam, promised :)

About the Author

foto de jotajotavm
José Javier Villena

Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.