Advertisement
drchloe

Mewch/Honey Additional Functions Script

Aug 8th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //COMPILED SCRIPTS
  2.  
  3. //SCRIPT OPTIONS
  4. var showposts = 20;
  5. var init = setInterval(function () {
  6.     if(document.getElementsByClassName('fa-cog')[0]){
  7.         go();
  8.         if (window.location.href.indexOf('res') !== -1) {
  9.             clear(); names(document.querySelectorAll('.quoteLink:not(.n)'));
  10.         }
  11.        
  12.     }
  13. }, 500);
  14.  
  15. function go(){
  16.     clearInterval(init);
  17. if (localStorage.getItem("showposts")){
  18.     showposts = localStorage.getItem("showposts");
  19. };
  20. var menu = document.getElementsByClassName('fa-cog')[0];
  21. var label = document.createElement('label');
  22. label.innerHTML = ' / Show Last'
  23. var option = document.createElement('input')
  24. option.type = 'text';
  25. option.style = "width:20px;"
  26. option.value = showposts;
  27. option.addEventListener('change', function(){
  28.     localStorage.setItem("showposts", option.value);
  29. });
  30. label.appendChild(option);
  31. menu.parentNode.appendChild(label);
  32. }
  33.  
  34. //POST WATCHER
  35. var targetNode = document.getElementsByClassName('thread-container')[0];
  36. var config = {childList : true};
  37. var callback = function (mutationsList) {
  38.     for (var mutation of mutationsList) {
  39.         if (mutation.type == 'childList') {
  40.             var quotes = mutation.addedNodes[0].querySelectorAll('.quoteLink')
  41.             names(quotes);
  42.             clear();
  43.         }
  44.     }
  45. };
  46. var observer = new MutationObserver(callback);
  47. observer.observe(targetNode, config);
  48.  
  49.  
  50. //REMOVER
  51. function clear(){
  52. var posts = document.querySelectorAll('.post-container:not(:nth-last-child(-n+'+showposts+')):not(:first-child)'); for (i in posts){posts[i].innerHTML = '';}
  53. document.getElementsByClassName('message-info')[0].innerHTML = '';
  54. }
  55.  
  56.  
  57.  
  58. //DROP ANYWHERE
  59. var dz = document.getElementsByClassName('dropzone')[0];
  60. document.addEventListener('dragover', function(e) {
  61.     dz.style = 'position: fixed;top: 0px;left: 0px;width: 100%;height: 90000px;';
  62. });
  63. dz.addEventListener('dragleave', function(e) {
  64.     dz.style = '';
  65. });
  66. dz.addEventListener('drop', function(e) {
  67.     dz.style = '';
  68. });
  69.  
  70. //IMAGE HOVER
  71. var imagehover = document.createElement('div');
  72. imagehover.style = 'pointer-events:none;z-index:1001;position:fixed;top:20px;right:20px;max-width:90%;height:700px';
  73. imagehover.id = 'imageHover';
  74. document.body.appendChild(imagehover);
  75.  
  76. function hoverImg(e) {
  77.         if (e.parentNode.className.indexOf('expanded') !== -1){
  78.             return;
  79.         }
  80.         var link = e.children[0].href;
  81.         if (e.dataset.mime == 'video/mp4'){
  82.             imagehover.innerHTML = '<video style="width:auto;height:100%;" src="' + link + '" autoplay controls>'
  83.         } else{
  84.             imagehover.innerHTML = '<img style="width:auto;height:100%;" src="' + link + '">'
  85.         }
  86.         e.addEventListener("mouseout", function (e) {
  87.             imagehover.innerHTML = '';
  88.         });
  89. };
  90.  
  91. document.getElementsByClassName('board-container')[0].addEventListener("mouseover", function (e) {
  92.         if(e.path[2].className == 'post-attachment-image'){
  93.             hoverImg(e.path[2])
  94.         }
  95. });
  96.  
  97. //QUOTE NAMES
  98. function names(quotes){
  99.    
  100.     if (quotes && quotes.length > 0){
  101.     for (i in quotes){
  102.         if (!quotes[i].hash){
  103.             return;
  104.         }
  105.         var po = quotes[i].hash.replace('#', '');      
  106.         var name = '';
  107.         var tpo = document.getElementById(po);     
  108.         if (tpo){          
  109.             name = tpo.querySelectorAll('.post-name')[0].innerHTML;
  110.         }
  111.         quotes[i].innerHTML = quotes[i].innerHTML + '<span>  ' + name + '</span>';
  112.         quotes[i].classList.add('n');
  113.     }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement