New Instance Button for Libreddit

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

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

  1. // ==UserScript==
  2. // @name New Instance Button for Libreddit
  3. // @namespace happyviking
  4. // @version 1
  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. // [Will be automatically updated by Github Actions]
  14. // @match https://reddi.tk/*
  15. // <<INSTANCES END HERE>>
  16.  
  17.  
  18. // ==/UserScript==
  19.  
  20. function main() {
  21. const navBar = document.querySelector('nav');
  22. if (!navBar) return
  23. const firstDivInNavBar = navBar.querySelector("div")
  24. const newButton = document.createElement("button")
  25. firstDivInNavBar.prepend(newButton)
  26. newButton.appendChild(document.createTextNode("New Instance"))
  27. newButton.onclick = () => {
  28. console.log("hi")
  29. location.replace('https://farside.link/libreddit/' + window.location.pathname);
  30. }
  31. }
  32.  
  33. main()