// ==UserScript==
// @name HiAnime Links
// @namespace forked_bytes
// @match https://hianime.to/*
// @grant none
// @version 1.0.1
// @author forked_bytes
// @license 0BSD
// @description Adds links to MyAnimeList and AniList on HiAnime watch pages
// @downloadURL https://update.greasyfork.icu/scripts/510669/HiAnime%20Links.user.js
// @updateURL https://update.greasyfork.icu/scripts/510669/HiAnime%20Links.meta.js
// ==/UserScript==
const syncData = JSON.parse(document.getElementById('syncData')?.textContent || null);
if (!syncData) return;
const title = document.getElementsByClassName('film-name')[0];
if (!title) return;
if (syncData.mal_id) {
const a = createLink(`https://myanimelist.net/anime/${syncData.mal_id}`, 'MyAnimeList');
a.innerHTML = `
`;
title.appendChild(a);
}
if (syncData.anilist_id) {
const a = createLink(`https://anilist.co/anime/${syncData.anilist_id}`, 'AniList');
a.innerHTML = `
`;
title.appendChild(a);
}
function createLink(href, title) {
const a = document.createElement('a');
a.target = '_blank';
a.rel = 'noreferrer';
a.href = href;
a.title = title;
return a;
}