-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-duolingo-exercise-min-width.user.js
61 lines (51 loc) · 1.67 KB
/
add-duolingo-exercise-min-width.user.js
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
// ==UserScript==
// @name AddDuolingoExerciseMaxWidthFix
// @namespace https://github.com/george-vlachos/user-scripts
// @version 1.0
// @description increase the maximum width of the main section in duolingo.com tree exercises
// @author George Vlachos
// @downloadURL https://github.com/george-vlachos/user-scripts/raw/master/add-duolingo-exercise-min-width.user.js
// @updateURL https://github.com/george-vlachos/user-scripts/raw/master/add-duolingo-exercise-min-width.user.js
// @match *://*.duolingo.com/*
// @grant none
// ==/UserScript==
// add-duolingo-exercise-min-width.user.js
// Used with [Violentmonkey](https://violentmonkey.github.io).
// Script to increase the maximum width to come up to the media query
// May help with cases where there are 3 rows of suggested words
// and some content is hidden (overlap)
const MAIN_EXERCISE_CLASS = ".bPbf1";
(function() {
"use strict";
let timeout = null;
const observer = new MutationObserver(() => {
clearTimeout(timeout);
setTimeout(() => {
addFix();
}, 1000);
});
observer.observe(document, {
childList: true,
subtree: true
});
})();
function addFix() {
const mainExerciseElement = document.querySelectorAll(MAIN_EXERCISE_CLASS);
if (mainExerciseElement.length > 0) {
if (window.innerWidth >= 700) {
mainExerciseElement.forEach(a => {
a.style.setProperty(
"transition",
"max-width .3s ease-in-out",
"important"
);
a.style.setProperty("max-width", "700px", "important");
});
// console.debug(new Date(), "added max width fix");
return true;
}
return false;
} else {
return false;
}
}