|
1 | 1 | // ==UserScript== |
2 | 2 | // @name JPDB Userscript (6a67) |
3 | 3 | // @namespace http://tampermonkey.net/ |
4 | | -// @version 0.1.153 |
| 4 | +// @version 0.1.154 |
5 | 5 | // @description Script for JPDB that adds some styling and functionality |
6 | 6 | // @match *://jpdb.io/* |
7 | 7 | // @grant GM_addStyle |
|
994 | 994 | `, |
995 | 995 |
|
996 | 996 | fixCenteredAnswerBox: ` |
997 | | - .answer-box > .plain > :empty { |
998 | | - display: none; |
999 | | - } |
1000 | | -
|
1001 | 997 | .answer-box > .plain > div[style*="padding-left"] { |
1002 | 998 | padding-left: 0px !important; |
| 999 | + flex: 1; |
1003 | 1000 | } |
1004 | 1001 |
|
1005 | | - .answer-box > .plain { |
1006 | | - display: flex; |
1007 | | - align-items: baseline; |
1008 | | - justify-content: space-between !important; |
| 1002 | + .answer-box > .plain > div[style*="width"] { |
| 1003 | + width: 0px !important; |
1009 | 1004 | } |
1010 | 1005 |
|
1011 | | - .inserted-dropdown { |
1012 | | - margin-right: 0px !important; |
| 1006 | + .answer-box > .plain > div[style*="column"] { |
| 1007 | + flex: 0 !important; |
1013 | 1008 | } |
1014 | 1009 | ` |
1015 | 1010 | }; |
|
3276 | 3271 | } |
3277 | 3272 |
|
3278 | 3273 | function initFixCenteredAnswerBox() { |
3279 | | - function centerElements() { |
3280 | | - const answerBox = document.querySelector('.answer-box'); |
3281 | | - if (!answerBox) return; |
3282 | | - if (answerBox.classList.contains('centered-fix')) return; |
3283 | | - const plain = answerBox.querySelector('.plain'); |
3284 | | - if (!plain) return; |
3285 | | - let plain2 = plain.querySelector('.plain'); |
3286 | | - let revealed = true; |
3287 | | - if (!plain2) { |
3288 | | - const divs = plain.querySelectorAll('div'); |
3289 | | - for (const div of divs) { |
3290 | | - if (div.style.cssText === '') { |
3291 | | - plain2 = div; |
3292 | | - revealed = false; |
3293 | | - break; |
3294 | | - } |
3295 | | - } |
3296 | | - } |
3297 | | - if (!plain2) return; |
3298 | | - |
3299 | | - const div = document.createElement('div'); |
3300 | | - div.style = 'display: flex; flex: 1;'; |
3301 | | - if (revealed) { |
3302 | | - plain.insertBefore(div, plain2); |
3303 | | - GM_addStyle(STYLES.fixCenteredAnswerBox); |
3304 | | - } else { |
3305 | | - plain.insertBefore(div, plain2); |
3306 | | - const lastDiv = plain.querySelector('div:last-child'); |
3307 | | - lastDiv.style.paddingLeft = '0'; |
3308 | | - lastDiv.style.flex = '1'; |
3309 | | - |
3310 | | - const divs = plain.querySelectorAll('div'); |
3311 | | - divs.forEach((d) => { |
3312 | | - if (d !== div && !d.textContent.trim() && !d.children.length) { |
3313 | | - d.remove(); |
3314 | | - } |
3315 | | - }); |
3316 | | - } |
3317 | | - |
3318 | | - answerBox.classList.add('centered-fix'); |
3319 | | - } |
3320 | | - |
3321 | | - centerElements(); |
3322 | | - |
3323 | | - let lastProcessedMutation = null; |
3324 | | - |
3325 | | - const observer = new MutationObserver((mutations) => { |
3326 | | - for (const mutation of mutations) { |
3327 | | - if (mutation === lastProcessedMutation) { |
3328 | | - continue; |
3329 | | - } |
3330 | | - lastProcessedMutation = mutation; |
3331 | | - centerElements(); |
3332 | | - } |
3333 | | - }); |
3334 | | - |
3335 | | - observer.observe(document.body.querySelector('.answer-box'), { childList: true, subtree: true }); |
| 3274 | + GM_addStyle(STYLES.fixCenteredAnswerBox); |
3336 | 3275 | } |
3337 | 3276 |
|
3338 | 3277 | async function initReviewProgress() { |
|
3589 | 3528 |
|
3590 | 3529 | if (window.location.href.startsWith(CONFIG.reviewPageUrlPrefix)) { |
3591 | 3530 | initDropdownOnReviewPage(); |
3592 | | - // initFixCenteredAnswerBox(); |
| 3531 | + initFixCenteredAnswerBox(); |
3593 | 3532 | } |
3594 | 3533 |
|
3595 | 3534 | if (window.location.href.startsWith(CONFIG.reviewPageUrlPrefix) && DEBUG.enableProgress) { |
|
0 commit comments