Dublanet Lastpost (Tema DublaNOVO)

Transforma últimos posts em hyperlinks

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Dublanet Lastpost (Tema DublaNOVO)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Transforma últimos posts em hyperlinks
// @author       Brenda
// @match        https://www.dublanet.com.br/comunidade/forumdisplay.php*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Selecionar todos os tópicos
    document.querySelectorAll('.card').forEach(card => {
        // Achar o tid
        const threadLink = card.querySelector('a[href*="showthread.php?tid="]');
        if (!threadLink) return;

        const tidMatch = threadLink.href.match(/tid=(\d+)/);
        if (!tidMatch) return;

        const tid = tidMatch[1];
        const lastpostUrl = `showthread.php?tid=${tid}&action=lastpost`;

        // Achar os elementos pra linkar
        const dateSpans = card.querySelectorAll('span.small.text-muted, span[title*="horas"], span[title*="Ontem"]');

        dateSpans.forEach(span => {
            // Não duplicar links
            if (span.closest('a')) return;

            const link = document.createElement('a');
            link.href = lastpostUrl;
            link.style.textDecoration = 'underline dotted';
            link.title = 'Ir para a última mensagem';
            link.appendChild(span.cloneNode(true));
            span.replaceWith(link);
        });
    });
})();