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.
当前为
// ==UserScript==
// @name Open in Miru
// @namespace http://tampermonkey.net/
// @version 0.1
// @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.
// @author WhiteTapeti
// @match https://anilist.co/*
// @icon https://raw.githubusercontent.com/ThaUnknown/miru/master/docs/logo.png
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant none
// ==/UserScript==
var functionIsRunning = false;
document.body.onload = function() {
if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
setTimeout(function() {
console.log('dsa');
$(`<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");
}, 1500);
}
}
window.addEventListener('popstate', (event) => {
if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
setTimeout(function() {
console.log('dsa');
$(`<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");
}, 1500);
}
});
window.addEventListener('locationchange', function() {
if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
setTimeout(function() {
console.log('dsa');
$(`<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");
}, 1500);
}
});
$(document).click(function() {
if (window.location.href.indexOf('https://anilist.co/anime/') == 0) {
setTimeout(function() {
if (document.getElementById("MiruLinks") == null) {
if (!functionIsRunning) {
functionIsRunning = true;
console.log('dsa');
$(`<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");
functionIsRunning = false;
}
}
}, 1500);
}
});