refactor: overhaul update detection - periodic check, icon only, no banner
This commit is contained in:
4
dist/bookmarklet-payload.js
vendored
4
dist/bookmarklet-payload.js
vendored
File diff suppressed because one or more lines are too long
2
dist/bookmarklet.txt
vendored
2
dist/bookmarklet.txt
vendored
File diff suppressed because one or more lines are too long
2
dist/install.html
vendored
2
dist/install.html
vendored
File diff suppressed because one or more lines are too long
109
dist/kantine-standalone.html
vendored
109
dist/kantine-standalone.html
vendored
@@ -1373,12 +1373,8 @@ body {
|
|||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update Banner Enhanced */
|
|
||||||
.update-banner {
|
|
||||||
/* ... existing styles ... */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Matched Tags in Menu Card */
|
|
||||||
.matched-tags {
|
.matched-tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -1409,25 +1405,7 @@ body {
|
|||||||
border: 1px solid rgba(37, 99, 235, 0.2);
|
border: 1px solid rgba(37, 99, 235, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.change-summary {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
background: rgba(0, 0, 0, 0.1);
|
|
||||||
padding: 0.5rem;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
font-family: inherit;
|
|
||||||
line-height: 1.4;
|
|
||||||
max-height: 100px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Installer Changelog */
|
/* Installer Changelog */
|
||||||
.changelog-container ul {
|
.changelog-container ul {
|
||||||
@@ -3047,72 +3025,34 @@ body {
|
|||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Version Check ===
|
// === Version Check (periodic, every hour) ===
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
const CurrentVersion = 'v1.2.4';
|
const currentVersion = 'v1.2.4';
|
||||||
const VersionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
|
const versionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
|
||||||
const InstallerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
|
const installerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
|
||||||
|
|
||||||
console.log(`[Kantine] Checking for updates... (Current: ${CurrentVersion})`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(VersionUrl, { cache: 'no-cache' });
|
const resp = await fetch(versionUrl, { cache: 'no-cache' });
|
||||||
if (!response.ok) return;
|
if (!resp.ok) return;
|
||||||
|
const remoteVersion = (await resp.text()).trim();
|
||||||
|
if (!remoteVersion || remoteVersion === currentVersion) return;
|
||||||
|
|
||||||
const remoteVersion = (await response.text()).trim();
|
console.log(`[Kantine] Update verfügbar: ${remoteVersion} (aktuell: ${currentVersion})`);
|
||||||
|
|
||||||
if (remoteVersion && remoteVersion !== CurrentVersion) {
|
// Show 🆕 icon in header (only once)
|
||||||
console.log(`[Kantine] New version available: ${remoteVersion}`);
|
const headerTitle = document.querySelector('.header-left h1');
|
||||||
|
if (headerTitle && !headerTitle.querySelector('.update-icon')) {
|
||||||
// Fetch Changelog content
|
const icon = document.createElement('a');
|
||||||
let changeSummary = '';
|
icon.className = 'update-icon';
|
||||||
try {
|
icon.href = installerUrl;
|
||||||
const clResp = await fetch('https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/changelog.md');
|
icon.target = '_blank';
|
||||||
if (clResp.ok) {
|
icon.innerHTML = '🆕';
|
||||||
const clText = await clResp.text();
|
icon.title = `Update verfügbar: ${remoteVersion} — Klick zum Installieren`;
|
||||||
const match = clText.match(/## (v[^\n]+)\n((?:-[^\n]+\n)+)/);
|
icon.style.cssText = 'margin-left:8px;font-size:1em;text-decoration:none;cursor:pointer;vertical-align:middle;';
|
||||||
if (match && match[1].includes(remoteVersion)) {
|
headerTitle.appendChild(icon);
|
||||||
changeSummary = match[2].replace(/- /g, '• ').trim();
|
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
} catch (e) { console.warn('No changelog', e); }
|
console.warn('[Kantine] Version check failed:', e);
|
||||||
|
|
||||||
// Create Banner
|
|
||||||
const updateBanner = document.createElement('div');
|
|
||||||
updateBanner.className = 'update-banner';
|
|
||||||
updateBanner.innerHTML = `
|
|
||||||
<div class="update-content">
|
|
||||||
<strong>Update verfügbar: ${remoteVersion}</strong>
|
|
||||||
${changeSummary ? `<pre class="change-summary">${changeSummary}</pre>` : ''}
|
|
||||||
<a href="${InstallerUrl}" target="_blank" class="update-link">
|
|
||||||
<span class="material-icons-round">system_update_alt</span>
|
|
||||||
Jetzt aktualisieren
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<button class="icon-btn-small close-update">×</button>
|
|
||||||
`;
|
|
||||||
|
|
||||||
document.body.appendChild(updateBanner);
|
|
||||||
updateBanner.querySelector('.close-update').addEventListener('click', () => updateBanner.remove());
|
|
||||||
|
|
||||||
// Highlight Header Icon -> Make Clickable
|
|
||||||
const lastUpdatedIcon = document.querySelector('.material-icons-round.logo-icon');
|
|
||||||
if (lastUpdatedIcon) {
|
|
||||||
const updateLink = document.createElement('a');
|
|
||||||
updateLink.href = InstallerUrl;
|
|
||||||
updateLink.target = '_blank';
|
|
||||||
updateLink.className = 'material-icons-round logo-icon update-pulse';
|
|
||||||
updateLink.style.color = 'var(--accent-color)';
|
|
||||||
updateLink.style.textDecoration = 'none';
|
|
||||||
updateLink.style.cursor = 'pointer';
|
|
||||||
updateLink.title = `Update verfügbar: ${remoteVersion}`;
|
|
||||||
updateLink.textContent = 'system_update'; // Change icon to update icon
|
|
||||||
|
|
||||||
lastUpdatedIcon.replaceWith(updateLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('[Kantine] Version check failed:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3254,8 +3194,9 @@ body {
|
|||||||
startPolling();
|
startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates (now + every hour)
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
setInterval(checkForUpdates, 60 * 60 * 1000);
|
||||||
|
|
||||||
console.log('Kantine Wrapper loaded ✅');
|
console.log('Kantine Wrapper loaded ✅');
|
||||||
})();
|
})();
|
||||||
|
|||||||
85
kantine.js
85
kantine.js
@@ -1411,72 +1411,34 @@
|
|||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Version Check ===
|
// === Version Check (periodic, every hour) ===
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
const CurrentVersion = '{{VERSION}}';
|
const currentVersion = '{{VERSION}}';
|
||||||
const VersionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
|
const versionUrl = 'https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/version.txt';
|
||||||
const InstallerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
|
const installerUrl = 'https://htmlpreview.github.io/?https://github.com/TauNeutrino/kantine-overview/blob/main/dist/install.html';
|
||||||
|
|
||||||
console.log(`[Kantine] Checking for updates... (Current: ${CurrentVersion})`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(VersionUrl, { cache: 'no-cache' });
|
const resp = await fetch(versionUrl, { cache: 'no-cache' });
|
||||||
if (!response.ok) return;
|
if (!resp.ok) return;
|
||||||
|
const remoteVersion = (await resp.text()).trim();
|
||||||
|
if (!remoteVersion || remoteVersion === currentVersion) return;
|
||||||
|
|
||||||
const remoteVersion = (await response.text()).trim();
|
console.log(`[Kantine] Update verfügbar: ${remoteVersion} (aktuell: ${currentVersion})`);
|
||||||
|
|
||||||
if (remoteVersion && remoteVersion !== CurrentVersion) {
|
// Show 🆕 icon in header (only once)
|
||||||
console.log(`[Kantine] New version available: ${remoteVersion}`);
|
const headerTitle = document.querySelector('.header-left h1');
|
||||||
|
if (headerTitle && !headerTitle.querySelector('.update-icon')) {
|
||||||
// Fetch Changelog content
|
const icon = document.createElement('a');
|
||||||
let changeSummary = '';
|
icon.className = 'update-icon';
|
||||||
try {
|
icon.href = installerUrl;
|
||||||
const clResp = await fetch('https://raw.githubusercontent.com/TauNeutrino/kantine-overview/main/changelog.md');
|
icon.target = '_blank';
|
||||||
if (clResp.ok) {
|
icon.innerHTML = '🆕';
|
||||||
const clText = await clResp.text();
|
icon.title = `Update verfügbar: ${remoteVersion} — Klick zum Installieren`;
|
||||||
const match = clText.match(/## (v[^\n]+)\n((?:-[^\n]+\n)+)/);
|
icon.style.cssText = 'margin-left:8px;font-size:1em;text-decoration:none;cursor:pointer;vertical-align:middle;';
|
||||||
if (match && match[1].includes(remoteVersion)) {
|
headerTitle.appendChild(icon);
|
||||||
changeSummary = match[2].replace(/- /g, '• ').trim();
|
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
} catch (e) { console.warn('No changelog', e); }
|
console.warn('[Kantine] Version check failed:', e);
|
||||||
|
|
||||||
// Create Banner
|
|
||||||
const updateBanner = document.createElement('div');
|
|
||||||
updateBanner.className = 'update-banner';
|
|
||||||
updateBanner.innerHTML = `
|
|
||||||
<div class="update-content">
|
|
||||||
<strong>Update verfügbar: ${remoteVersion}</strong>
|
|
||||||
${changeSummary ? `<pre class="change-summary">${changeSummary}</pre>` : ''}
|
|
||||||
<a href="${InstallerUrl}" target="_blank" class="update-link">
|
|
||||||
<span class="material-icons-round">system_update_alt</span>
|
|
||||||
Jetzt aktualisieren
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<button class="icon-btn-small close-update">×</button>
|
|
||||||
`;
|
|
||||||
|
|
||||||
document.body.appendChild(updateBanner);
|
|
||||||
updateBanner.querySelector('.close-update').addEventListener('click', () => updateBanner.remove());
|
|
||||||
|
|
||||||
// Highlight Header Icon -> Make Clickable
|
|
||||||
const lastUpdatedIcon = document.querySelector('.material-icons-round.logo-icon');
|
|
||||||
if (lastUpdatedIcon) {
|
|
||||||
const updateLink = document.createElement('a');
|
|
||||||
updateLink.href = InstallerUrl;
|
|
||||||
updateLink.target = '_blank';
|
|
||||||
updateLink.className = 'material-icons-round logo-icon update-pulse';
|
|
||||||
updateLink.style.color = 'var(--accent-color)';
|
|
||||||
updateLink.style.textDecoration = 'none';
|
|
||||||
updateLink.style.cursor = 'pointer';
|
|
||||||
updateLink.title = `Update verfügbar: ${remoteVersion}`;
|
|
||||||
updateLink.textContent = 'system_update'; // Change icon to update icon
|
|
||||||
|
|
||||||
lastUpdatedIcon.replaceWith(updateLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('[Kantine] Version check failed:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1618,8 +1580,9 @@
|
|||||||
startPolling();
|
startPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates (now + every hour)
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
setInterval(checkForUpdates, 60 * 60 * 1000);
|
||||||
|
|
||||||
console.log('Kantine Wrapper loaded ✅');
|
console.log('Kantine Wrapper loaded ✅');
|
||||||
})();
|
})();
|
||||||
|
|||||||
24
style.css
24
style.css
@@ -1362,12 +1362,8 @@ body {
|
|||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update Banner Enhanced */
|
|
||||||
.update-banner {
|
|
||||||
/* ... existing styles ... */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Matched Tags in Menu Card */
|
|
||||||
.matched-tags {
|
.matched-tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -1398,25 +1394,7 @@ body {
|
|||||||
border: 1px solid rgba(37, 99, 235, 0.2);
|
border: 1px solid rgba(37, 99, 235, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.change-summary {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
background: rgba(0, 0, 0, 0.1);
|
|
||||||
padding: 0.5rem;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
font-family: inherit;
|
|
||||||
line-height: 1.4;
|
|
||||||
max-height: 100px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Installer Changelog */
|
/* Installer Changelog */
|
||||||
.changelog-container ul {
|
.changelog-container ul {
|
||||||
|
|||||||
@@ -91,13 +91,14 @@ try {
|
|||||||
// Execute the code
|
// Execute the code
|
||||||
vm.runInContext(code, sandbox);
|
vm.runInContext(code, sandbox);
|
||||||
|
|
||||||
// Regex Check for the FIX
|
|
||||||
const fixRegex = /lastUpdatedIcon\.replaceWith/;
|
// Regex Check: update icon appended to header
|
||||||
|
const fixRegex = /headerTitle\.appendChild\(icon\)/;
|
||||||
if (!fixRegex.test(code)) {
|
if (!fixRegex.test(code)) {
|
||||||
console.error("❌ Logic Test Failed: 'replaceWith' anchor missing in checkForUpdates.");
|
console.error("❌ Logic Test Failed: 'appendChild(icon)' missing in checkForUpdates.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
console.log("✅ Static Analysis Passed: 'replaceWith' found.");
|
console.log("✅ Static Analysis Passed: 'appendChild(icon)' found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check dynamic logic usage
|
// Check dynamic logic usage
|
||||||
|
|||||||
Reference in New Issue
Block a user