-
Notifications
You must be signed in to change notification settings - Fork 0
/
flitto.js
60 lines (47 loc) · 1.86 KB
/
flitto.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
LAME_OLD_LOCATION = '';
TERMS_CONDITIONS_URLS = [
'https://www.flitto.com/arcade-service/problems/32',
'https://www.flitto.com/arcade-service/problems/193'
];
function lameify() {
setInterval(checkLocation, 100);
}
function checkLocation() {
const myLocation = window.location.href;
// Exit if not first time or not in New Arcade
if (myLocation == LAME_OLD_LOCATION || !myLocation.includes('arcade-service')) return;
//
if (TERMS_CONDITIONS_URLS.includes(myLocation)) {
bypassTermsAndConditions();
return;
}
// It's a "problem/question" page like https://www.flitto.com/arcade-service/problems/63c539909f134b08daa48d93/63c539909f134b08daa48d87
if (/problems\/\w+\/\w+$/.test(myLocation)) {
LAME_OLD_LOCATION = myLocation;
setTimeout(tweakProblemPage, 500);
}
}
function bypassTermsAndConditions() {
document.querySelector('i.checkbox__icon')?.click();
document.querySelector('.text-button.primary-light-fill.start-btn')?.click();
}
function tweakProblemPage() {
// In case it's a re-review. Remove irrelevant, already accepted translation.
document.querySelector('.translation__re-accepted-text')?.closest('.translation')?.remove();
// Auto-send after Accept button is clicked
let acceptButtons = [...document.querySelectorAll('.accept-button')];
acceptButtons?.forEach(btn => btn.addEventListener('click', clickSend));
// Make target div contenteditable, so the spellcheck is available
let targetAreas = [...document.querySelectorAll('p.translation__content')];
targetAreas.forEach(area => area.setAttribute('contenteditable','true'));
// Focus on areas so spellcheck actually kicks in
targetAreas.forEach(async (area, i) => {
await new Promise(r => setTimeout(r, (i + 1) * 500));
area.focus()
})
}
function clickSend() {
setTimeout(()=>{
document.querySelector('button.primary-light-fill')?.click()
}, 50);
}