-
Notifications
You must be signed in to change notification settings - Fork 0
/
duolingo-result-position-fix.user.js
58 lines (47 loc) · 1.52 KB
/
duolingo-result-position-fix.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
// ==UserScript==
// @name DuolingoResultPositionFix
// @namespace https://github.com/george-vlachos/user-scripts
// @version 1.0
// @description fix the position of the result (bottom) after an exercise in duolingo.com
// @author George Vlachos
// @downloadURL https://github.com/george-vlachos/user-scripts/raw/master/duolingo-result-position-fix.user.js
// @updateURL https://github.com/george-vlachos/user-scripts/raw/master/duolingo-result-position-fix.user.js
// @match *://*.duolingo.com/*
// @grant none
// ==/UserScript==
// duolingo-result-position-fix.user.js
// Used with [Violentmonkey](https://violentmonkey.github.io).
// Script to fix the position of the result after an exercise
// especially in small browser width
const RESULT_CLASS = "._1l6NK";
(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 element = document.querySelectorAll(RESULT_CLASS);
if (element.length > 0) {
if (window.innerWidth >= 700) {
element.forEach(a => {
a.style.setProperty("position", "fixed", "important");
a.style.setProperty("bottom", "0", "important");
a.style.setProperty("left", "10vw", "important");
});
// console.debug(new Date(), "added result fix");
return true;
}
return false;
} else {
return false;
}
}