-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserScript.js
More file actions
95 lines (81 loc) · 4.41 KB
/
UserScript.js
File metadata and controls
95 lines (81 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// ==UserScript==
// @name LingoDeer Extras
// @namespace https://www.lingodeer.com
// @version 0.1.14
// @description Extras for LingoDeer web app
// @author Ilya Ilyushenok
// @match https://www.lingodeer.com/learn-language*
// @match https://lingodeer.com/learn-language*
// @grant none
// @updateURL https://raw.githubusercontent.com/ilyushenok/LingoDeerExtras/master/UserScript.js
// @downloadURL https://raw.githubusercontent.com/ilyushenok/LingoDeerExtras/master/UserScript.js
// ==/UserScript==
window.addEventListener('load', function() {
'use strict';
var checkInterval = 250;
var extrasEnabledAtt = 'extrasenabled';
var isCorrect = function() {
var switchBottom = document.getElementsByClassName('switchBottom')[0];
return switchBottom && switchBottom.classList.contains('right');
};
var playAudio = function() {
var playBtn =
document.getElementsByClassName('labaWrapContainer')[0] ||
document.getElementsByClassName('titleLabaWrapContainer')[0];
if (isCorrect()) {
playBtn = document.getElementsByClassName('checkLabaWrapContainer')[0];
}
if (playBtn) {
playBtn.click();
}
};
setInterval(function() {
var app = document.getElementById('app');
if (app && !app.hasAttribute(extrasEnabledAtt)) {
app.setAttribute(extrasEnabledAtt, '');
var style = document.createElement('style');
style.innerHTML = plainStyles;
document.head.appendChild(style);
window.addEventListener('keydown', function(e) {
if (e.code === 'Space') {
playAudio();
}
if (!isCorrect() && 48 <= e.keyCode && e.keyCode <= 57) {
var index = (e.shiftKey ? 10 : 0) + (e.keyCode === 48 ? 9 : (e.keyCode - 49));
var optionsArea =
document.getElementsByClassName('optionsArea')[0] ||
document.querySelector('.sentenceTitle + .sentenceStem');
if (optionsArea) {
var options =
optionsArea.getElementsByClassName('option');
if (!options.length) {
options = optionsArea.getElementsByClassName('wrapOption');
}
if (index < options.length) {
var opt = options[index];
var option =
[...opt.classList].includes('wrapOption')
? opt
: opt.getElementsByClassName('item')[0];
if (option) {
option.click();
}
}
}
}
});
}
var el = document.querySelector('.isCheckedPanel');
if (el && !el.hasAttribute('played')) {
setTimeout(function() {
document.querySelector('.checkLabaWrapContainer.right').click();
}, 500);
el.setAttribute('played', '');
}
var el2 = document.querySelector('.checkPanel');
if (el2 && el2.hasAttribute('played')) {
el2.removeAttribute('played');
}
}, checkInterval);
});
var plainStyles = '.optionsArea,.sentenceTitle+.sentenceStem{counter-reset:option-n}.optionsArea .option{border-radius:9px!important}.optionsArea .option .item,.optionsArea .option .item .wrapOption,.sentenceTitle+.sentenceStem .wrapOption{position:relative}.optionsArea .option .item .wrapOption .circle,.sentenceTitle+.sentenceStem .wrapOption .closeWrap{opacity:0!important}.optionsArea .option .item{border-radius:8px!important}.optionsArea .option .item::before,.sentenceTitle+.sentenceStem .wrapOption::before{position:absolute;top:8px;left:8px;display:flex;align-items:center;justify-content:center;counter-increment:option-n;content:counter(option-n);width:30px;height:30px;font-size:22px;border-radius:100%;background-color:#fff;border:1px solid #979797;color:#000}.optionsArea .option.active .item::before{background-color:#1caff6;border-color:#1caff6;color:#fff}.wordModel5 .optionsArea{padding-top:10px!important}.sentenceModel10 .optionsArea .option .item::before,.sentenceModel13 .optionsArea .option .item::before,.sentenceModel2 .sentenceTitle+.sentenceStem .wrapOption::before,.sentenceModel5 .optionsArea .option .item::before,.wordModel10 .optionsArea .option .item::before,.wordModel5 .optionsArea .option .item::before,.wordModel9 .optionsArea .option .item::before{top:-10px;left:-10px;width:20px;height:20px;font-size:12px}.sentenceModel2 .sentenceTitle+.sentenceStem .wrapOption::before{z-index:1}.sentenceModel13 .optionsAreaWrap .center,.sentenceModel13 .optionsAreaWrap .left,.sentenceModel13 .optionsAreaWrap .right{padding-top:10px}.modelContainerSent.sentenceModel13 .optionsArea .optionsAreaWrap .center .oneRow.active{display:block!important;margin:0!important;padding:0!important;overflow:hidden!important;height:0!important}';