DuoLingo JavaScript

I have been studying Spanish for over a year. One of the tools I use to learn Spanish is DuoLingo. I began to copy and paste a lesson’s sentences so I can refer to them later when working for Legendary Status. The problem with this is that copying a sentence will give you each word but not put together in a sentence. Let me give you an example.

Tenemos que pensar en muchas cosas.

Tenemos que pensar en muchas cosas.

If you copy that sentence and paste it you will get:

Tenemos
que
pensar
en
muchas
cosas
.

This is very annoying. I have to delete every line break after the words to get the full sentence. Fortunately, my JavaScript skills came in handy again. I wrote the following script to copy the sentence:


var sentence = "";
for (var i = 0; i < document.getElementsByClassName("_34k_q _3Lg1h _13doy").length; i++) {
	var word = document.getElementsByClassName("_34k_q _3Lg1h _13doy")[i].textContent;
  sentence = sentence + word + " ";
}
alert(sentence);

This gives you a JavaScript pop-up with the complete sentence that you can copy:

DuoLingo JavaScript

DuoLingo JavaScript

Usually I use Greasemonkey for JavaScript that interacts with a web page I frequently visit and wish to tweak. My favorite use of this is to hide annoying things in a web page. But Greasemonkey will not work with DuoLingo because a lesson does not load a new page for every question. So a script cannot be invoked every time the lesson progresses to a new sentence. Until I find a better solution I have to run the JavaScript snippet in the web developer tools.

This entry was posted in General and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit exceeded. Please complete the captcha once again.