Size
7.4 KB
Version
1.1.4
Created
Jan 17, 2026
Updated
18 days ago
1// ==UserScript==
2// @name Extension for nzbs.moe
3// @description A new extension
4// @version 1.1.4
5// @match https://*.nzbs.moe/*
6// @icon https://nzbs.moe/static/img/favicon.svg
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 console.log('Extension initialized on:', window.location.hostname);
12
13 const ANIMEBYTES_API_KEY = 'qDml6cPVnAsuE7AceT6XRKW3rvi4cGsfGXlik6dwZgtnqurWpqWgz8lc';
14
15 async function searchAniList(animeTitle) {
16 const query = `
17 query ($search: String) {
18 Page {
19 media(search: $search, type: ANIME) {
20 id
21 title {
22 romaji
23 english
24 native
25 }
26 }
27 }
28 }
29 `;
30
31 const variables = {
32 search: animeTitle
33 };
34
35 try {
36 const response = await fetch('https://graphql.anilist.co', {
37 method: 'POST',
38 headers: {
39 'Content-Type': 'application/json',
40 'Accept': 'application/json',
41 },
42 body: JSON.stringify({
43 query: query,
44 variables: variables
45 })
46 });
47
48 const data = await response.json();
49
50 if (data.data && data.data.Page && data.data.Page.media && data.data.Page.media.length > 0) {
51 return data.data.Page.media[0].id;
52 }
53
54 return null;
55 } catch (error) {
56 console.error('Error searching AniList:', error);
57 return null;
58 }
59 }
60
61 async function searchAnimeBytes(animeTitle) {
62 try {
63 const encodedTitle = encodeURIComponent(animeTitle);
64 const url = `https://animebytes.tv/scrape.php?torrent_pass=${ANIMEBYTES_API_KEY}&type=anime&searchstr=${encodedTitle}&search_type=title`;
65
66 const response = await fetch(url);
67 const data = await response.json();
68
69 console.log('AnimeBytes search results:', data);
70
71 if (data.Groups && data.Groups.length > 0) {
72 // Return the series ID of the first result
73 return data.Groups[0].SeriesID;
74 }
75
76 return null;
77 } catch (error) {
78 console.error('Error searching AnimeBytes:', error);
79 return null;
80 }
81 }
82
83 function createButton(text, iconClass, backgroundColor, hoverColor) {
84 const button = document.createElement('a');
85 button.href = '#';
86 button.textContent = text;
87 button.style.cssText = `
88 display: inline-flex;
89 align-items: center;
90 gap: 6px;
91 padding: 6px 12px;
92 background-color: ${backgroundColor};
93 color: white;
94 text-decoration: none;
95 border-radius: 4px;
96 font-size: 14px;
97 font-weight: 500;
98 margin-left: 10px;
99 transition: background-color 0.2s;
100 cursor: pointer;
101 `;
102
103 const icon = document.createElement('i');
104 icon.className = iconClass;
105 icon.style.fontSize = '12px';
106 button.appendChild(icon);
107
108 // Hover effect
109 button.addEventListener('mouseenter', () => {
110 button.style.backgroundColor = hoverColor;
111 });
112 button.addEventListener('mouseleave', () => {
113 button.style.backgroundColor = backgroundColor;
114 });
115
116 return button;
117 }
118
119 async function init() {
120 // Get the anime title from the breadcrumb
121 const breadcrumbLink = document.querySelector('.breadcrumb-item.active a[href^="/series/"]');
122
123 if (!breadcrumbLink) {
124 console.log('Anime title not found');
125 return;
126 }
127
128 const animeTitle = breadcrumbLink.textContent.trim();
129 console.log('Found anime title:', animeTitle);
130
131 // Create SeaDex button
132 const seadexButton = createButton('Search on SeaDex', 'fas fa-external-link-alt', '#0d6efd', '#0b5ed7');
133
134 seadexButton.addEventListener('click', async (e) => {
135 e.preventDefault();
136
137 const originalText = seadexButton.textContent;
138 seadexButton.textContent = 'Searching...';
139 seadexButton.style.pointerEvents = 'none';
140
141 try {
142 const anilistId = await searchAniList(animeTitle);
143
144 if (anilistId) {
145 console.log('Found AniList ID:', anilistId);
146 window.open(`https://releases.moe/${anilistId}`, '_blank');
147 } else {
148 console.log('Anime not found on AniList, opening search');
149 window.open('https://releases.moe/', '_blank');
150 }
151 } catch (error) {
152 console.error('Error:', error);
153 window.open('https://releases.moe/', '_blank');
154 } finally {
155 seadexButton.textContent = originalText;
156 seadexButton.style.pointerEvents = 'auto';
157 }
158 });
159
160 // Create AnimeBytes button
161 const animeBytesButton = createButton('Search on AnimeBytes', 'fas fa-external-link-alt', '#dc3545', '#bb2d3b');
162
163 animeBytesButton.addEventListener('click', async (e) => {
164 e.preventDefault();
165
166 const originalText = animeBytesButton.textContent;
167 animeBytesButton.textContent = 'Searching...';
168 animeBytesButton.style.pointerEvents = 'none';
169
170 try {
171 const seriesId = await searchAnimeBytes(animeTitle);
172
173 if (seriesId) {
174 console.log('Found AnimeBytes Series ID:', seriesId);
175 window.open(`https://animebytes.tv/series.php?id=${seriesId}`, '_blank');
176 } else {
177 console.log('Anime not found on AnimeBytes, opening search');
178 const encodedTitle = encodeURIComponent(animeTitle);
179 window.open(`https://animebytes.tv/torrents.php?searchstr=${encodedTitle}&action=advanced&search_type=title`, '_blank');
180 }
181 } catch (error) {
182 console.error('Error:', error);
183 const encodedTitle = encodeURIComponent(animeTitle);
184 window.open(`https://animebytes.tv/torrents.php?searchstr=${encodedTitle}&action=advanced&search_type=title`, '_blank');
185 } finally {
186 animeBytesButton.textContent = originalText;
187 animeBytesButton.style.pointerEvents = 'auto';
188 }
189 });
190
191 // Find a good place to insert the buttons - next to the breadcrumb
192 const breadcrumbContainer = document.querySelector('.breadcrumb-item.active');
193 if (breadcrumbContainer) {
194 breadcrumbContainer.style.display = 'flex';
195 breadcrumbContainer.style.alignItems = 'center';
196 breadcrumbContainer.appendChild(seadexButton);
197 breadcrumbContainer.appendChild(animeBytesButton);
198 console.log('Buttons added successfully');
199 }
200 }
201
202 // Wait for the page to be ready
203 if (document.readyState === 'loading') {
204 document.addEventListener('DOMContentLoaded', init);
205 } else {
206 init();
207 }
208})();