{"id":4236,"date":"2023-05-22T12:41:14","date_gmt":"2023-05-22T17:41:14","guid":{"rendered":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=4236"},"modified":"2023-05-22T12:43:49","modified_gmt":"2023-05-22T17:43:49","slug":"duolingo-javascript","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=4236","title":{"rendered":"DuoLingo JavaScript"},"content":{"rendered":"<p>I have been studying Spanish for over a year. One of the tools I use to learn Spanish is <a href=\"https:\/\/www.duolingo.com\"><strong>DuoLingo<\/strong><\/a>. I began to copy and paste a lesson&#8217;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.<\/p>\n<div id=\"attachment_4237\" style=\"width: 585px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-Write-This-In-English.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4237\" src=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-Write-This-In-English.jpg\" alt=\"Tenemos que pensar en muchas cosas.\" class=\"wp-image-4237 size-full\" width=\"575\" height=\"233\" srcset=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-Write-This-In-English.jpg 575w, http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-Write-This-In-English-400x162.jpg 400w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><\/a><p id=\"caption-attachment-4237\" class=\"wp-caption-text\">Tenemos que pensar en muchas cosas.<\/p><\/div>\n<p>If you copy that sentence and paste it you will get:<\/p>\n<pre>Tenemos\r\nque\r\npensar\r\nen\r\nmuchas\r\ncosas\r\n.<\/pre>\n<p>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:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>\r\nvar sentence = \"\";\r\nfor (var i = 0; i &lt; document.getElementsByClassName(\"_34k_q _3Lg1h _13doy\").length; i++) {\r\n\tvar word = document.getElementsByClassName(\"_34k_q _3Lg1h _13doy\")[i].textContent;\r\n  sentence = sentence + word + \" \";\r\n}\r\nalert(sentence);\r\n<\/code><\/pre>\n<\/div>\n<p>This gives you a JavaScript pop-up with the complete sentence that you can copy:<\/p>\n<div id=\"attachment_4240\" style=\"width: 650px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4240\" src=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript-1024x422.jpg\" alt=\"DuoLingo JavaScript\" class=\"wp-image-4240 size-large\" width=\"640\" height=\"264\" srcset=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript-1024x422.jpg 1024w, http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript-400x165.jpg 400w, http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript-768x317.jpg 768w, http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript-1536x633.jpg 1536w, http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/wp-content\/uploads\/2023\/05\/DuoLingo-JavaScript.jpg 1628w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-4240\" class=\"wp-caption-text\">DuoLingo JavaScript<\/p><\/div>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s sentences so I can refer to them later when working for Legendary &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=4236\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1983,1152,1963],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4236"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4236"}],"version-history":[{"count":2,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4236\/revisions"}],"predecessor-version":[{"id":4242,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4236\/revisions\/4242"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4236"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}