New Instance Button for Libreddit

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

目前为 2023-07-29 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name New Instance Button for Libreddit
  3. // @namespace happyviking
  4. // @version 1.2.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://libreddit.bus-hit.me/*
  14. // @match https://libreddit.cachyos.org/*
  15. // @match https://libreddit.domain.glass/*
  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.northboot.xyz/*
  21. // @match https://libreddit.oxymagnesium.com/*
  22. // @match https://libreddit.privacy.com.de/*
  23. // @match https://libreddit.privacydev.net/*
  24. // @match https://libreddit.tux.pizza/*
  25. // @match https://lr.4201337.xyz/*
  26. // @match https://lr.aeong.one/*
  27. // @match https://lr.artemislena.eu/*
  28. // @match https://lr.riverside.rocks/*
  29. // @match https://r.darklab.sh/*
  30. // @match https://rd.funami.tech/*
  31. // @match https://reddit.baby/*
  32. // @match https://reddit.leptons.xyz/*
  33. // @match https://reddit.moe.ngo/*
  34. // @match https://reddit.smnz.de/*
  35. // @match https://safereddit.com/*
  36. // @match https://snoo.habedieeh.re/*
  37. // <<INSTANCES END HERE>>
  38.  
  39.  
  40. // ==/UserScript==
  41.  
  42. function main() {
  43. const navBar = document.querySelector('nav');
  44. if (!navBar) return
  45. const firstDivInNavBar = navBar.querySelector("div")
  46. const newButton = document.createElement("button")
  47. firstDivInNavBar.prepend(newButton)
  48. newButton.appendChild(document.createTextNode("New Instance"))
  49. newButton.onclick = () => {
  50. console.log("hi")
  51. location.replace('https://farside.link/libreddit/' + window.location.pathname);
  52. }
  53. }
  54.  
  55. main()