Mydealz Spam Button

Fügt einen "Spam melden" Button im Nachrichtenbereich hinzu

  1. // ==UserScript==
  2. // @name Mydealz Spam Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Fügt einen "Spam melden" Button im Nachrichtenbereich hinzu
  6. // @author Claude 3.5
  7. // @match https://www.mydealz.de/profile/messages*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // CSS für Button-Design hinzufügen
  16. const style = document.createElement('style');
  17. style.textContent = `
  18. .button--mode-danger {
  19. background-color: transparent;
  20. color: #dc3545;
  21. }
  22.  
  23. .button--mode-danger:hover {
  24. background-color: rgba(220, 53, 69, 0.1);
  25. }
  26. `;
  27. document.head.appendChild(style);
  28.  
  29. function init() {
  30. const checkInterval = setInterval(() => {
  31. const replyButton = document.querySelector('[data-t="sendButton"]');
  32. const activeMessage = document.querySelector('.conversationList-msg--active');
  33.  
  34. if (replyButton && activeMessage && !document.querySelector('[data-spam-button]')) {
  35. clearInterval(checkInterval);
  36. addSpamButton(replyButton, activeMessage);
  37. }
  38. }, 500);
  39.  
  40. setTimeout(() => clearInterval(checkInterval), 10000);
  41. }
  42.  
  43. function addSpamButton(replyButton, activeMessage) {
  44. const username = activeMessage.querySelector('.conversationList-senderLine').textContent.trim();
  45. const messageText = activeMessage.querySelector('.conversationList-msgPreview').textContent.trim();
  46. const messageLong = document.querySelector('.splitPage-paneTwo .userHtml').textContent.trim();
  47. const messageShort = messageText.substring(0, 40) + '...';
  48.  
  49. const spamButton = document.createElement('button');
  50. spamButton.className = 'button button--shape-circle button--type-secondary button--mode-danger';
  51. spamButton.setAttribute('data-spam-button', 'true');
  52. spamButton.innerHTML = `
  53. <span class="flex--inline boxAlign-ai--all-c">
  54. <svg width="18" height="18" class="icon icon--flag space--mr-2">
  55. <use xlink:href="/assets/img/ico_c6302.svg#flag"></use>
  56. </svg>
  57. <span class="hide--toW5 space--ml-2">Spam melden</span>
  58. </span>
  59. `;
  60.  
  61. replyButton.parentNode.insertBefore(spamButton, replyButton);
  62.  
  63. spamButton.addEventListener('click', () => {
  64. if (confirm(`Soll diese Nachricht von "${username}"\n\n"${messageShort}"\n\nals Spam an den Support gemeldet werden?`)) {
  65. const token = document.cookie.split(';')
  66. .find(cookie => cookie.includes('xsrf_t='))
  67. ?.split('=')[1]?.replace(/"/g, '');
  68.  
  69. if (token) {
  70. const formData = new FormData();
  71. formData.append('_token', token);
  72. formData.append('userName', 'mydealz');
  73. formData.append('message', `Hey Supportteam,\nder User ${username} hat mir folgende Spamnachricht geschickt. Könnt Ihr Euch das bitte einmal ansehen?\n"${messageLong}"`);
  74.  
  75. fetch('https://www.mydealz.de/conversation/send-message', {
  76. method: 'POST',
  77. headers: {
  78. 'X-XSRF-TOKEN': token,
  79. 'X-Requested-With': 'XMLHttpRequest'
  80. },
  81. body: formData
  82. }).then(() => {
  83. window.location.reload();
  84. });
  85. }
  86. }
  87. });
  88. }
  89.  
  90. function observeChanges() {
  91. const observer = new MutationObserver(() => {
  92. const activeMessage = document.querySelector('.conversationList-msg--active');
  93. const replyButton = document.querySelector('[data-t="sendButton"]');
  94. const spamButton = document.querySelector('[data-spam-button]');
  95.  
  96. if (activeMessage && replyButton && !spamButton) {
  97. addSpamButton(replyButton, activeMessage);
  98. }
  99. });
  100.  
  101. observer.observe(document.body, {
  102. childList: true,
  103. subtree: true
  104. });
  105. }
  106.  
  107. if (document.readyState === 'loading') {
  108. document.addEventListener('DOMContentLoaded', () => {
  109. init();
  110. observeChanges();
  111. });
  112. } else {
  113. init();
  114. observeChanges();
  115. }
  116. })();