fandom.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. DESCRIPTION:
  3. This is a file that after installing a greasemonkey extension can
  4. be used to convert youtube.com to any invidious instance.
  5. NOTE: I might change this really often because instances may fail.
  6. ----
  7. Copyright (C) 2021 ZortaZert and other contributors
  8. This program is free software: you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation, either version 3 of the License, or (at
  11. your option) any later version.
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. // ==UserScript==
  20. // @name Fandom to Breezewiki
  21. // @namespace Zera's breezewiki redirection script
  22. // @version 1
  23. // @grant none
  24. // @match https://*.fandom.com/*
  25. // @grant none
  26. // @run-at document-start
  27. // ==/UserScript==
  28. BREEZEWIKI_INSTANCE = "antifandom.com"
  29. //fetch('https://corsproxy.io/?https://docs.breezewiki.com/files/instances.json', {
  30. // method: 'GET',
  31. // headers: {
  32. // 'Accept': 'application/json',
  33. // },
  34. //})
  35. //.then(response => response.json())
  36. //.then((data) => {
  37. // let list = []
  38. // data.forEach(function (result) {
  39. // list.push(result.instance)
  40. // })
  41. //});
  42. //console.log(list)
  43. url = location.href
  44. url = url.replace(/\bwww\.\b/, "")
  45. host = location.hostname
  46. path = location.pathname
  47. if (url.includes("/wiki/")) {
  48. // this is bad
  49. location.href = "https://" + BREEZEWIKI_INSTANCE + "/" + host.split(".")[0] + path
  50. }
  51. else {
  52. url = url.replace("fandom.com", BREEZEWIKI_ISNTANCE)
  53. location.href = url
  54. }