您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fängt Klicks auf .metaRibbon ab und zeigt den Kommentar in einem Vorschaupopup
// ==UserScript== // @name MyDealz Letzten Kommentar bei Sortierung nach 'Diskutiert' anzeigen // @namespace http://tampermonkey.net/ // @version 1.0 // @description Fängt Klicks auf .metaRibbon ab und zeigt den Kommentar in einem Vorschaupopup // @author MD928835 // @license MIT // @match https://www.mydealz.de/*-discussed* // @grant none // @require https://update.greasyfork.org/scripts/531060/1561179/Comment%20PopUp.js // ==/UserScript== (function() { 'use strict'; document.addEventListener('click', handleClick, true); async function handleClick(event) { const metaRibbon = event.target.closest('.metaRibbon'); if (!metaRibbon) return; event.stopPropagation(); event.preventDefault(); const article = metaRibbon.closest('article'); if (!article) { console.error('Kein umschließendes <article> gefunden'); return; } const threadId = article.id.replace('thread_', ''); const metaText = metaRibbon.querySelector('span').textContent; const match = metaText.match(/kommentiert\s(.*?)(?:\s+von\s(.+))?$/); const username = match && match[2] ? match[2].trim() : 'Unbekannt'; // console.log('Thread ID:', threadId); // console.log('Autor:', username); const { commentId } = await getCommentDirectLink(threadId, username); if (commentId) { showCommentPopup(commentId); } else { console.error('Kommentar-ID konnte nicht ermittelt werden'); } } async function getCommentDirectLink(threadId, username) { const encodedUsername = encodeURIComponent(username); let commentId = null; try { const profileHtml = await fetch(`https://www.mydealz.de/profile/${encodedUsername}`).then(res => res.text()); const tempDiv = document.createElement('div'); tempDiv.innerHTML = profileHtml; const commentRegex = new RegExp(`https://www\\.mydealz\\.de/.*-${threadId}#(?:reply|comment)-([0-9]+)`); const directLinkElement = Array.from(tempDiv.querySelectorAll('a')).find(a => commentRegex.test(a.href)); if (directLinkElement) { const match = directLinkElement.href.match(commentRegex); if (match && match[1]) { commentId = match[1]; } } } catch (error) { console.error('Fehler beim Abrufen der Profildaten:', error); } return { commentId }; } })();