Greasy Fork

Greasy Fork is available in English.

Упоминание поста

Добавляет кнопку "Упоминание поста" как в мобильном приложении + сразу сортирует по дате от новых к старым.

当前为 2025-05-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Упоминание поста
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Добавляет кнопку "Упоминание поста" как в мобильном приложении + сразу сортирует по дате от новых к старым.
// @author       Vierta
// @match        https://4pda.to/forum/index.php?showtopic=*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Функция для извлечения topic_id из URL
    function getTopicId() {
        const url = window.location.href;
        const match = url.match(/showtopic=(\d+)/);
        return match ? match[1] : null;
    }

    // Функция для создания кнопки поиска
    function createSearchButton(postId, topicId) {
        const searchUrl = `https://4pda.to/forum/index.php?topics=${topicId}&act=search&source=pst&query=${postId}&sort=dd&result=posts`;
        const searchButton = document.createElement('a');
        searchButton.href = searchUrl;
        searchButton.textContent = 'Упоминание поста';
        searchButton.className = 'g-btn blue min-mid';
        searchButton.style.marginLeft = '10px';
        return searchButton;
    }

    // Основная функция
    function addSearchButtons() {
        const topicId = getTopicId();
        if (!topicId) return;

        // Находим все элементы с сообщениями
        const postLinks = document.querySelectorAll('a[onclick*="link_to_post"]');

        postLinks.forEach(link => {
            // Извлекаем postId из onclick атрибута
            const postIdMatch = link.onclick.toString().match(/link_to_post\((\d+)\)/);
            if (postIdMatch && postIdMatch[1]) {
                const postId = postIdMatch[1];
                const parentDiv = link.parentElement;

                // Создаем и добавляем кнопку поиска
                const searchButton = createSearchButton(postId, topicId);
                parentDiv.appendChild(searchButton);
            }
        });
    }

    // Запускаем после загрузки страницы
    window.addEventListener('load', addSearchButtons);
})();