Mastodon Auto-Redirect To Home Instance

16/08/2024, 9:48:10 am

  1. // ==UserScript==
  2. // @name Mastodon Auto-Redirect To Home Instance
  3. // @namespace Violentmonkey Scripts
  4. // @grant GM_getValue
  5. // @grant GM_setValue
  6. // @grant GM_registerMenuCommand
  7. // @run-at document-start
  8. // @noframes
  9. // @license MIT
  10. // @version 3.17
  11. // @author CoopCoding
  12. // @description 16/08/2024, 9:48:10 am
  13. // @match *://piraten-partei.social/*
  14. // @match *://androiddev.social/*
  15. // @match *://mastodon.de/*
  16. // @match *://grapheneos.social/*
  17. // @match *://mastodon.matrix.org/*
  18. // @match *://chaosfem.tw/*
  19. // @match *://mastodon.neilzone.co.uk/*
  20. // @match *://mastodon.archive.org/*
  21. // @match *://alpaca.gold/*
  22. // @match *://follow.coryd.dev/*
  23. // @match *://mamot.fr/*
  24. // @match *://soc.kvet.ch/*
  25. // @match *://toot.community/*
  26. // @match *://mastodon.top/*
  27. // @match *://toot.whatever.cz/*
  28. // @match *://martianbase.net/*
  29. // @match *://mastodon.macstories.net/*
  30. // @match *://rustedneuron.com/*
  31. // @match *://botsin.space/*
  32. // @match *://notacult.social/*
  33. // @match *://fedi.computernewb.com/*
  34. // @match *://social.vmbrasseur.com/*
  35. // @match *://posts.rat.pictures/*
  36. // @match *://nondeterministic.computer/*
  37. // @match *://breakpoint.cafe/*
  38. // @match *://social.tchncs.de/*
  39. // @match *://corteximplant.com/*
  40. // @match *://mastodon.oysta.au/*
  41. // @match *://social.data.coop/*
  42. // @match *://vt.social/*
  43. // @match *://mastodon.gamedev.place/*
  44. // @match *://mastodon.sdf.org/*
  45. // @match *://merveilles.town/*
  46. // @match *://tauri.earth/*
  47. // @match *://front-end.social/*
  48. // @match *://allthingstech.social/*
  49. // @match *://x0r.be/*
  50. // @match *://anticapitalist.party/*
  51. // @match *://apobangpo.space/*
  52. // @match *://appdot.net/*
  53. // @match *://archaeo.social/*
  54. // @match *://artsculture.media/*
  55. // @match *://astrodon.social/*
  56. // @match *://attractive.space/*
  57. // @match *://bark.lgbt/*
  58. // @match *://beach.city/*
  59. // @match *://beige.party/*
  60. // @match *://berserker.town/*
  61. // @match *://bikesare.cool/*
  62. // @match *://birds.town/*
  63. // @match *://bitbang.social/*
  64. // @match *://blacktwitter.io/*
  65. // @match *://blobfox.coffee/*
  66. // @match *://body.social/*
  67. // @match *://bookstodon.com/*
  68. // @match *://bookwor.ms/*
  69. // @match *://brands.town/*
  70. // @match *://catcatnya.com/*
  71. // @match *://chatsubo.bar/*
  72. // @match *://chitter.xyz/*
  73. // @match *://climatejustice.social/*
  74. // @match *://cloudisland.nz/*
  75. // @match *://convo.casa/*
  76. // @match *://cooler.mom/*
  77. // @match *://cosmos.social/*
  78. // @match *://cryptodon.lol/*
  79. // @match *://cuddly.space/*
  80. // @match *://cupoftea.social/*
  81. // @match *://cute.is/*
  82. // @match *://cutie.city/*
  83. // @match *://cyberplace.social/*
  84. // @match *://dads.cool/*
  85. // @match *://deadinsi.de/*
  86. // @match *://defcon.social/*
  87. // @match *://demoncore.info/*
  88. // @match *://dice.camp/*
  89. // @match *://digitalcourage.social/*
  90. // @match *://digitaldarkage.cc/*
  91. // @match *://disabled.social/*
  92. // @match *://discuss.systems/*
  93. // @match *://dolphin.town/*
  94. // @match *://drupal.community/*
  95. // @match *://earthstream.social/*
  96. // @match *://ecoevo.social/*
  97. // @match *://econtwitter.net/*
  98. // @match *://eightpoint.app/*
  99. // @match *://emacs.ch/*
  100. // @match *://equestria.social/*
  101. // @match *://fandom.ink/*
  102. // @match *://fediscience.org/*
  103. // @match *://federated.press/*
  104. // @match *://finsup.site/*
  105. // @match *://finsup.social/*
  106. // @match *://flipboard.social/*
  107. // @match *://flipping.rocks/*
  108. // @match *://mastodon.floe.earth/*
  109. // @match *://fluffy.family/*
  110. // @match *://fosstodon.org/*
  111. // @match *://freeradical.zone/*
  112. // @match *://friend.camp/*
  113. // @match *://functional.cafe/*
  114. // @match *://social.funnyna.me/*
  115. // @match *://fur.lgbt/*
  116. // @match *://g33ks.coffee/*
  117. // @match *://gamedev.lgbt/*
  118. // @match *://gamepad.club/*
  119. // @match *://geekdom.social/*
  120. // @match *://genealysis.social/*
  121. // @match *://ghost.cafe/*
  122. // @match *://girlcock.club/*
  123. // @match *://glaceon.social/*
  124. // @match *://glammr.us/*
  125. // @match *://goblin.camp/*
  126. // @match *://hachyderm.io/*
  127. // @match *://hackers.town/*
  128. // @match *://handmade.social/*
  129. // @match *://harrystyl.es/*
  130. // @match *://hci.social/*
  131. // @match *://hcommons.social/*
  132. // @match *://hellyeah.social/*
  133. // @match *://hispagatos.space/*
  134. // @match *://history.lol/*
  135. // @match *://historians.social/*
  136. // @match *://ibite.lol/*
  137. // @match *://icosahedron.website/*
  138. // @match *://idlethumbs.social/*
  139. // @match *://im-in.space/*
  140. // @match *://inaccessible.ac/*
  141. // @match *://indieauthors.social/*
  142. // @match *://indieweb.social/*
  143. // @match *://infosec.exchange/*
  144. // @match *://interfaith.masto.host/*
  145. // @match *://ioc.exchange/*
  146. // @match *://ischool.social/*
  147. // @match *://jorts.horse/*
  148. // @match *://journa.host/*
  149. // @match *://k8s.social/*
  150. // @match *://kind.social/*
  151. // @match *://kinky.business/*
  152. // @match *://kitch.win/*
  153. // @match *://kitty.town/*
  154. // @match *://kosmos.social/*
  155. // @match *://kpop.social/*
  156. // @match *://laserdisc.party/*
  157. // @match *://layer8.space/*
  158. // @match *://legal.social/*
  159. // @match *://lesbianschool.com/*
  160. // @match *://liker.social/*
  161. // @match *://linernotes.club/*
  162. // @match *://livester.net/*
  163. // @match *://lgbt.io/*
  164. // @match *://lgbtqplus.social/*
  165. // @match *://lonely.town/*
  166. // @match *://lor.sh/*
  167. // @match *://magnificentbeardsfan.club/*
  168. // @match *://mapstodon.space/*
  169. // @match *://mas.to/*
  170. // @match *://masto.ai/*
  171. // @match *://masto.social/*
  172. // @match *://mastodon.art/*
  173. // @match *://mastodon.beer/*
  174. // @match *://mastodon.bot/*
  175. // @match *://mastodon.cloud/*
  176. // @match *://mastodon.design/*
  177. // @match *://mastodon.education/*
  178. // @match *://mastodon.energy/*
  179. // @match *://mastodon.green/*
  180. // @match *://mastodon.online/*
  181. // @match *://mastodon.radio/*
  182. // @match *://mastodon.sandwich.net/*
  183. // @match *://mastodon.world/*
  184. // @match *://mastodonbooks.net/*
  185. // @match *://mastodong.lol/*
  186. // @match *://mathtod.online/*
  187. // @match *://mathstodon.xyz/*
  188. // @match *://me.dm/*
  189. // @match *://med-mastodon.com/*
  190. // @match *://mefi.social/*
  191. // @match *://meow.social/*
  192. // @match *://mellified.men/*
  193. // @match *://metalhead.club/*
  194. // @match *://mograph.social/*
  195. // @match *://monocles.social/*
  196. // @match *://moth.social/*
  197. // @match *://mountains.social/*
  198. // @match *://mozilla.social/*
  199. // @match *://mstdn.business/*
  200. // @match *://mstdn.games/*
  201. // @match *://mstdn.io/*
  202. // @match *://mstdn.plus/*
  203. // @match *://mstdn.science/*
  204. // @match *://mstdn.social/*
  205. // @match *://musicworld.social/*
  206. // @match *://nerdculture.de/*
  207. // @match *://neurodifferent.me/*
  208. // @match *://neuromatch.social/*
  209. // @match *://newsie.social/*
  210. // @match *://noc.social/*
  211. // @match *://nullthe.net/*
  212. // @match *://occult.camp/*
  213. // @match *://octodon.social/*
  214. // @match *://ohai.social/*
  215. // @match *://oldbytes.space/*
  216. // @match *://oval.cc/*
  217. // @match *://parasocial.network/*
  218. // @match *://parody.town/*
  219. // @match *://peoplemaking.games/*
  220. // @match *://photog.social/*
  221. // @match *://phpc.social/*
  222. // @match *://plush.city/*
  223. // @match *://pool.social/*
  224. // @match *://social.privacytools.io/*
  225. // @match *://publicsquare.global/*
  226. // @match *://qaf.men/*
  227. // @match *://queer.cool/*
  228. // @match *://queer.garden/*
  229. // @match *://queer.party/*
  230. // @match *://rage.love/*
  231. // @match *://raggedfeathers.com/*
  232. // @match *://rail.chat/*
  233. // @match *://raphus.social/*
  234. // @match *://raru.re/*
  235. // @match *://ravenation.club/*
  236. // @match *://retro.pizza/*
  237. // @match *://retro.social/*
  238. // @match *://retrochat.online/*
  239. // @match *://retro-gaiden.com/*
  240. // @match *://ridetrans.it/*
  241. // @match *://romancelandia.club/*
  242. // @match *://ruby.social/*
  243. // @match *://ruhr.social/*
  244. // @match *://saturation.social/*
  245. // @match *://savageworlds.social/*
  246. // @match *://scholar.social/*
  247. // @match *://scicomm.xyz/*
  248. // @match *://sciencemastodon.com/*
  249. // @match *://sciences.social/*
  250. // @match *://seeds.social/*
  251. // @match *://seo.chat/*
  252. // @match *://seocommunity.social/*
  253. // @match *://shakedown.social/*
  254. // @match *://sinblr.com/*
  255. // @match *://skastodon.com/*
  256. // @match *://smores.town/*
  257. // @match *://snowmans.land/*
  258. // @match *://social.bbc/*
  259. // @match *://social.coop/*
  260. // @match *://social.lol/*
  261. // @match *://socialturtle.eu/*
  262. // @match *://solarsystem.social/*
  263. // @match *://sonomu.club/*
  264. // @match *://spacelase.rs/*
  265. // @match *://spacey.space/*
  266. // @match *://spore.social/*
  267. // @match *://stoat.zone/*
  268. // @match *://strangeobject.space/*
  269. // @match *://stranger.social/*
  270. // @match *://sunbeam.city/*
  271. // @match *://sunny.garden/*
  272. // @match *://switter.at/*
  273. // @match *://tabletop.social/*
  274. // @match *://tech.lgbt/*
  275. // @match *://techhub.social/*
  276. // @match *://tenforward.social/*
  277. // @match *://telescope.garden/*
  278. // @match *://theres.life/*
  279. // @match *://thicc.horse/*
  280. // @match *://toad.social/*
  281. // @match *://toki.social/*
  282. // @match *://toot.bike/*
  283. // @match *://toot.blue/*
  284. // @match *://toot.cafe/*
  285. // @match *://toot.io/*
  286. // @match *://tooot.im/*
  287. // @match *://toque.town/*
  288. // @match *://towns.gay/*
  289. // @match *://transforthe.win/*
  290. // @match *://transportation.social/*
  291. // @match *://trivia.town/*
  292. // @match *://tsukihi.me/*
  293. // @match *://tweesecake.social/*
  294. // @match *://twit.social/*
  295. // @match *://types.pl/*
  296. // @match *://urbanists.social/*
  297. // @match *://unbound.social/*
  298. // @match *://union.place/*
  299. // @match *://universeodon.com/*
  300. // @match *://uwu.town/*
  301. // @match *://veganism.social/*
  302. // @match *://vis.social/*
  303. // @match *://vivaldi.net/*
  304. // @match *://social.vivaldi.net/*
  305. // @match *://vmst.io/*
  306. // @match *://w3c.social/*
  307. // @match *://wandering.shop/*
  308. // @match *://wehavecookies.social/*
  309. // @match *://weirder.earth/*
  310. // @match *://weirdo.network/*
  311. // @match *://weremember.social/*
  312. // @match *://wetdry.world/*
  313. // @match *://wobbl.xyz/*
  314. // @match *://writing.exchange/*
  315. // @match *://xoxo.zone/*
  316. // @match *://yesterweb.org/*
  317. // @match *://social.yesterweb.org/*
  318. // @match *://zeal.center/*
  319. // @match *://zeroes.ca/*
  320. // @match *://zirk.us/*
  321. // @match *://aus.social/*
  322. // @match *://mastodon.au/*
  323. // @match *://social.chinwag.org/*
  324. // @match *://theblower.au/*
  325. // @match *://tyrol.social/*
  326. // @match *://mastodon.com.br/*
  327. // @match *://masto.donte.com.br/*
  328. // @match *://mstdn.ca/*
  329. // @match *://mastodonapp.ca/*
  330. // @match *://thecanadian.social/*
  331. // @match *://oceanplayground.social/*
  332. // @match *://ottawa.place/*
  333. // @match *://mastodont.cat/*
  334. // @match *://chilemasto.casa/*
  335. // @match *://mastodon.cl/*
  336. // @match *://bgme.me/*
  337. // @match *://mastodon.shenenfa.cn/*
  338. // @match *://mastodon.cr/*
  339. // @match *://expressional.social/*
  340. // @match *://norrebro.space/*
  341. // @match *://est.social/*
  342. // @match *://masr.social/*
  343. // @match *://mastodontti.fi/*
  344. // @match *://mstdn.fr/*
  345. // @match *://piaille.fr/*
  346. // @match *://gayfr.social/*
  347. // @match *://toulouse.social/*
  348. // @match *://cultur.social/*
  349. // @match *://kanoa.de/*
  350. // @match *://muenchen.social/*
  351. // @match *://oberpfalz.social/*
  352. // @match *://toot.koeln/*
  353. // @match *://social.saarland/*
  354. // @match *://dresden.network/*
  355. // @match *://machteburch.social/*
  356. // @match *://bonn.social/*
  357. // @match *://darmstadt.social/*
  358. // @match *://norden.social/*
  359. // @match *://wue.social/*
  360. // @match *://augsburg.social/*
  361. // @match *://brandenburg.social/*
  362. // @match *://nrw.social/*
  363. // @match *://osna.social/*
  364. // @match *://social.cologne/*
  365. // @match *://mastodon.hongkongers.net/*
  366. // @match *://mastodon.ie/*
  367. // @match *://mastodon.uno/*
  368. // @match *://pan.rent/*
  369. // @match *://mstdn.jp/*
  370. // @match *://mastodos.com/*
  371. // @match *://mastodon.tokyo/*
  372. // @match *://matitodon.com/*
  373. // @match *://mastodon.mg/*
  374. // @match *://mstdn.mx/*
  375. // @match *://mastodon.nl/*
  376. // @match *://mastonederland.nl/*
  377. // @match *://toot.re/*
  378. // @match *://nederland.online/*
  379. // @match *://mastodon.frl/*
  380. // @match *://tukkers.online/*
  381. // @match *://nwb.social/*
  382. // @match *://hsnl.social/*
  383. // @match *://social.edu.nl/*
  384. // @match *://social.overheid.nl/*
  385. // @match *://mastodon.nz/*
  386. // @match *://mastodon.nzoss.nz/*
  387. // @match *://snabelen.no/*
  388. // @match *://fribygda.no/*
  389. // @match *://oslo.town/*
  390. // @match *://mastodon.babb.no/*
  391. // @match *://tutoteket.no/*
  392. // @match *://mikrobloggen.no/*
  393. // @match *://kjas.no/*
  394. // @match *://samenet.social/*
  395. // @match *://paktodon.asia/*
  396. // @match *://pol.social/*
  397. // @match *://101010.pl/*
  398. // @match *://masto.pt/*
  399. // @match *://mastodon.ml/*
  400. // @match *://mastodon.scot/*
  401. // @match *://glasgow.social/*
  402. // @match *://toot.si/*
  403. // @match *://fediverse.co.za/*
  404. // @match *://jmm.kr/*
  405. // @match *://twingyeo.kr/*
  406. // @match *://mstdn.es/*
  407. // @match *://tkz.one/*
  408. // @match *://mastodon.se/*
  409. // @match *://mastodon.nu/*
  410. // @match *://fikaverse.club/*
  411. // @match *://vattenkylaren.se/*
  412. // @match *://swiss.social/*
  413. // @match *://mastodon.com.tr/*
  414. // @match *://soc.ua-fediland.de/*
  415. // @match *://mastodon.vn.ua/*
  416. // @match *://social.kyiv.dcomm.net.ua/*
  417. // @match *://mastodon.me.uk/*
  418. // @match *://mastodon.org.uk/*
  419. // @match *://mastodonapp.uk/*
  420. // @match *://mcr.wtf/*
  421. // @match *://blop.social/*
  422. // @match *://triangletoot.party/*
  423. // @match *://sfba.social/*
  424. // @match *://social.seattle.wa.us/*
  425. // @match *://theatl.social/*
  426. // @match *://crabland.social/*
  427. // @match *://okla.social/*
  428. // @match *://nycity.social/*
  429. // @match *://masto.nyc/*
  430. // @match *://dmv.community/*
  431. // @match *://az.social/*
  432. // @match *://cityofchicago.live/*
  433. // @match *://nutmeg.social/*
  434. // @match *://better.boston/*
  435. // @match *://toot.boston/*
  436. // @match *://bostonmusic.online/*
  437. // @match *://hoosier.social/*
  438. // @match *://kcmo.social/*
  439. // @match *://nashtodon.com/*
  440. // @match *://denvr.social/*
  441. // @match *://mastodon.uy/*
  442. // @match *://mastodon.social/*
  443. // @match *://toot.wales/*
  444. // @match *://fediverse.party/*
  445. // @match *://lugnasad.eu/*
  446. // @match *://oulipo.social/*
  447. // @match *://tusk.schoollibraries.net/*
  448. // @match *://mastodon.oeru.org/*
  449. // @match *://oeru.org/*
  450. // @match *://akademienl.social/*
  451. // @match *://sotl.social/*
  452. // @match *://koreadon.com/*
  453. // @match *://feedbeat.me/*
  454. // @match *://piano.masto.host/*
  455. // @match *://metalverse.social/*
  456. // @match *://drumstodon.net/*
  457. // @match *://musician.social/*
  458. // @match *://rollenspiel.social/*
  459. // @match *://radiosocial.de/*
  460. // @match *://hamradio.tel/*
  461. // @match *://pl.nudie.social/*
  462. // @match *://prf.me/*
  463. // @match *://makerspace.social/*
  464. // @match *://3dp.chat/*
  465. // @match *://gametoots.de/*
  466. // @match *://mastodon.triggerphra.se/*
  467. // @match *://podvibes.co/*
  468. // @match *://aircrew.rocks/*
  469. // @match *://bahn.social/*
  470. // @match *://toot.pizza/*
  471. // @match *://vkl.world/*
  472. // @match *://mastodon.fedi.bzh/*
  473. // @match *://fairy.id/*
  474. // @match *://gomastodon.cz/*
  475. // @match *://e.fo/*
  476. // @match *://mastodo.fi/*
  477. // @match *://librosphere.fr/*
  478. // @match *://electricrequiem.com/*
  479. // @match *://xn--lofll-1sat.is/*
  480. // @match *://best-friends.chat/*
  481. // @match *://occitania.social/*
  482. // @match *://wspanialy.eu/*
  483. // @match *://mk.phreedom.club/*
  484. // @match *://mastodon.sk/*
  485. // @match *://mastodon.in.th/*
  486. // @match *://jam.xwx.moe/*
  487. // @match *://fedi.garden/*
  488. // @match *://neovibe.app/*
  489. // @match *://qdon.space/*
  490. // @match *://bne.social/*
  491. // @match *://krems.social/*
  492. // @match *://fedi.at/*
  493. // @match *://sbg-social.at/*
  494. // @match *://aut.social/*
  495. // @match *://wokka.be/*
  496. // @match *://mastodon-belgium.be/*
  497. // @match *://witter.cz/*
  498. // @match *://mastodon.bayern/*
  499. // @match *://ruhrpott.social/*
  500. // @match *://fulda.social/*
  501. // @match *://berlin.social/*
  502. // @match *://fem.social/*
  503. // @match *://friendica.a-zwenkau.de/*
  504. // @match *://harz.social/*
  505. // @match *://rheinneckar.social/*
  506. // @match *://moessingen.social/*
  507. // @match *://cas.social/*
  508. // @match *://im.allmendenetz.de/*
  509. // @match *://toot.berlin/*
  510. // @match *://kowelenz.social/*
  511. // @match *://foxyhole.io/*
  512. // @match *://mastodon.holeyfox.co/*
  513. // @match *://malaga.social/*
  514. // @match *://mastodon.free-solutions.org/*
  515. // @match *://mastodon.tn/*
  516. // @match *://lviv.social/*
  517. // @match *://bath.social/*
  518. // @match *://socialclub.nyc/*
  519. // @match *://social.tulsa.ok.us/*
  520. // @match *://gardenstate.social/*
  521. // @match *://techlover.eu/*
  522. // @match *://devschile.social/*
  523. // @match *://gnulinux.social/*
  524. // @match *://technodon.org/*
  525. // @match *://toot.works/*
  526. // @match *://dotnet.social/*
  527. // @match *://jvm.social/*
  528. // @match *://greenhill.zone/*
  529. // @match *://toot.cat/*
  530. // @match *://sauropods.win/*
  531. // @match *://fedisabled.social/*
  532. // @match *://medibubble.org/*
  533. // @match *://bungle.online/*
  534. // @match *://mastodol.jp/*
  535. // @match *://elizur.me/*
  536. // @match *://babka.social/*
  537. // @match *://1689.social/*
  538. // @match *://elonsucks.org/*
  539. // @match *://venera.social/*
  540. // @match *://misskey.de/*
  541. // @match *://social.sp-codes.de/*
  542. // @match *://masto.bike/*
  543. // @match *://blueplanet.social/*
  544. // @match *://en.osm.town/*
  545. // @match *://swiss-chaos.social/*
  546. // @match *://mastodon.mit.edu/*
  547. // @match *://mastodon.librelabucm.org/*
  548. // @match *://mastodon.acc.sunet.se/*
  549. // @match *://social.sunet.se/*
  550. // @match *://social.mpdl.mpg.de/*
  551. // @match *://wisskomm.social/*
  552. // @match *://social.up.edu.ph/*
  553. // @match *://4bear.com/*
  554. // @match *://indiepocalypse.social/*
  555. // @match *://is.nota.live/*
  556. // @match *://lgbtqia.space/*
  557. // @match *://meemu.org/*
  558. // @match *://pipou.academy/*
  559. // @match *://poweredbygay.social/*
  560. // @match *://connectop.us/*
  561. // @match *://blackqueer.life/*
  562. // @match *://wavebird.party/*
  563. // @match *://furry.engineer/*
  564. // @match *://pawb.fun/*
  565. // @match *://pounced-on.me/*
  566. // @match *://pony.social/*
  567. // @match *://derg.social/*
  568. // @match *://krefeld.life/*
  569. // @match *://mastodon.opencloud.lu/*
  570. // @match *://iztasocial.site/*
  571. // @match *://openbiblio.social/*
  572. // @match *://ausglam.space/*
  573. // @match *://floss.social/*
  574. // @match *://linuxrocks.online/*
  575. // @match *://digipres.club/*
  576. // @match *://colorid.es/*
  577. // @match *://tooting.ch/*
  578. // @match *://libretooth.gr/*
  579. // @match *://mastodon.cc/*
  580. // @match *://feuerwehr.social/*
  581. // @match *://mastodon.gougere.fr/*
  582. // @match *://stereodon.social/*
  583. // @match *://solarpunk.moe/*
  584. // @match *://leftist.network/*
  585. // @match *://pcgamer.social/*
  586. // @match *://poliverso.org/*
  587. // @match *://cmdr.social/*
  588. // @match *://recht.social/*
  589. // @match *://medic.cafe/*
  590. // @match *://graz.social/*
  591. // @match *://brettspiel.space/*
  592. // @match *://podcasts.social/*
  593. // @match *://beo.social/*
  594. // @match *://greennuclear.online/*
  595. // @match *://indiehackers.social/*
  596. // @match *://musicians.today/*
  597. // @match *://kalmar.social/*
  598. // @match *://blasmusik.social/*
  599. // @match *://social.bau-ha.us/*
  600. // @match *://poliversity.it/*
  601. // @match *://onlycosplays.social/*
  602. // @match *://mastodon.eus/*
  603. // @match *://xarxa.cloud/*
  604. // @match *://frankfurt.social/*
  605. // @match *://nahe.social/*
  606. // @match *://veterinary.education/*
  607. // @match *://bardown.space/*
  608. // @match *://dz.social/*
  609. // @match *://astronomy.city/*
  610. // @match *://mastodon.africa/*
  611. // @match *://ribeiro.social/*
  612. // ==/UserScript==
  613.  
  614. // List of instances taken from: https://coxy.co/mastodon/ and https://fediverse.party/en/portal/servers/
  615.  
  616. let mastodonHomeInstanceHost = GM_getValue("mastodonHomeInstanceHost")
  617.  
  618. function promptForMastodonInstance(){
  619. let promptVal = prompt("Enter your home mastodon instance url you want to auto-redirect to.")
  620. try{
  621. if(!promptVal.startsWith("https://") && !promptVal.startsWith("http://")){
  622. promptVal = "https://" + promptVal.trim()
  623. }
  624. let u = new URL(promptVal.trim())
  625. GM_setValue("mastodonHomeInstanceHost", u.host)
  626. }catch(err){
  627. alert("Not a valid url.")
  628. }
  629. }
  630.  
  631. if(!mastodonHomeInstanceHost || !URL.canParse(`http://${mastodonHomeInstanceHost}`)) {
  632. promptForMastodonInstance()
  633. }
  634. else {
  635. if(window.location.host !== mastodonHomeInstanceHost){
  636. var url = new URL(window.location.href)
  637. var host = url.host
  638. var pathName = url.pathname
  639. url.host = mastodonHomeInstanceHost
  640. var urlPaths = pathName.split("/")
  641. var isProfileOrPostPage = urlPaths[1].startsWith("@")
  642.  
  643. if(isProfileOrPostPage){
  644. var isPostUrl = urlPaths[2] && urlPaths[2].length > 0 && Number.isInteger(parseInt(urlPaths[2]))
  645. var secondForwardSlashIndex = pathName.indexOf("/", 1)
  646. if(isPostUrl){
  647. // url.pathname = pathName.slice(0, secondForwardSlashIndex) + "@" + host + pathName.slice(secondForwardSlashIndex)
  648. // Need to use this cause the post id is sometimes different when viewed on a different instance. ¯\_(ツ)_/¯
  649. url.href = `https://${mastodonHomeInstanceHost}/authorize_interaction?uri=${encodeURIComponent(window.location.href)}`
  650. }
  651. else {
  652. url.pathname = urlPaths[1] + "@" + host
  653. }
  654. // console.log(url.href)
  655. window.location.href = url.href
  656. }
  657. }
  658. }
  659.  
  660.  
  661.  
  662. GM_registerMenuCommand('Change Your Mastodon Home Instance', promptForMastodonInstance)
  663.  
  664.