VozHideLongPosts

Chống Rết, Truyện Kiều các kiểu con đà điểu

  1. // ==UserScript==
  2. // @name VozHideLongPosts
  3. // @description Chống Rết, Truyện Kiều các kiểu con đà điểu
  4. // @grant none
  5. // @include *://*vozforums.com/showthread.php?t=*
  6. // @version 0.0.1.20150822071541
  7. // @namespace https://greasyfork.org/users/14513
  8. // ==/UserScript==
  9.  
  10. posts = [].slice.call(document.querySelectorAll('[id^=post_message_]'));
  11. heightLimit = window.innerHeight*2;
  12. hideStr = "Hide this Post";
  13. showStr = "This post has been hidden";
  14. var style = `
  15. .btn-success:hover {
  16. color: #FFF;
  17. background-color: #449D44;
  18. border-color: #398439;
  19. }
  20. .btn-success {
  21. background-color: #5CB85C;
  22. border-color: #4CAE4C;
  23. color: #FFF;
  24. }
  25. .btn {
  26. display: inline-block;
  27. padding: 6px 12px;
  28. margin-bottom: 0px;
  29. font-size: 14px;
  30. font-weight: 400;
  31. line-height: 1.42857;
  32. text-align: center;
  33. white-space: nowrap;
  34. vertical-align: middle;
  35. touch-action: manipulation;
  36. cursor: pointer;
  37. -moz-user-select: none;
  38. background-image: none;
  39. border: 1px solid transparent;
  40. /*border-radius: 4px;*/
  41. }
  42. .btn ~ div{
  43. transition: all .6s;
  44. }
  45. `;
  46. customStyle = document.createElement('style');
  47. customStyle.innerHTML = style;
  48. document.body.appendChild(customStyle);
  49. posts.forEach(function(post,index,array){
  50. if(post.offsetHeight < heightLimit){return;}
  51. parent = post.parentElement;
  52. hideBtn = document.createElement('button');
  53. hideBtn.setAttribute("class","btn btn-success");
  54. if(index !=0){
  55. hideBtn.innerHTML = showStr;
  56. post.style.display = "none";
  57. }
  58. else{
  59. hideBtn.innerHTML = hideStr;
  60. }
  61. hideBtn.addEventListener("click",function(){
  62. if(post.style.display == "none"){
  63. post.style.display = "block";
  64. this.innerHTML = hideStr;
  65. }else{
  66. post.style.display = "none";
  67. this.innerHTML = showStr;
  68. }
  69. })
  70. parent.insertBefore(hideBtn,post);
  71. });