您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Добавляет кнопку "Упоминание поста" как в мобильном приложении + сразу сортирует по дате от новых к старым.
// ==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); })();