Historisches Script für Mydealz

https://www.mydealz.de/diskussion/tampermonkey-script-fur-mydealz-2299700

  1. // ==UserScript==
  2. // @name Historisches Script für Mydealz
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0-2024.01.08
  5. // @description https://www.mydealz.de/diskussion/tampermonkey-script-fur-mydealz-2299700
  6. // @author Moritz
  7. // @match https://www.mydealz.de/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=mydealz.de
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. // Konfiguration der Skripteinstellungen
  15.  
  16. const Geizfaktor = 6; // Hier trägst du die Mindestersparniss ein die du haben möchtest, alle deals darunter kannst du entweder einfärben oder mit Geizfaktorvisible ganz ausblenden
  17. const Geizfaktorghost = '0.5'; // hier kannst du einstellen wie "durchsichtig" eingefäbt wird. 0.2 - 0.5 sind hier brauchbare werte
  18. const Geizfaktorvisible ='none'; // 'yes' oder 'none' --> bei none werden deals unterhalb des Geizfaktor ausgeblendet
  19.  
  20. const Maximalpreis = 160; // Maximal akzeptierter Preis für Deals
  21. const Maximalpreisghost = '0.5'; //hier kannst du einstellen wie "durchsichtig" eingefäbt wird. 0.2 - 0.5 sind hier brauchbare werte
  22. const Maximalpreisvisible ='none'; // 'yes' oder 'none' --> bei none werden deals überhalb des Maximalpreis ausgeblendet
  23.  
  24. //const Hotness = 50; // Mindest-Hotness-Wert
  25. const Hotnessghost = '0.5'; // hier kannst du einstellen wie "durchsichtig" eingefäbt wird. 0.2 - 0.5 sind hier brauchbare werte
  26. const Hotnessvisible ='none'; // 'yes' oder 'none' --> bei none werden deals unterhalb einer Hotness ausgeblendet
  27.  
  28. const excludeWords = ['Amazon', 'Film', 'Ps4', 'PlayStation', 'Xbox']; // Wörter, aus dem Titel die ausgeschlossen werden sollen
  29. // const excludeMerchant =['Amazon', 'dm', 'ebay']; // Händler, die ausgeschlossen werden sollen
  30.  
  31. // Ende der Einstellungen
  32.  
  33. // Konvertiert Preis-Strings in numerische Werte
  34. function convertPriceToNumber(priceString) {
  35. let numberString = priceString.replace('€', '').trim();
  36. numberString = numberString.replace(/\./g, '').replace(',', '.');
  37. return parseFloat(numberString);
  38. }
  39. // Überprüft, ob ein Artikel basierend auf dem Titel ausgeschlossen werden soll
  40. function shouldExcludeArticle(article) {
  41. const titleElement = article.querySelector('.thread-title');
  42. if (titleElement) {
  43. return excludeWords.some(word => titleElement.textContent.toLowerCase().includes(word.toLowerCase()));
  44. }
  45. return false;
  46. }
  47. // Hauptfunktion zur Hervorhebung und ggf. Ausblendung von Artikeln exclude words
  48. function highlightDeals(article) {
  49. if (shouldExcludeArticle(article)) {
  50. article.style.display = 'none'; // Artikel ausblenden
  51. return;
  52. }
  53. // Elemente für Originalpreis, reduzierten Preis und Warm-Vote finden
  54. const originalPriceElement = article.querySelector('.mute--text.text--lineThrough');
  55. const reducedPriceElement = article.querySelector('.thread-price');
  56. const warmVoteElement = article.querySelector('.vote-temp--warm'); // könnte man in Zukunft mal abändern das die Temperatur als wert erfasst wird...
  57.  
  58. if (warmVoteElement) {
  59. article.style = `background-color: rgba(0, 0, 255, 0.1); opacity: ${Hotnessghost};`;
  60. article.title = 'Nur "warm" gevoted';
  61. article.style.display = `${Hotnessvisible}`; // Artikel ausblenden über konstanten
  62.  
  63. } else if (originalPriceElement && reducedPriceElement) {
  64. const originalPrice = convertPriceToNumber(originalPriceElement.textContent);
  65. const reducedPrice = convertPriceToNumber(reducedPriceElement.textContent);
  66. const savings = originalPrice - reducedPrice;
  67.  
  68. if (savings < Geizfaktor) {
  69. article.style = `background-color: rgba(255, 121, 0, 0.2); opacity: ${Geizfaktorghost};`;
  70. article.title = `Ersparniss ist weniger als ${Geizfaktor}€`;
  71. article.style.display = `${Geizfaktorvisible}`; // Artikel ausblenden über konstanten
  72. }
  73. }
  74.  
  75. if (reducedPriceElement && !warmVoteElement) {
  76. const priceValue = convertPriceToNumber(reducedPriceElement.textContent);
  77. if (priceValue > Maximalpreis) {
  78. article.style = `background-color: rgba(255, 34, 34, 0.1); opacity: ${Maximalpreisghost};`;
  79. article.title = `Preis ist über Limit von ${Maximalpreis}€`;
  80. article.style.display = `${Maximalpreisvisible}`; // Artikel ausblenden über konstanten
  81. }
  82. }
  83. }
  84. // Verarbeitet alle Artikel auf der Seite
  85. function processArticles() {
  86. const articles = document.querySelectorAll('article');
  87. articles.forEach(highlightDeals);
  88. }
  89. // MutationObserver zur Überwachung von Änderungen im DOM und Ausführung von processArticles bei Änderungen
  90. const observer = new MutationObserver(mutations => {
  91. mutations.forEach(mutation => {
  92. if (mutation.addedNodes && mutation.addedNodes.length > 0) {
  93. processArticles();
  94. }
  95. });
  96. });
  97. // Konfiguration und Start des MutationObservers
  98. const config = { childList: true, subtree: true };
  99. observer.observe(document.body, config);
  100.  
  101. // Erstmalige Ausführung von processArticles
  102. processArticles();
  103. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址