Sankaku Paginator Posts Replacer

Removes older posts when newer posts are added by the paginator so your page remains short

  1. // ==UserScript==
  2. // @name Sankaku Paginator Posts Replacer
  3. // @namespace tuktuk3103@gmail.com
  4. // @description Removes older posts when newer posts are added by the paginator so your page remains short
  5. // @include https://chan.sankakucomplex.com/*
  6. // @include https://idol.sankakucomplex.com/*
  7. // @version 1
  8. // @grant none
  9. // @icon https://chan.sankakucomplex.com/favicon.png
  10. // ==/UserScript==
  11.  
  12. // Select the node that will be observed for mutations
  13. const targetNode = document.getElementById('content');
  14.  
  15. // Options for the observer (which mutations to observe)
  16. const config = { attributes: false, childList: true, subtree: true };
  17.  
  18. // Callback function to execute when mutations are observed
  19. const callback = function(mutationsList, observer) {
  20. // Use traditional 'for loops' for IE 11
  21. for(const mutation of mutationsList) {
  22. if (mutation.type === 'childList') {
  23. var page = document.getElementById('content').querySelectorAll('.content-page');
  24. page.length++;
  25. page[page.length-3].remove();
  26. break;
  27. }
  28. }
  29. };
  30.  
  31. // Create an observer instance linked to the callback function
  32. const observer = new MutationObserver(callback);
  33.  
  34. // Start observing the target node for configured mutations
  35. observer.observe(targetNode, config);