// ==UserScript== // @name LingQ // @namespace http://tampermonkey.net/ // @version 0.1.4 // @description same site better UX // @author ibn_rushd // @match https://www.lingq.com/* // @grant GM_addStyle // @downloadURL none // ==/UserScript== GM_addStyle(` .lessons-wrap .current-lesson { background: #f6f6f6; padding: 30px 10px !important; box-shadow: 0 5px 5px 0 #c3bfbf; margin: 0 0px 5px 0px; } .today-counter span { color: white; position: relative; height: 55px; line-height: 55px; z-index: 1; } `); GM_addStyle(` .lessons-wrap { padding: 0px !important; }`); GM_addStyle(` .lessons-wrap .lesson-item { padding: 10px !important; }`); let data = []; var url = "https://www.lingq.com/api/v2/ru/milestones/"; fetch(url) .then(response => response.json()) .then(result => data.push(result)); addEventListener('load', function () { var lingq_daily = data[0].stats.lingqs_daily; console.log("this is your amount of lingq's" + lingq_daily); //make sure the last course you did before completing is the first one in the course. if (window.location.href.indexOf("chunk") != -1) { var lessons = document.querySelector('.lessons-wrap .lesson-list'); if (lessons) { var lessons_items = document.querySelector('.lessons-wrap .lesson-list .lesson-item'); var total_completed = document.querySelectorAll('.completed').length; var current_lesson = lessons.childNodes[total_completed]; lessons.insertBefore(current_lesson, lessons.firstChild); //change css lessons.firstChild.classList.add("current-lesson"); } } //hover translate translates if (window.location.href.indexOf("chunk") != -1) { var sentence_btn = document.querySelector(".sentence-size"); if(sentence_btn.classList.contains("active")) { console.log("sentence mode"); var translate_btn = document.querySelector(".lesson .loadedContent .btn"); translate_btn.addEventListener("mouseover", function () { translate_btn.click(); }); } } //add total lingq in top bar var topbar = document.querySelector('.counters.nav'); var today_counter = document.createElement("li"); today_counter.setAttribute('class','today-counter counter-item'); var span = document.createElement("span"); span.innerText = lingq_daily + " Lingq's"; today_counter.appendChild(span); topbar.appendChild(today_counter); });