New Instance Button for Libreddit

Adds a button to Libreddit instances to redirect to a new instance

As of 2023-08-25. See the latest version.

  1. // ==UserScript==
  2. // @name New Instance Button for Libreddit
  3. // @namespace happyviking
  4. // @version 1.29.0
  5. // @grant none
  6. // @run-at document-end
  7. // @license MIT
  8. // @description Adds a button to Libreddit instances to redirect to a new instance
  9. // @icon https://gitlab.com/uploads/-/system/project/avatar/32545239/libreddit.png
  10. // @author HappyViking
  11.  
  12. // <<INSTANCES START HERE>>
  13. // @match https://l.opnxng.com/*
  14. // @match https://libreddit.bus-hit.me/*
  15. // @match https://libreddit.cachyos.org/*
  16. // @match https://libreddit.freedit.eu/*
  17. // @match https://libreddit.kutay.dev/*
  18. // @match https://libreddit.kylrth.com/*
  19. // @match https://libreddit.lunar.icu/*
  20. // @match https://libreddit.mha.fi/*
  21. // @match https://libreddit.northboot.xyz/*
  22. // @match https://libreddit.oxymagnesium.com/*
  23. // @match https://libreddit.privacydev.net/*
  24. // @match https://libreddit.projectsegfau.lt/*
  25. // @match https://libreddit.pussthecat.org/*
  26. // @match https://libreddit.tiekoetter.com/*
  27. // @match https://libreddit.tux.pizza/*
  28. // @match https://lr.4201337.xyz/*
  29. // @match https://lr.aeong.one/*
  30. // @match https://lr.artemislena.eu/*
  31. // @match https://lr.slipfox.xyz/*
  32. // @match https://lr.vern.cc/*
  33. // @match https://r.darklab.sh/*
  34. // @match https://reddit.dr460nf1r3.org/*
  35. // @match https://reddit.leptons.xyz/*
  36. // @match https://reddit.rtrace.io/*
  37. // @match https://reddit.smnz.de/*
  38. // @match https://reddit.utsav2.dev/*
  39. // @match https://safereddit.com/*
  40. // @match https://snoo.habedieeh.re/*
  41. // <<INSTANCES END HERE>>
  42.  
  43.  
  44. // ==/UserScript==
  45.  
  46. function main() {
  47. const navBar = document.querySelector('nav');
  48. if (!navBar) return
  49. const firstDivInNavBar = navBar.querySelector("div")
  50. const newButton = document.createElement("button")
  51. firstDivInNavBar.prepend(newButton)
  52. newButton.appendChild(document.createTextNode("New Instance"))
  53. newButton.onclick = () => {
  54. console.log("hi")
  55. location.replace('https://farside.link/libreddit/' + window.location.pathname);
  56. }
  57. }
  58.  
  59. main()