BR | Mobile Walker (Fixed & Clean)

Исправленная версия. Заходит в темы, ставит лайк и выходит.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         BR | Mobile Walker (Fixed & Clean)
// @namespace    https://forum.blackrussia.online
// @version      6.1
// @description  Исправленная версия. Заходит в темы, ставит лайк и выходит.
// @author       Gemini & Nuserik
// @match        https://forum.blackrussia.online/whats-new/*
// @match        https://forum.blackrussia.online/threads/*
// @match        https://forum.blackrussia.online/posts/*
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- НАСТРОЙКИ ---
    const CONFIG = {
        FEED_URL: 'https://forum.blackrussia.online/whats-new/posts/?skip=1',
        DELAY_WAIT: 2000, // Ждать 2 сек перед действием
    };

    const DB_KEY = 'br_walker_history_v6';

    // --- ИНТЕРФЕЙС ---
    function hud(msg) {
        let el = document.getElementById('walker-hud');
        if (!el) {
            el = document.createElement('div');
            el.id = 'walker-hud';
            el.style.cssText = "position:fixed;top:0;left:0;right:0;background:black;color:lime;padding:10px;text-align:center;z-index:9999;font-family:monospace;border-bottom:2px solid lime;";
            document.body.appendChild(el);
        }
        el.innerText = "STATUS: " + msg;
    }

    // --- ИСТОРИЯ (Чтобы не заходить дважды) ---
    function checkHistory(link) {
        let db = JSON.parse(localStorage.getItem(DB_KEY) || '[]');
        return db.includes(link);
    }

    function saveHistory(link) {
        let db = JSON.parse(localStorage.getItem(DB_KEY) || '[]');
        if (!db.includes(link)) {
            db.push(link);
            if (db.length > 200) db.shift();
            localStorage.setItem(DB_KEY, JSON.stringify(db));
        }
    }

    // --- ЛОГИКА РАБОТЫ ---
    function run() {
        const url = window.location.href;

        // 1. ЕСЛИ МЫ В ЛЕНТЕ
        if (url.includes('whats-new')) {
            hud("ИЩУ ТЕМУ...");
            
            let links = document.querySelectorAll('.structItem-title a');
            let target = null;

            for (let i = 0; i < links.length; i++) {
                let href = links[i].href;
                // Убираем лишнее из ссылки
                if (href.indexOf('/unread') > -1) {
                    href = href.split('/unread')[0];
                }
                
                if (!checkHistory(href) && href.includes('threads/')) {
                    target = href;
                    break;
                }
            }

            if (target) {
                hud("ЗАХОЖУ: " + target);
                saveHistory(target);
                setTimeout(function() {
                    window.location.href = target;
                }, 1000);
            } else {
                hud("НЕТ НОВЫХ ТЕМ. ОБНОВЛЕНИЕ...");
                setTimeout(function() {
                    window.location.href = CONFIG.FEED_URL;
                }, 2000);
            }
        } 
        
        // 2. ЕСЛИ МЫ ВНУТРИ ТЕМЫ
        else if (url.includes('threads/') || url.includes('posts/')) {
            hud("Я В ТЕМЕ. ЖДУ...");

            setTimeout(function() {
                let btn = document.querySelector('.reaction:not(.reaction--reacted)');
                
                if (btn) {
                    hud("ЛАЙК!");
                    btn.scrollIntoView({behavior: "smooth", block: "center"});
                    
                    setTimeout(function() {
                        btn.click();
                        // Уходим обратно через 1 сек
                        setTimeout(function() {
                            window.location.href = CONFIG.FEED_URL;
                        }, 1000);
                    }, 500);
                } else {
                    hud("КНОПОК НЕТ. УХОЖУ.");
                    window.location.href = CONFIG.FEED_URL;
                }
            }, CONFIG.DELAY_WAIT);
        }
        
        // 3. ЕСЛИ ЗАБЛУДИЛИСЬ
        else {
            setTimeout(function() {
                if (!url.includes('login')) {
                    window.location.href = CONFIG.FEED_URL;
                }
            }, 3000);
        }
    }

    // ЗАПУСК
    if (document.readyState === 'complete') {
        run();
    } else {
        window.addEventListener('load', run);
    }

})();