Try again to fix refresh navigation

This commit is contained in:
Timothy Farrell 2026-03-12 09:34:40 +00:00
parent cf1e9d47c2
commit fd32dcc534

View File

@ -48,12 +48,17 @@
</div>
<script>
function getRefreshParams() {
var metaRefresh = document.querySelector('meta[http-equiv="refresh"]');
if (!metaRefresh) return null;
var content = metaRefresh.getAttribute('content');
var path = window.location.pathname.slice(1);
var parts = path.split('/');
if (parts.length < 3) return null;
var order = parts[0];
if (order !== 'next' && order !== 'random') return null;
var delay = parseInt(parts[1]);
if (isNaN(delay)) return null;
return {
delay: parseInt(content.split(';')[0].trim()),
url: content.split('url=')[1]
delay: delay,
order: order,
hash: parts[2]
};
}
@ -65,18 +70,17 @@
document.getElementById('prev-btn').click();
} else if (e.code === 'ArrowRight') {
document.getElementById('next-btn').click();
} else if (e.code === 'Equal') {
} else if (e.code === 'Equal') {
var params = getRefreshParams();
if (params) window.location.href = params.url;
if (params) window.location.href = `/${params.order}/${params.delay + 1}/${params.hash}`;
} else if (e.code === 'Minus') {
var params = getRefreshParams();
if (params && params.delay > 1) window.location.href = params.url;
if (params && params.delay > 1) window.location.href = `/${params.order}/${params.delay - 1}/${params.hash}`;
} else if (e.key.toLowerCase() === 'o') {
var params = getRefreshParams();
if (params) {
var newOrder = params.url.split('/')[1] === 'next' ? 'random' : 'next';
var newUrl = params.url.replace('/' + (newOrder === 'next' ? 'next' : 'random') + '/', '/' + newOrder + '/');
window.location.href = newUrl;
var newOrder = params.order === 'next' ? 'random' : 'next';
window.location.href = `/${newOrder}/${params.delay}/${params.hash}`;
}
}
});