New Instance Button for Libreddit

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

目前为 2023-08-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name New Instance Button for Libreddit
  3. // @namespace happyviking
  4. // @version 1.26.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.freedit.eu/*
  15. // @match https://libreddit.oxymagnesium.com/*
  16. // @match https://libreddit.privacy.com.de/*
  17. // @match https://libreddit.privacydev.net/*
  18. // @match https://libreddit.tux.pizza/*
  19. // @match https://lr.4201337.xyz/*
  20. // @match https://lr.aeong.one/*
  21. // @match https://lr.vern.cc/*
  22. // @match https://r.darklab.sh/*
  23. // @match https://reddit.baby/*
  24. // @match https://reddit.invak.id/*
  25. // @match https://reddit.leptons.xyz/*
  26. // @match https://safereddit.com/*
  27. // @match https://snoo.habedieeh.re/*
  28. // <<INSTANCES END HERE>>
  29.  
  30.  
  31. // ==/UserScript==
  32.  
  33. function main() {
  34. const navBar = document.querySelector('nav');
  35. if (!navBar) return
  36. const firstDivInNavBar = navBar.querySelector("div")
  37. const newButton = document.createElement("button")
  38. firstDivInNavBar.prepend(newButton)
  39. newButton.appendChild(document.createTextNode("New Instance"))
  40. newButton.onclick = () => {
  41. console.log("hi")
  42. location.replace('https://farside.link/libreddit/' + window.location.pathname);
  43. }
  44. }
  45.  
  46. main()