X Timeline Sync

Tracks and syncs your last reading position on Twitter/X, with manual and automatic options. Ideal for keeping track of new posts without losing your place.

目前為 2025-02-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name              X Timeline Sync
// @description       Tracks and syncs your last reading position on Twitter/X, with manual and automatic options. Ideal for keeping track of new posts without losing your place.
// @description:de    Verfolgt und synchronisiert Ihre letzte Leseposition auf Twitter/X, mit manuellen und automatischen Optionen. Perfekt, um neue Beiträge im Blick zu behalten, ohne die aktuelle Position zu verlieren.
// @description:es    Rastrea y sincroniza tu última posición de lectura en Twitter/X, con opciones manuales y automáticas. Ideal para mantener el seguimiento de las publicaciones nuevas sin perder tu posición.
// @description:fr    Suit et synchronise votre dernière position de lecture sur Twitter/X, avec des options manuelles et automatiques. Idéal pour suivre les nouveaux posts sans perdre votre place actuelle.
// @description:zh-CN 跟踪并同步您在 Twitter/X 上的最后阅读位置,提供手动和自动选项。完美解决在查看新帖子时不丢失当前位置的问题。
// @description:ru    Отслеживает и синхронизирует вашу последнюю позицию чтения на Twitter/X с ручными и автоматическими опциями. Идеально подходит для просмотра новых постов без потери текущей позиции.
// @description:ja    Twitter/X での最後の読み取り位置を追跡して同期します。手動および自動オプションを提供します。新しい投稿を見逃さずに現在の位置を維持するのに最適です。
// @description:pt-BR Rastrea e sincroniza sua última posição de leitura no Twitter/X, com opções manuais e automáticas. Perfeito para acompanhar novos posts sem perder sua posição atual.
// @description:hi    Twitter/X पर आपकी अंतिम पठन स्थिति को ट्रैक और सिंक करता है, मैनुअल और स्वचालित विकल्पों के साथ। नई पोस्ट देखते समय अपनी वर्तमान स्थिति को खोए बिना इसे ट्रैक करें।
// @description:ar    يتتبع ويزامن آخر موضع قراءة لك على Twitter/X، مع خيارات يدوية وتلقائية. مثالي لتتبع المشاركات الجديدة دون فقدان موضعك الحالي.
// @description:it    Traccia e sincronizza la tua ultima posizione di lettura su Twitter/X, con opzioni manuali e automatiche. Ideale per tenere traccia dei nuovi post senza perdere la posizione attuale.
// @description:ko    Twitter/X에서 마지막 읽기 위치를 추적하고 동기화합니다. 수동 및 자동 옵션 포함. 새로운 게시물을 확인하면서 현재 위치를 잃지 않도록 이상적입니다.
// @icon              https://x.com/favicon.ico
// @namespace         http://tampermonkey.net/
// @version           2025-02-03.1
// @author            Copiis
// @license           MIT
// @match             https://x.com/home
// @grant             GM_setValue
// @grant             GM_getValue
// @grant             GM_download
// ==/UserScript==

