gdfgd
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
const tagsContainer = document.querySelector("#tags");
|
||||
if (!tagsContainer) return;
|
||||
const inner = tagsContainer.querySelector(".tags-inner") || tagsContainer;
|
||||
const activePostId = tagsContainer.dataset.itemId || (typeof window.getCurrentItemId === 'function' ? window.getCurrentItemId() : null);
|
||||
|
||||
const canManage = !!(
|
||||
document.querySelector('#tags[data-can-manage="true"]') ||
|
||||
@@ -96,6 +97,7 @@
|
||||
if (isRating) {
|
||||
span.classList.add('rating-tag', `is-${tag.normalized}`);
|
||||
span.dataset.rating = tag.normalized;
|
||||
if (activePostId) span.dataset.itemId = activePostId;
|
||||
if (canManage) {
|
||||
span.classList.add('can-cycle');
|
||||
}
|
||||
@@ -124,6 +126,7 @@
|
||||
const untaggedSpan = document.createElement("span");
|
||||
untaggedSpan.className = `badge badge-untagged rating-tag is-untagged${canManage ? ' can-cycle' : ''}`;
|
||||
untaggedSpan.dataset.rating = 'untagged';
|
||||
if (activePostId) untaggedSpan.dataset.itemId = activePostId;
|
||||
const lbl = document.createElement("span");
|
||||
lbl.className = "rating-label";
|
||||
lbl.textContent = "untagged";
|
||||
@@ -139,6 +142,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Update thumbnail data-mode in background grid (ensures div.posts > a > p::before updates in Onara)
|
||||
if (activePostId) {
|
||||
const modeAttr = lastRatingTag ? lastRatingTag.normalized : 'null';
|
||||
document.querySelectorAll(`.posts > a.thumb[data-item-id="${activePostId}"], .posts a[data-item-id="${activePostId}"], .posts a[href$="/${activePostId}"]`).forEach(th => {
|
||||
th.setAttribute('data-mode', modeAttr);
|
||||
});
|
||||
if (document.body.classList.contains('onara-modal-open')) {
|
||||
const onaraThumb = document.querySelector('.posts > a.thumb.onara-active');
|
||||
if (onaraThumb) onaraThumb.setAttribute('data-mode', modeAttr);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle show more/less toggle visibility and count
|
||||
const allBadges = [...inner.querySelectorAll(".badge")];
|
||||
const realTags = allBadges.filter(b => !b.querySelector('#a_addtag') && !b.querySelector('#a_toggle') && !b.classList.contains('tag-ac-wrapper'));
|
||||
|
||||
+21
-4
@@ -645,11 +645,16 @@
|
||||
|
||||
if (data.success) {
|
||||
this.isSessionReady = true;
|
||||
if (data.csrf_token) {
|
||||
if (window.f0ckSession) window.f0ckSession.csrf_token = data.csrf_token;
|
||||
const metaCsrf = document.querySelector('meta[name="csrf-token"]');
|
||||
if (metaCsrf) metaCsrf.content = data.csrf_token;
|
||||
if (window.f0ckSession) {
|
||||
window.f0ckSession.user = 'anonymous';
|
||||
window.f0ckSession.is_anon = true;
|
||||
window.f0ckSession.logged_in = true;
|
||||
window.f0ckSession.id = data.user_id;
|
||||
window.f0ckSession.user_id = data.user_id;
|
||||
if (data.csrf_token) window.f0ckSession.csrf_token = data.csrf_token;
|
||||
}
|
||||
const metaCsrf = document.querySelector('meta[name="csrf-token"]');
|
||||
if (metaCsrf && data.csrf_token) metaCsrf.content = data.csrf_token;
|
||||
window.f0ckAnonIdentity = {
|
||||
userId: data.user_id,
|
||||
fingerprint: data.fingerprint,
|
||||
@@ -657,6 +662,9 @@
|
||||
hwFingerprint: data.hw_fingerprint || hwFingerprint
|
||||
};
|
||||
window.dispatchEvent(new CustomEvent('f0ck:anon_session_ready', { detail: window.f0ckAnonIdentity }));
|
||||
if (typeof window.syncRatingButtonUI === 'function') {
|
||||
window.syncRatingButtonUI();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('[ANON_SSH] Session handshake failed:', err);
|
||||
@@ -870,6 +878,15 @@
|
||||
const guestFavsLink = document.getElementById('nav-guest-favs-link');
|
||||
if (guestFavsNav) guestFavsNav.style.display = isAnon ? '' : 'none';
|
||||
if (guestFavsLink) guestFavsLink.style.display = isAnon ? '' : 'none';
|
||||
|
||||
if (isAnon && window.f0ckSession) {
|
||||
window.f0ckSession.user = window.f0ckSession.user || 'anonymous';
|
||||
window.f0ckSession.is_anon = true;
|
||||
window.f0ckSession.logged_in = true;
|
||||
}
|
||||
if (typeof window.syncRatingButtonUI === 'function') {
|
||||
window.syncRatingButtonUI();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1084
-48
File diff suppressed because it is too large
Load Diff
+50
-1
@@ -97,11 +97,34 @@
|
||||
let autoNextLoops = Math.max(0, parseInt(prefs.autoNextLoops ?? 1, 10));
|
||||
let leftHandEnabled = prefs.leftHand === true;
|
||||
|
||||
const getIsScrollerGuest = () => {
|
||||
if (!window.f0ckSession) return true;
|
||||
if (window.f0ckSession.user && !window.f0ckSession.is_anon) return false;
|
||||
if (window.f0ckSession.is_anon && (window.f0ckSession.logged_in || window.f0ckSession.user)) return false;
|
||||
if (window.f0ckAnonSSH && (window.f0ckAnonSSH.isSessionReady || window.f0ckAnonSSH.pubkey)) return false;
|
||||
if (typeof localStorage !== 'undefined' && localStorage.getItem('f0ck_anon_ssh_pub')) return false;
|
||||
return !window.f0ckSession.logged_in;
|
||||
};
|
||||
const isScrollerGuest = getIsScrollerGuest();
|
||||
const isScrollerAnon = !(window.f0ckSession && window.f0ckSession.user && !window.f0ckSession.is_anon);
|
||||
const scrollerAllowedMimes = window.f0ckSession?.anon_permissions?.allowed_mimes;
|
||||
const scrollerSingleMime = (isScrollerAnon && Array.isArray(scrollerAllowedMimes) && scrollerAllowedMimes.length === 1) ? scrollerAllowedMimes[0] : null;
|
||||
|
||||
let applied = { mode: defaultMode, mime: scrollerSingleMime || '', order: 'random', tags: [], externalUrl: null };
|
||||
const scrollerAllowedModes = isScrollerGuest ? ['sfw'] : window.f0ckSession?.anon_permissions?.allowed_modes;
|
||||
const scrollerModeNames = ['sfw', 'nsfw', 'untagged', 'all', 'nsfl'];
|
||||
let effectiveScrollerMode = defaultMode;
|
||||
if (isScrollerGuest) {
|
||||
effectiveScrollerMode = 0;
|
||||
} else if (isScrollerAnon && Array.isArray(scrollerAllowedModes)) {
|
||||
const curName = scrollerModeNames[effectiveScrollerMode] || 'sfw';
|
||||
if (!scrollerAllowedModes.includes(curName)) {
|
||||
const fallbackName = scrollerAllowedModes[0] || 'sfw';
|
||||
const fallbackIdx = scrollerModeNames.indexOf(fallbackName);
|
||||
effectiveScrollerMode = fallbackIdx >= 0 ? fallbackIdx : 0;
|
||||
}
|
||||
}
|
||||
|
||||
let applied = { mode: effectiveScrollerMode, mime: scrollerSingleMime || '', order: 'random', tags: [], externalUrl: null };
|
||||
let pending = { ...applied, tags: [] };
|
||||
|
||||
// Volume / mute
|
||||
@@ -3039,6 +3062,19 @@
|
||||
});
|
||||
|
||||
function syncPanelUI() {
|
||||
const isGuest = getIsScrollerGuest();
|
||||
if (isGuest) {
|
||||
pending.mode = 0;
|
||||
applied.mode = 0;
|
||||
} else {
|
||||
document.querySelectorAll('#mode-pills .filter-pill').forEach(pill => {
|
||||
pill.classList.remove('locked');
|
||||
pill.disabled = false;
|
||||
pill.style.cursor = '';
|
||||
pill.style.opacity = '';
|
||||
pill.querySelectorAll('.fa-lock').forEach(i => i.remove());
|
||||
});
|
||||
}
|
||||
if (scrollerSingleMime) {
|
||||
pending.mime = scrollerSingleMime;
|
||||
applied.mime = scrollerSingleMime;
|
||||
@@ -3055,6 +3091,10 @@
|
||||
if (!el) return;
|
||||
el.querySelectorAll('.filter-pill').forEach(pill => {
|
||||
pill.addEventListener('click', (e) => {
|
||||
if (groupId === 'mode-pills' && (getIsScrollerGuest() || pill.classList.contains('locked') || pill.disabled)) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (groupId === 'mime-pills' && scrollerSingleMime) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
@@ -3064,6 +3104,15 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('f0ck:anon_session_ready', () => {
|
||||
if (window.f0ckSession) {
|
||||
window.f0ckSession.user = 'anonymous';
|
||||
window.f0ckSession.is_anon = true;
|
||||
window.f0ckSession.logged_in = true;
|
||||
}
|
||||
syncPanelUI();
|
||||
});
|
||||
makePillListener('mode-pills', 'mode', v => +v);
|
||||
makePillListener('mime-pills', 'mime', v => v);
|
||||
makePillListener('order-pills', 'order', v => v);
|
||||
|
||||
@@ -1515,12 +1515,17 @@
|
||||
const getCurrentItemIdentifiers = () => {
|
||||
const ids = new Set();
|
||||
|
||||
// 1. From DOM elements on the page (primary/direct)
|
||||
const idElem = document.querySelector('[data-item-id]');
|
||||
if (idElem && idElem.dataset.itemId) {
|
||||
ids.add(String(idElem.dataset.itemId).trim());
|
||||
// 1. From active item on the page (never match background grid thumbnails)
|
||||
if (typeof window.getCurrentItemId === 'function') {
|
||||
const currentId = window.getCurrentItemId();
|
||||
if (currentId) ids.add(String(currentId).trim());
|
||||
} else {
|
||||
const idElem = document.querySelector('#onara-item-mount [data-item-id], .item-layout-container[data-item-id], #comments-container[data-item-id]');
|
||||
if (idElem?.dataset?.itemId) {
|
||||
ids.add(String(idElem.dataset.itemId).trim());
|
||||
}
|
||||
}
|
||||
const idLink = document.querySelector('.id-link');
|
||||
const idLink = document.querySelector('#onara-item-mount .id-link, .item-layout-container .id-link, #main.item-view .id-link');
|
||||
if (idLink) {
|
||||
if (idLink.dataset.itemId) ids.add(String(idLink.dataset.itemId).trim());
|
||||
const txt = idLink.textContent.trim();
|
||||
|
||||
+16
-1
@@ -46,6 +46,7 @@
|
||||
const tagsContainer = document.querySelector("#tags");
|
||||
if (!tagsContainer) return;
|
||||
const inner = tagsContainer.querySelector(".tags-inner") || tagsContainer;
|
||||
const activePostId = tagsContainer.dataset.itemId || (typeof window.getCurrentItemId === 'function' ? window.getCurrentItemId() : null);
|
||||
|
||||
const canManage = !!(
|
||||
document.querySelector('#tags[data-can-manage="true"]') ||
|
||||
@@ -76,7 +77,7 @@
|
||||
contentEl.textContent = tag.tag;
|
||||
} else {
|
||||
contentEl = document.createElement("a");
|
||||
contentEl.href = `/tag/${tag.normalized}`;
|
||||
contentEl.href = "/tag/" + tag.normalized;
|
||||
contentEl.style = "color: inherit !important";
|
||||
contentEl.textContent = tag.tag;
|
||||
}
|
||||
@@ -92,6 +93,7 @@
|
||||
if (isRating) {
|
||||
span.classList.add('rating-tag', `is-${tag.normalized}`);
|
||||
span.dataset.rating = tag.normalized;
|
||||
if (activePostId) span.dataset.itemId = activePostId;
|
||||
if (canManage) {
|
||||
span.classList.add('can-cycle');
|
||||
}
|
||||
@@ -120,6 +122,7 @@
|
||||
const untaggedSpan = document.createElement("span");
|
||||
untaggedSpan.className = `badge badge-untagged rating-tag is-untagged${canManage ? ' can-cycle' : ''}`;
|
||||
untaggedSpan.dataset.rating = 'untagged';
|
||||
if (activePostId) untaggedSpan.dataset.itemId = activePostId;
|
||||
const lbl = document.createElement("span");
|
||||
lbl.className = "rating-label";
|
||||
lbl.textContent = "untagged";
|
||||
@@ -135,6 +138,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Update thumbnail data-mode in background grid (ensures div.posts > a > p::before updates in Onara)
|
||||
if (activePostId) {
|
||||
const modeAttr = lastRatingTag ? lastRatingTag.normalized : 'null';
|
||||
document.querySelectorAll(`.posts > a.thumb[data-item-id="${activePostId}"], .posts a[data-item-id="${activePostId}"], .posts a[href$="/${activePostId}"]`).forEach(th => {
|
||||
th.setAttribute('data-mode', modeAttr);
|
||||
});
|
||||
if (document.body.classList.contains('onara-modal-open')) {
|
||||
const onaraThumb = document.querySelector('.posts > a.thumb.onara-active');
|
||||
if (onaraThumb) onaraThumb.setAttribute('data-mode', modeAttr);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle show more/less toggle visibility and count
|
||||
const allBadges = [...inner.querySelectorAll(".badge")];
|
||||
const realTags = allBadges.filter(b => !b.querySelector('#a_addtag') && !b.querySelector('#a_toggle') && !b.classList.contains('tag-ac-wrapper'));
|
||||
|
||||
Reference in New Issue
Block a user