Open in Miru

Adds a link to open an anime in Miru, if you have MAL-Sync installed then it will be at the bottom of the Quicklinks.

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

  1. // ==UserScript==
  2. // @name Open in Miru
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Adds a link to open an anime in Miru, if you have MAL-Sync installed then it will be at the bottom of the Quicklinks.
  6. // @author WhiteTapeti
  7. // @match https://anilist.co/*
  8. // @icon https://raw.githubusercontent.com/ThaUnknown/miru/master/docs/logo.png
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var functionIsRunning = false;
  14.  
  15. document.body.onload = function() {
  16. if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
  17. setTimeout(function() {
  18. console.log('dsa');
  19. $(`<div style="background: rgb(var(--color-foreground)); border-radius: 3px; display: block; padding: 8px 12px; width: 100%; margin-bottom: 16px; margin-top: 16px; font-size: 1.2rem; position: relative; word-break: break-all;" class="mal_links" id="MiruLinks"> <img width="16" height="16" src="https://github.com/ThaUnknown/miru/raw/master/docs/logo.png"> <span style="font-weight: 500; line-height: 16px; vertical-align: middle;">Miru</span> <div style="margin-top: 5px;" class="miru_links"> <a href="https://miru.watch/anime/` + document.location.href.split('/')[4] + `" target="miruOpen"> ` + document.getElementsByClassName('content')[0].childNodes[0].innerText + ` </a> </div></div><iframe href="about:blank" name="miruOpen" style="visibility:hidden;position:absolute" width="0px" height="0px"></iframe>`).insertBefore(".data");
  20. }, 1500);
  21. }
  22. }
  23.  
  24. window.addEventListener('popstate', (event) => {
  25. if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
  26. setTimeout(function() {
  27. console.log('dsa');
  28. $(`<div style="background: rgb(var(--color-foreground)); border-radius: 3px; display: block; padding: 8px 12px; width: 100%; margin-bottom: 16px; margin-top: 16px; font-size: 1.2rem; position: relative; word-break: break-all;" class="mal_links" id="MiruLinks"> <img width="16" height="16" src="https://github.com/ThaUnknown/miru/raw/master/docs/logo.png"> <span style="font-weight: 500; line-height: 16px; vertical-align: middle;">Miru</span> <div style="margin-top: 5px;" class="miru_links"> <a href="https://miru.watch/anime/` + document.location.href.split('/')[4] + `" target="miruOpen"> ` + document.getElementsByClassName('content')[0].childNodes[0].innerText + ` </a> </div></div><iframe href="about:blank" name="miruOpen" style="visibility:hidden;position:absolute" width="0px" height="0px"></iframe>`).insertBefore(".data");
  29. }, 1500);
  30. }
  31. });
  32.  
  33. window.addEventListener('locationchange', function() {
  34. if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
  35. setTimeout(function() {
  36. console.log('dsa');
  37. $(`<div style="background: rgb(var(--color-foreground)); border-radius: 3px; display: block; padding: 8px 12px; width: 100%; margin-bottom: 16px; margin-top: 16px; font-size: 1.2rem; position: relative; word-break: break-all;" class="mal_links" id="MiruLinks"> <img width="16" height="16" src="https://github.com/ThaUnknown/miru/raw/master/docs/logo.png"> <span style="font-weight: 500; line-height: 16px; vertical-align: middle;">Miru</span> <div style="margin-top: 5px;" class="miru_links"> <a href="https://miru.watch/anime/` + document.location.href.split('/')[4] + `" target="miruOpen"> ` + document.getElementsByClassName('content')[0].childNodes[0].innerText + ` </a> </div></div><iframe href="about:blank" name="miruOpen" style="visibility:hidden;position:absolute" width="0px" height="0px"></iframe>`).insertBefore(".data");
  38. }, 1500);
  39. }
  40. });
  41.  
  42. $(document).click(function() {
  43. if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
  44. setTimeout(function() {
  45. if (document.getElementById("MiruLinks") == null) {
  46. if (!functionIsRunning) {
  47. functionIsRunning = true;
  48. console.log('dsa');
  49. $(`<div style="background: rgb(var(--color-foreground)); border-radius: 3px; display: block; padding: 8px 12px; width: 100%; margin-bottom: 16px; margin-top: 16px; font-size: 1.2rem; position: relative; word-break: break-all;" class="mal_links" id="MiruLinks"> <img width="16" height="16" src="https://github.com/ThaUnknown/miru/raw/master/docs/logo.png"> <span style="font-weight: 500; line-height: 16px; vertical-align: middle;">Miru</span> <div style="margin-top: 5px;" class="miru_links"> <a href="https://miru.watch/anime/` + document.location.href.split('/')[4] + `" target="miruOpen"> ` + document.getElementsByClassName('content')[0].childNodes[0].innerText + ` </a> </div></div><iframe href="about:blank" name="miruOpen" style="visibility:hidden;position:absolute" width="0px" height="0px"></iframe>`).insertBefore(".data");
  50. functionIsRunning = false;
  51.  
  52. }
  53. }
  54. }, 1500);
  55. }
  56. });