(function() {
    'use strict';

    let lastReadPost = null;
    let isAutoScrolling = false;
    let isSearching = false;
    let isTabFocused = true;
    let downloadTriggered = false;
    let scrollTimeout;
    let hasScrolledAfterLoad = false;
    let isPostLoading = false; // To track if new posts are currently loading
    let searchTimeout; // To control the duration of the search

    // Internationalization
    const translations = {
        en: {
            scriptDisabled: "🚫 Script disabled: Not on the home page.",
            pageLoaded: "🚀 Page fully loaded. Initializing script...",
            tabBlur: "🌐 Tab lost focus.",
            downloadStart: "📥 Starting download of last read position...",
            alreadyDownloaded: "🗂️ Position already downloaded.",
            tabFocused: "🟢 Tab refocused.",
            saveSuccess: "✅ Last read position saved:",
            saveFail: "⚠️ No valid position to save.",
            noPostFound: "❌ No top visible post found.",
            highlightSuccess: "✅ Post highlighted successfully.",
            searchStart: "🔍 Refined search started...",
            searchCancel: "⏹️ Search manually canceled.",
            contentLoadWait: "⌛ Waiting for content to load..."
        },
        de: {
            scriptDisabled: "🚫 Skript deaktiviert: Nicht auf der Home-Seite.",
            pageLoaded: "🚀 Seite vollständig geladen. Initialisiere Skript...",
            tabBlur: "🌐 Tab hat den Fokus verloren.",
            downloadStart: "📥 Starte Download der letzten Leseposition...",
            alreadyDownloaded: "🗂️ Leseposition bereits im Download-Ordner vorhanden.",
            tabFocused: "🟢 Tab wieder fokussiert.",
            saveSuccess: "✅ Leseposition erfolgreich gespeichert:",
            saveFail: "⚠️ Keine gültige Leseposition zum Speichern.",
            noPostFound: "❌ Kein oberster sichtbarer Beitrag gefunden.",
            highlightSuccess: "✅ Beitrag erfolgreich hervorgehoben.",
            searchStart: "🔍 Verfeinerte Suche gestartet...",
            searchCancel: "⏹️ Suche manuell abgebrochen.",
            contentLoadWait: "⌛ Warte darauf, dass der Inhalt geladen wird..."
        }
    };

    const userLang = navigator.language.split('-')[0];
    const t = (key) => translations[userLang]?.[key] || translations.en[key];

    // Debounce function for scroll events
    function debounce(func, wait) {
        let timeout;
        return function executedFunction(...args) {
            const later = () => {
                clearTimeout(timeout);
                func(...args);
            };
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
        };
    }

    // IntersectionObserver for efficient visibility detection
    const observer = new IntersectionObserver(
        entries => {
            entries.forEach(entry => {
                if (entry.isIntersecting) {
                    const postData = {
                        timestamp: getPostTimestamp(entry.target),
                        authorHandler: getPostAuthorHandler(entry.target)
                    };
                    // Optionally update or save the data here
                }
            });
        },
        { threshold: 0.1 }
    );

    // Only observe posts that are close to the viewport
    function observeVisiblePosts() {
        const articles = document.querySelectorAll('article');
        const viewportHeight = window.innerHeight;
        const buffer = viewportHeight * 2; // Observing posts within 2 viewports from the top/bottom

        for (let article of articles) {
            const rect = article.getBoundingClientRect();
            if (rect.top < buffer && rect.bottom > -buffer) {
                observer.observe(article);
            } else {
                observer.unobserve(article); // Unobserve if moved out of buffer range
            }
        }
    }

    function loadNewestLastReadPost() {
        const data = GM_getValue("lastReadPost", null);
        if (data) {
            lastReadPost = JSON.parse(data);
            console.log(t("saveSuccess"), lastReadPost);
        } else {
            console.warn(t("saveFail"));
        }
    }

    function loadLastReadPostFromFile() {
        loadNewestLastReadPost();
    }

    function saveLastReadPostToFile() {
        if (lastReadPost && lastReadPost.timestamp && lastReadPost.authorHandler) {
            GM_setValue("lastReadPost", JSON.stringify(lastReadPost));
            console.log(t("saveSuccess"), lastReadPost);
        } else {
            console.warn(t("saveFail"));
        }
    }

    function downloadLastReadPost() {
        if (!lastReadPost || !lastReadPost.timestamp || !lastReadPost.authorHandler) {
            console.warn(t("saveFail"));
            return;
        }
        try {
            const data = JSON.stringify(lastReadPost, null, 2);
            const sanitizedHandler = lastReadPost.authorHandler.replace(/[^a-zA-Z0-9-_]/g, "");
            const timestamp = new Date(lastReadPost.timestamp).toISOString().replace(/[:.-]/g, "_");
            const fileName = `${sanitizedHandler}_${timestamp}.json`;

            GM_download({
                url: `data:application/json;charset=utf-8,${encodeURIComponent(data)}`,
                name: fileName,
                onload: () => console.log(`${t("saveSuccess")} ${fileName}`),
                onerror: (err) => console.error("❌ Error downloading:", err),
            });
        } catch (error) {
            console.error("❌ Download error:", error);
        }
    }

    function markTopVisiblePost(save = true) {
        const topPost = getTopVisiblePost();
        if (!topPost) {
            console.log(t("noPostFound"));
            return;
        }

        const postTimestamp = getPostTimestamp(topPost);
        const authorHandler = getPostAuthorHandler(topPost);

        if (postTimestamp && authorHandler) {
            if (save && (!lastReadPost || new Date(postTimestamp) > new Date(lastReadPost.timestamp))) {
                lastReadPost = { timestamp: postTimestamp, authorHandler };
                saveLastReadPostToFile();
            }
        }
    }

    function getTopVisiblePost() {
        return Array.from(document.querySelectorAll("article")).find(post => {
            const rect = post.getBoundingClientRect();
            return rect.top >= 0 && rect.bottom > 0;
        });
    }

    function getPostTimestamp(post) {
        const timeElement = post.querySelector("time");
        return timeElement ? timeElement.getAttribute("datetime") : null;
    }

    function getPostAuthorHandler(post) {
        const handlerElement = post.querySelector('[role="link"][href*="/"]');
        return handlerElement ? handlerElement.getAttribute("href").slice(1) : null;
    }

    // Binary search for last read post
    function binarySearchForLastReadPost() {
        if (!lastReadPost || !lastReadPost.timestamp) return;

        let posts = Array.from(document.querySelectorAll('article')).map(post => ({
            element: post,
            timestamp: getPostTimestamp(post)
        })).filter(post => post.timestamp);

        if (posts.length === 0) return;

        let low = 0;
        let high = posts.length - 1;
        let lastReadTime = new Date(lastReadPost.timestamp);

        while (low <= high) {
            let mid = Math.floor((low + high) / 2);
            let midPostTime = new Date(posts[mid].timestamp);

            if (midPostTime.getTime() === lastReadTime.getTime()) {
                scrollToPostWithHighlight(posts[mid].element);
                return;
            } else if (midPostTime < lastReadTime) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }

        // If exact match not found, adjust for nearest post
        let nearestPost = posts[low] || posts[high];
        scrollToPostWithHighlight(nearestPost.element);
    }

    function startRefinedSearchForLastReadPost() {
    if (!lastReadPost || !lastReadPost.timestamp || !lastReadPost.authorHandler || isPostLoading) return;

    console.log(t("searchStart"));
    const popup = createSearchPopup();
    let direction = 1; // 1 for scrolling down, -1 for up
    let scrollAmount = 200; // Smaller initial scroll jump size
    let previousScrollY = -1;
    let lastComparison = null;
    let initialAdjusted = false;
    let lastScrollDirection = null;
    let lastScrollY = 0;

    clearTimeout(searchTimeout); // Clear any ongoing timeout
    searchTimeout = setTimeout(() => {
        console.log(t("searchCancel"));
        isSearching = false;
        popup.remove();
        window.removeEventListener("keydown", handleSpaceKey);
    }, 10000); // Search for 10 seconds before stopping

    function handleSpaceKey(event) {
        if (event.code === "Space") {
            console.log(t("searchCancel"));
            isSearching = false;
            popup.remove();
            window.removeEventListener("keydown", handleSpaceKey);
            clearTimeout(searchTimeout);
        }
    }

    window.addEventListener("keydown", handleSpaceKey);

    function search() {
        if (!isSearching) {
            popup.remove();
            return;
        }

        const visiblePosts = getVisiblePosts();
        if (visiblePosts.length === 0 && !isPostLoading) {
            setTimeout(search, 1000);
            return;
        }

        if (!initialAdjusted) {
            const comparison = compareVisiblePostsToLastReadPost(visiblePosts);
            adjustInitialScroll(comparison);
            initialAdjusted = true;
        }

        const comparison = compareVisiblePostsToLastReadPost(visiblePosts);
        const lastReadTime = new Date(lastReadPost.timestamp);
        let nearestVisiblePostTime = null;

        if (visiblePosts.length > 0) {
            nearestVisiblePostTime = new Date(visiblePosts[0].timestamp);
        }

        scrollAmount = adjustScrollSpeed(visiblePosts, lastReadTime);

        if (comparison === "match") {
            const matchedPost = findPostByData(lastReadPost);
            if (matchedPost) {
                scrollToPostWithHighlight(matchedPost);
                isSearching = false;
                popup.remove();
                window.removeEventListener("keydown", handleSpaceKey);
                clearTimeout(searchTimeout);
                return;
            }
        } else if (comparison === "older") {
            direction = -1;
        } else if (comparison === "newer") {
            direction = 1;
        }

        if (lastScrollDirection === direction && window.scrollY === lastScrollY) {
            direction = -direction; // Change direction if stuck
        }

        lastScrollDirection = direction;
        lastScrollY = window.scrollY;

        console.log(`Scroll-Richtung: ${direction}, Betrag: ${scrollAmount}, aktuelle Position: ${window.scrollY}, Zeitdifferenz: ${Math.abs(lastReadTime - nearestVisiblePostTime)}`);

        requestAnimationFrame(() => {
            window.scrollBy(0, direction * scrollAmount);
            search(); // Recursive call controlled by requestAnimationFrame
        });
    }

    isSearching = true;
    search();
}

    function adjustInitialScroll(comparison) {
        const initialScrollAmount = 2000; // Größerer initialer Sprung
        if (comparison === "older") {
            for (let i = 0; i < 3; i++) { // Mehrere Anpassungen nach oben
                window.scrollBy(0, -initialScrollAmount / 3);
            }
        } else if (comparison === "newer") {
            for (let i = 0; i < 3; i++) { // Mehrere Anpassungen nach unten
                window.scrollBy(0, initialScrollAmount / 3);
            }
        }
    }

    function adjustScrollSpeed(posts, lastReadTime) {
        if (posts.length === 0) return 1000; // Größerer Startwert
        let nearestPostTime = posts.reduce((min, post) =>
            Math.abs(new Date(post.timestamp) - lastReadTime) < Math.abs(min - lastReadTime)
                ? new Date(post.timestamp)
                : min, Infinity);

        let timeDifference = Math.abs(lastReadTime - nearestPostTime);
        let baseScroll = 10000; // Startwert für die Scroll-Menge
        return Math.max(500, Math.min(baseScroll, baseScroll - (timeDifference / 1000) * 1000));
    }

    function createSearchPopup() {
        const popup = document.createElement("div");
        popup.style.cssText = `position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.9); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); z-index: 10000;`;
        popup.textContent = "🔍 Refined search in progress... Press SPACE to cancel.";
        document.body.appendChild(popup);
        return popup;
    }

    function compareVisiblePostsToLastReadPost(posts) {
        const validPosts = posts.filter(post => post.timestamp && post.authorHandler);
        if (validPosts.length === 0) return null;

        const lastReadTime = new Date(lastReadPost.timestamp);

        if (validPosts.some(post => post.timestamp === lastReadPost.timestamp && post.authorHandler === lastReadPost.authorHandler)) {
            return "match";
        } else if (validPosts.every(post => new Date(post.timestamp) < lastReadTime)) {
            return "older";
        } else if (validPosts.every(post => new Date(post.timestamp) > lastReadTime)) {
            return "newer";
        } else {
            return "mixed";
        }
    }

    function scrollToPostWithHighlight(post) {
        if (!post) return;
        isAutoScrolling = true;

        post.style.cssText = `outline: none; box-shadow: 0 0 30px 10px rgba(255, 223, 0, 1); background-color: rgba(255, 223, 0, 0.3); border-radius: 12px; transform: scale(1.1); transition: all 0.3s ease;`;
        post.scrollIntoView({ behavior: "smooth", block: "center" });

        setTimeout(() => {
            post.style.boxShadow = "0 0 0 0 rgba(255, 223, 0, 0)";
            post.style.transform = "scale(1)";
            post.style.backgroundColor = "transparent";
        }, 500);

        setTimeout(() => {
            post.style.cssText = ""; // Reset all styles
            isAutoScrolling = false;
            console.log(t("highlightSuccess"));
        }, 1000);
    }

    function getVisiblePosts() {
        return Array.from(document.querySelectorAll("article")).map(post => ({
            element: post,
            timestamp: getPostTimestamp(post),
            authorHandler: getPostAuthorHandler(post)
        })).filter(post => post.timestamp && post.authorHandler);
    }

    function findPostByData(data) {
        return Array.from(document.querySelectorAll("article")).find(post => {
            const postTimestamp = getPostTimestamp(post);
            const authorHandler = getPostAuthorHandler(post);
            return postTimestamp === data.timestamp && authorHandler === data.authorHandler;
        });
    }

    function createButtons() {
        const container = document.createElement("div");
        container.style.cssText = `position: fixed; top: 50%; left: 3px; transform: translateY(-50%); display: flex; flex-direction: column; gap: 3px; z-index: 10000;`;

        const buttons = [
            { icon: "📂", title: "Load saved reading position", onClick: importLastReadPost },
            { icon: "🔍", title: "Start manual search", onClick: startRefinedSearchForLastReadPost }
        ];

        buttons.forEach(({ icon, title, onClick }) => {
            const button = document.createElement("div");
            button.style.cssText = `width: 36px; height: 36px; background: rgba(0, 0, 0, 0.9); color: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; font-size: 18px; box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5); transition: all 0.2s ease;`;
            button.title = title;
            button.textContent = icon;

            button.addEventListener("click", () => {
                button.style.boxShadow = "inset 0 0 20px rgba(255, 255, 255, 0.8)";
                button.style.transform = "scale(0.9)";
                setTimeout(() => {
                    button.style.boxShadow = "inset 0 0 10px rgba(255, 255, 255, 0.5)";
                    button.style.transform = "scale(1)";
                    onClick();
                }, 300);
            });

            ["mouseenter", "mouseleave"].forEach(event =>
                button.addEventListener(event, () => button.style.transform = event === "mouseenter" ? "scale(1.1)" : "scale(1)")
            );

            container.appendChild(button);
        });

        document.body.appendChild(container);
    }

    function importLastReadPost() {
        const input = document.createElement("input");
        input.type = "file";
        input.accept = "application/json";
        input.style.display = "none";

        input.addEventListener("change", (event) => {
            const file = event.target.files[0];
            if (file) {
                const reader = new FileReader();
                reader.onload = () => {
                    try {
                        const importedData = JSON.parse(reader.result);
                        if (importedData.timestamp && importedData.authorHandler) {
                            lastReadPost = importedData;
                            saveLastReadPostToFile();
                            startRefinedSearchForLastReadPost();
                        } else {
                            throw new Error("Invalid reading position");
                        }
                    } catch (error) {
                        console.error("❌ Error importing reading position:", error);
                    }
                };
                reader.readAsText(file);
            }
        });

        document.body.appendChild(input);
        input.click();
        document.body.removeChild(input);
    }

    function observeForNewPosts() {
    const targetNode = document.querySelector('div[aria-label="Timeline: Your Home Timeline"]') || document.body;

    const mutationObserver = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            if (mutation.type === 'childList') {
                checkForNewPosts();
            }
        }
    });

    mutationObserver.observe(targetNode, { childList: true, subtree: true });
}

    function checkForNewPosts() {
    if (window.scrollY <= 10) {
        const newPostsIndicator = getNewPostsIndicator();
        if (newPostsIndicator) {
            console.log("🆕 New posts detected near the top. Clicking indicator...");
            clickNewPostsIndicator(newPostsIndicator);
            hasScrolledAfterLoad = false;

            // Instead of waiting for content to load, directly start the refined search
            setTimeout(() => {
                console.log("Starting search immediately after clicking new posts indicator...");
                startRefinedSearchForLastReadPost();
            }, 500); // A short delay might be necessary for the DOM to update, but this should be minimal
        }
    }
}

    function getNewPostsIndicator() {
        return document.querySelector('div[aria-label*="undefined"]');
    }

    function clickNewPostsIndicator(indicator) {
        if (indicator) {
            indicator.click();
            console.log("Clicked on new posts indicator.");
        }
    }

    async function simpleContentCheck() {
    let posts = document.querySelectorAll("article");
    return posts.length > 0;
}

    window.onload = async () => {
        if (!window.location.href.includes("/home")) {
            console.log(t("scriptDisabled"));
            return;
        }
        console.log(t("pageLoaded"));
        await loadNewestLastReadPost();
        await initializeScript();
        createButtons();

        window.addEventListener("beforeunload", async (e) => {
            console.log("Browser wird geschlossen.");
            if (lastReadPost && !downloadTriggered) {
                downloadTriggered = true;
                if (!(await isFileAlreadyDownloaded())) {
                    console.log(t("downloadStart"));
                    await downloadLastReadPost();
                    await markDownloadAsComplete();
                } else {
                    console.log(t("alreadyDownloaded"));
                }
            }
        });
    };

    async function initializeScript() {
        console.log(t("pageLoaded"));
        await loadLastReadPostFromFile();
        observeForNewPosts();

        // Observe posts that are close to the viewport
        observeVisiblePosts();

        // Use debounced scroll event listener
        window.addEventListener("scroll", debounce(() => {
            observeVisiblePosts(); // Re-evaluate which posts to observe on scroll
            if (!isAutoScrolling && !isSearching) {
                if (hasScrolledAfterLoad) {
                    markTopVisiblePost(true);
                } else {
                    hasScrolledAfterLoad = true;
                }
            }
        }, 500));
    }

    window.addEventListener("blur", async () => {
        console.log(t("tabBlur"));
        if (lastReadPost && !downloadTriggered) {
            downloadTriggered = true;
            if (!(await isFileAlreadyDownloaded())) {
                console.log(t("downloadStart"));
                await downloadLastReadPost();
                await markDownloadAsComplete();
            } else {
                console.log(t("alreadyDownloaded"));
            }
            downloadTriggered = false;
        }
    });

    window.addEventListener("focus", () => {
    isTabFocused = true;
    downloadTriggered = false;
    console.log(t("tabFocused"));

    // Check if new posts need to be loaded before starting the search
    if (window.scrollY === 0) { // Assumes new posts indicator is at the top when not scrolled
        const newPostsIndicator = getNewPostsIndicator();
        if (newPostsIndicator) {
            isPostLoading = true;
            clickNewPostsIndicator(newPostsIndicator);
            console.log("Loading new posts...");

            // Wait for some posts to load before starting the search
            setTimeout(() => {
                isPostLoading = false;
                hasScrolledAfterLoad = false; // Reset this as we're treating this as a new load
                startRefinedSearchForLastReadPost(); // Start the search after a brief delay
            }, 2000); // Adjust this delay based on how long it typically takes for posts to load
        } else {
            // If no new posts indicator, start search directly
            startRefinedSearchForLastReadPost();
        }
    }
});

    async function isFileAlreadyDownloaded() {
        const localFiles = await GM_getValue("downloadedPosts", []);
        const fileSignature = `${lastReadPost.authorHandler}_${lastReadPost.timestamp}`;
        return localFiles.includes(fileSignature);
    }

    async function markDownloadAsComplete() {
        const localFiles = await GM_getValue("downloadedPosts", []);
        const fileSignature = `${lastReadPost.authorHandler}_${lastReadPost.timestamp}`;
        if (!localFiles.includes(fileSignature)) {
            localFiles.push(fileSignature);
            GM_setValue("downloadedPosts", localFiles);
        }
    }
})();