|
1 | 1 | // ==UserScript== |
2 | 2 | // @name JavStore Full Layout Cleanup - No Sidebars + Mosaic Overlay |
3 | 3 | // @namespace http://tampermonkey.net/ |
4 | | -// @version 6.8.1 |
| 4 | +// @version 6.9.0 |
5 | 5 | // @description Clean up JavStore's layout, filter keyword-matched thumbnails, and track visited items with private, configurable controls. |
6 | 6 | // @homepageURL https://github.com/jitdor/userscript-javstore |
7 | 7 | // @supportURL https://github.com/jitdor/userscript-javstore/issues |
|
29 | 29 | (function () { |
30 | 30 | 'use strict'; |
31 | 31 |
|
32 | | - const SCRIPT_VERSION = '6.8.1'; |
| 32 | + const SCRIPT_VERSION = '6.9.0'; |
33 | 33 | // The same address as @downloadURL: opening it hands the newest release to the |
34 | 34 | // userscript manager, which offers to install it. |
35 | 35 | const INSTALL_URL = 'https://github.com/jitdor/userscript-javstore/releases/latest/download/javstore-full-layout-cleanup.user.js'; |
|
1617 | 1617 | return 0; |
1618 | 1618 | } |
1619 | 1619 |
|
| 1620 | + // A worker that only says it is "older than" some version is behind by definition. |
| 1621 | + function workerBehindScript() { |
| 1622 | + if (!syncConfigured() || !remoteWorkerVersion) return false; |
| 1623 | + return !/^\d+(\.\d+)*$/.test(remoteWorkerVersion) |
| 1624 | + || compareVersions(remoteWorkerVersion, SCRIPT_VERSION) < 0; |
| 1625 | + } |
| 1626 | + |
1620 | 1627 | function describeWorkerVersion() { |
1621 | 1628 | if (!syncConfigured()) return ''; |
1622 | 1629 | if (!remoteWorkerVersion) return 'Worker version: not known until the first sync on this page.'; |
1623 | | - const known = /^\d+(\.\d+)*$/.test(remoteWorkerVersion); |
1624 | | - const behind = !known || compareVersions(remoteWorkerVersion, SCRIPT_VERSION) < 0; |
1625 | | - return behind |
1626 | | - ? `Worker version: ${remoteWorkerVersion}, behind this script (${SCRIPT_VERSION}). Redeploy the worker.` |
1627 | | - : `Worker version: ${remoteWorkerVersion}.`; |
| 1630 | + return `Worker version: ${remoteWorkerVersion}.`; |
| 1631 | + } |
| 1632 | + |
| 1633 | + function describeWorkerBehind() { |
| 1634 | + return `Your sync worker is ${remoteWorkerVersion}, behind this script (${SCRIPT_VERSION}). The worker redeploys from main through Cloudflare, so check its latest build in the Cloudflare dashboard.`; |
1628 | 1635 | } |
1629 | 1636 |
|
1630 | 1637 | // The worker deploys from the same commit the release is cut from, so a worker ahead of |
|
2126 | 2133 | const workerVersion = describeWorkerVersion(); |
2127 | 2134 | ui.workerVersion.textContent = workerVersion; |
2128 | 2135 | ui.workerVersion.hidden = !workerVersion; |
| 2136 | + const workerBehind = workerBehindScript(); |
| 2137 | + ui.redeployButton.hidden = !workerBehind; |
| 2138 | + if (workerBehind) ui.redeployButton.title = describeWorkerBehind(); |
2129 | 2139 | const behind = scriptBehindWorker(); |
2130 | 2140 | ui.updateButton.hidden = !behind; |
2131 | 2141 | ui.updateWarning.hidden = !behind; |
|
2143 | 2153 | ui.toast.classList.toggle('error', isError); |
2144 | 2154 | ui.toast.classList.add('show'); |
2145 | 2155 | window.clearTimeout(ui.toastTimer); |
2146 | | - ui.toastTimer = window.setTimeout(() => ui?.toast.classList.remove('show'), 2800); |
| 2156 | + ui.toastTimer = window.setTimeout(() => ui?.toast.classList.remove('show'), Math.max(2800, message.length * 60)); |
2147 | 2157 | } |
2148 | 2158 |
|
2149 | 2159 | function splitTerms(value) { |
|
2394 | 2404 | .muted { color: #9ca3af; font-size: 12px; } |
2395 | 2405 | .warning { padding: 8px; border-radius: 8px; color: #fecaca; background: #7f1d1d; } |
2396 | 2406 | .warning a { color: #fff; } |
2397 | | - .pill.update { border-color: #fca5a5; background: #991b1b; } |
2398 | | - .pill.update:hover { background: #7f1d1d; } |
| 2407 | + .pill.update, .pill.redeploy { border-color: #fca5a5; background: #991b1b; } |
| 2408 | + .pill.update:hover, .pill.redeploy:hover { background: #7f1d1d; } |
2399 | 2409 | .pill[hidden], .warning[hidden] { display: none; } |
2400 | 2410 | .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } |
2401 | 2411 | .full { grid-column: 1 / -1; } |
|
2435 | 2445 | </style> |
2436 | 2446 | <div class="dock" aria-label="JavStore cleanup controls"> |
2437 | 2447 | <button class="pill update" type="button" hidden>⚠ Update script</button> |
| 2448 | + <button class="pill redeploy" type="button" hidden>⚠ Redeploy worker</button> |
2438 | 2449 | <button class="pill lift" type="button">Reveal all</button> |
2439 | 2450 | <button class="pill summary" type="button" aria-expanded="false">JavStore controls</button> |
2440 | 2451 | </div> |
|
2523 | 2534 | workerVersion: shadow.querySelector('.worker-version'), |
2524 | 2535 | storageWarning: shadow.querySelector('.storage-warning'), |
2525 | 2536 | updateButton: shadow.querySelector('.update'), |
| 2537 | + redeployButton: shadow.querySelector('.redeploy'), |
2526 | 2538 | updateWarning: shadow.querySelector('.update-warning'), |
2527 | 2539 | updateVersions: shadow.querySelector('.update-versions'), |
2528 | 2540 | selectedTitle: shadow.querySelector('.selected-title'), |
|
2546 | 2558 | shadow.querySelector('.close').addEventListener('click', () => setPanelOpen(false)); |
2547 | 2559 | liftButton.addEventListener('click', toggleOverlays); |
2548 | 2560 | shadow.querySelector('.update').addEventListener('click', () => setPanelOpen(true)); |
| 2561 | + shadow.querySelector('.redeploy').addEventListener('click', () => showToast(describeWorkerBehind(), true)); |
2549 | 2562 | form.addEventListener('submit', event => { |
2550 | 2563 | event.preventDefault(); |
2551 | 2564 | applySettings(readSettingsForm()); |
|
0 commit comments