|
| Код: <a href="https://crossess.ru/" target="_blank"><img src="https://upforme.ru/uploads/001b/9d/d4/2/143691.jpg" width="88px" height="31px" title="crosses (crossover)"></a> |
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.5/firebase-app.js";
import { getDatabase, ref, set, get } from "https://www.gstatic.com/firebasejs/10.12.5/firebase-database.js";
import { getAuth, signInAnonymously, onAuthStateChanged } from "https://www.gstatic.com/firebasejs/10.12.5/firebase-auth.js";
// Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyClr62iAjNEM2xE7_PEkw0l9i4HNeO7nqE",
authDomain: "tbhc-66edd.firebaseapp.com",
databaseURL: "https://tbhc-66edd-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "tbhc-66edd",
storageBucket: "tbhc-66edd.appspot.com",
messagingSenderId: "852632586224",
appId: "1:852632586224:web:05db18b44a04cc3719ff35"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getDatabase(app);
const auth = getAuth(app);
// Cache for liked posts
const localCache = {};
// Sign in anonymously
signInAnonymously(auth)
.then(() => {
console.log('User signed in anonymously');
})
.catch((error) => {
console.error('Error signing in anonymously:', error);
});
// Handle authentication state
onAuthStateChanged(auth, (user) => {
if (user) {
const firebaseUserId = user.uid; // The authenticated Firebase user ID
console.log('Authenticated Firebase User ID:', firebaseUserId);
// Extract forum user ID from the profile link
const forumUserId = extractForumUserId();
if (!forumUserId) {
console.error('Failed to extract forum user ID.');
return;
}
console.log('Forum User ID:', forumUserId);
const userLikesRef = ref(db, `likes/${forumUserId}`);
console.log('Firebase path:', userLikesRef.toString());
get(userLikesRef).then((snapshot) => {
localCache[forumUserId] = snapshot.val() || {};
document.querySelectorAll('div[id^="p"][data-posted][data-user-id][data-group-id]').forEach(function(post) {
const postId = post.id.replace('p', '');
const icon = post.querySelector('div.post-body > div.post-box > div.post-rating > p > a');
const postAuthorId = post.getAttribute('data-user-id'); // Assuming post author ID is stored here
// Initialize icon classes based on current state
if (icon) {
updateIconClasses(postId, icon, localCache[forumUserId]);
}
// Listen for like button clicks
if (icon) {
icon.addEventListener('click', function() {
if (postAuthorId !== forumUserId) {
if (!localCache[forumUserId][postId]) {
// Like the post (if not already liked)
localCache[forumUserId][postId] = true;
// Optimistically update UI
if (icon) {
updateIconClasses(postId, icon, localCache[forumUserId]);
}
// Save the like action to Firebase
const postRef = ref(db, `likes/${forumUserId}/${postId}`);
set(postRef, true)
.catch((error) => {
console.error('Error updating like action:', error);
});
}
} else {
console.warn('User cannot like their own post.');
}
});
// MutationObserver to detect changes in the like count
let previousLikeCount = parseInt(icon.textContent, 10);
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
const newLikeCount = parseInt(icon.textContent, 10);
// Check if the like count has increased
if (newLikeCount > previousLikeCount) {
// Update the local cache to reflect the new liked state
localCache[forumUserId][postId] = true;
// Handle the like count change by updating the icon
updateIconClasses(postId, icon, localCache[forumUserId]);
// Save the like action to Firebase if it's not already there
const postRef = ref(db, `likes/${forumUserId}/${postId}`);
set(postRef, true)
.then(() => {
console.log('Like action saved to Firebase due to observed change.');
})
.catch((error) => {
console.error('Error updating like action from MutationObserver:', error);
});
}
// Update previous like count
previousLikeCount = newLikeCount;
}
});
});
// Observe the like element for changes in its child nodes (text content)
observer.observe(icon, {
childList: true, // Monitor changes in the text content
});
}
});
}).catch((error) => {
console.error('Error fetching liked posts:', error);
});
} else {
console.error('No user is signed in.');
}
});
// Function to update icon classes based on user interactions
function updateIconClasses(postId, icon, likedPosts) {
if (likedPosts[postId]) {
icon.classList.add('noNullLiked');
} else {
icon.classList.remove('noNullLiked');
}
}
// Function to extract forum user ID from profile link
function extractForumUserId() {
const profileLink = document.querySelector('#navprofile > a');
if (!profileLink) return null;
const url = profileLink.href;
const match = url.match(/id=(\d+)/);
return match ? match[1] : null;
}
crosses |
Привет, Гость! Войдите или зарегистрируйтесь.
Вы здесь » crosses » solar bind » баннерообмен
|
| Код: <a href="https://crossess.ru/" target="_blank"><img src="https://upforme.ru/uploads/001b/9d/d4/2/143691.jpg" width="88px" height="31px" title="crosses (crossover)"></a> |
я человек простой вижу красивый дизайн предлагаю руку и сердце и обмен бабнерами
<a href="https://americafckyeah.rusff.me/" target="_blank"><img src="https://forumstatic.ru/files/001c/96/9f/74727.jpg" title="welcome to candy`s!" border="0" width="88" height="31"></a>
invisible hand, всё прошло успешно! 
привет, а давайте дружить, красивые
<a href="https://prosecco.rusff.me"><img src="https://i.imgur.com/1uuL2vm.png" title="champagne" alt="real-life" width="88" height="31"></a>
invisible hand, от красивых слышим 
А можно нам тоже, пожалуйста?
<a href="https://aleandtalecross.ru/" target="_blank"><img src="https://forumstatic.ru/files/001c/87/f8/10727.jpg" title="Ale and Tale crossover" border="0"width="88" height="31"></a>
invisible hand, конечно, уже всё поставили 🧸
доброй ночи, пришли махнуться баннерами :3
<a href="https://execute.rusff.me/" target="_blank"><img src="https://forumstatic.ru/files/001b/f1/8a/26876.png" alt="Execute" title="Execute [кроссовер]" width="88" height="31"></a>
invisible hand, приветики, закинули 
добрый день! это kakaotalk, хотим с вами обменяться баннерами)
<a href="https://kakaotalk.rusff.me/" target="_blank"> <img src="https://upforme.ru/uploads/001c/9b/a1/7/934056.png" title="kakaotalk" border="0" alt="kakaotalk"></a>
invisible hand, добрый, баннер поставили, спасибо!
хотим с вами обменяться баннерами, красивые
ваш баннер установлен в футере ♥
<a href="https://supremumvale.rusff.me/" target="_blank"><img src="https://upforme.ru/uploads/001c/52/68/4/208118.png" title="перси джексон ♥ мифология"></a>
invisible hand, очень красиво стоите и у нас в футере теперь ! 
мое почтение таким красивым, давайте дружить?
вас уже поставили в футере
<a href="https://wtscross.rusff.me/" target="_blank"><img src="https://forumstatic.ru/files/001c/97/18/61929.png" title="write to survive [crossover]" border="0"width="88" height="31"></a>
Отредактировано invisible hand (2026-01-26 14:52:09)
invisible hand, а вам наше почтение, ваш баннер тоже уже поставили в футере! 
очень нравится ваша эстетика. предлагаем дружить домами
наш баннер
<a href="https://sept3rd.rusff.me/" title="Sept.3rd"><img src="https://upforme.ru/uploads/001a/eb/a8/2/61477.png" border="0"></a>
ваш поставили в футер туть
invisible hand, принимаем вашу дружбу, баннер тоже поставили в футер! 
Добрый вечер, прекрасные, будем рады задружиться и обменяться баннерами
<a href="https://faceinless.ru" target=_blank><img src="https://upforme.ru/uploads/0010/90/43/2/358629.png" title="TVD: FACELESS">
Ваш баннер установлен в футере 
invisible hand, и мы рады, ваш баннер тоже в футере! 
Привет, красивые! Давайте меняться баннерами? Ваш уже стоит в футере
<a href="https://phantompact.rusff.me/" target="_blank"><img src="https://upforme.ru/uploads/001c/2a/e5/3/924613.gif" alt="Повесть о призрачном пакте" title="Повесть о призрачном пакте" width="88" height="31"></a>
Отредактировано invisible hand (2026-02-12 03:24:24)
Добрый день! Это kakaotalk.
Мы обновились и в связи с этим просим заменить наш баннер. Заранее спасибо!
<a href="https://kakaotalk.rusff.me/" target="_blank"> <img src="https://upforme.ru/uploads/001c/9b/a1/7/846859.png" title="kakaotalk" border="0" alt="kakaotalk"></a>
invisible hand, обновили, поздравляем с обновками! 
привет, на связи prime, вы красивые
<a href="https://prime.rusff.me/" target="_blank"><img src="https://i.imgur.com/GKET1Zv.png" title="prime" border="0"></a>
invisible hand, привет, и вы! 
Вы здесь » crosses » solar bind » баннерообмен