MyDealz Toggle Comments

Adds functionallity to toggles cascaded comments on mydealz.de

  1. // ==UserScript==
  2. // @name MyDealz Toggle Comments
  3. // @namespace http://www.mydealz.de/profile/richi2k
  4. // @version 0.8
  5. // @description Adds functionallity to toggles cascaded comments on mydealz.de
  6. // @author richi2k
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
  8. // @match http://www.mydealz.de/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // BEGIN REQUIRED ONE TIME INIT
  16. // hides all quoted content except those without a header
  17. $(".bbcode_quote_head:not(:empty) ~ .bbcode_quote_body").hide();
  18.  
  19. // sets 'pointer' as cursor to indicate, that the element is clickable
  20. $(".bbcode_quote_head:not(:empty)").css("cursor", "pointer").each(function(){
  21. var onlyText = $(this).siblings(".bbcode_quote_body").clone() //clone the element
  22. .children() //select all the children
  23. .remove() //remove all the children
  24. .end() //again go back to selected element
  25. .text(); //get the text of element
  26. $(this).append( $( '<span class="comment-quote-preview"> - ' + onlyText.substring(0,80) + ' [...] </span>' ) );
  27. });
  28. // END REQUIRED ONE TIME INIT
  29. $(document).on( "click",".bbcode_quote_head", function(){
  30. // toggles the related content area
  31. $(this).siblings(".bbcode_quote_body").slideToggle();
  32. $(this).children(".comment-quote-preview").toggle();
  33. });
  34. //
  35. $(document).on('DOMNodeInserted DOMNodeRemoved',".comments-item", function(event) {
  36. if (event.type == 'DOMNodeInserted') {
  37. // Here we need to set the same things up, that we setup in the one time init section,
  38. // because we get a new set of dom elements
  39. if($(this).hasClass("comments-item")){
  40. $(this).find(".bbcode_quote_head:not(:empty) ~ .bbcode_quote_body").hide();
  41. $(this).find(".bbcode_quote_head:not(:empty)").css("cursor", "pointer");
  42. }
  43. }
  44. });
  45. })();

QingJ © 2025

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