kemono.su navbar duplicator

Add another navbar to post end

  1. // ==UserScript==
  2. // @name kemono.su navbar duplicator
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Add another navbar to post end
  6. // @match https://kemono.su/*
  7. // @author rainbowflesh
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. let isNavCloned = false;
  16.  
  17. function insertAfter(newNode, referenceNode) {
  18. referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
  19. }
  20.  
  21. function tryCloneAndInsert() {
  22. if (isNavCloned) return;
  23.  
  24. const nav = document.querySelector("nav.post__nav-links");
  25. const body = document.querySelector("div.post__body");
  26.  
  27. if (nav && body) {
  28. const clone = nav.cloneNode(true);
  29. insertAfter(clone, body);
  30. isNavCloned = true;
  31. }
  32. }
  33.  
  34. const observer = new MutationObserver((mutationsList) => {
  35. // Look for the specific target nodes that are added to the DOM
  36. for (let mutation of mutationsList) {
  37. if (mutation.type === 'childList') {
  38. tryCloneAndInsert();
  39. }
  40. }
  41. });
  42.  
  43. observer.observe(document.body, { childList: true, subtree: true });
  44.  
  45. window.addEventListener('load', tryCloneAndInsert);
  46. })();