Skip to content

Commit

Permalink
add: MAL-additional-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Metacor committed Mar 28, 2024
1 parent 8df6a78 commit 6692532
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nyaa-linker",
"version": "1.2.1",
"version": "1.3.0",
"description": "Adds a button to Anime and Manga database websites that opens a relevant Nyaa search",
"scripts": {
"zip": "npm run firefox && npm run chrome",
Expand Down
60 changes: 35 additions & 25 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,42 @@ const searchNyaa = () => {
};

switch (true) {
case domain.includes(`myanimelist.net/${media}/`):
const engCheck = document.querySelector('.title-english');
engCheck && (titleEng = engCheck.textContent);

if (media === 'manga') {
const titleElm = document.querySelector('[itemprop="name"]');
titleJap = titleElm.textContent;
if (engCheck) {
(engCheck.textContent = ''), (titleJap = titleElm.textContent), (engCheck.textContent = titleEng);
case domain.includes(`myanimelist.net`):
const malMain = new RegExp(`myanimelist\\.net/${media}/\\d+`);
if (malMain.test(domain)) {
const engCheck = document.querySelector('.title-english');
engCheck && (titleEng = engCheck.textContent);

if (media === 'manga') {
const titleElm = document.querySelector('[itemprop="name"]');
titleJap = titleElm.textContent;
if (engCheck) {
(engCheck.textContent = ''), (titleJap = titleElm.textContent), (engCheck.textContent = titleEng);
}
} else {
titleJap = document.querySelector('.title-name > strong').textContent;
}
} else {
titleJap = document.querySelector('.title-name > strong').textContent;

btnSpace = document.getElementById('broadcast-block')
? document.getElementById('broadcast-block')
: document.querySelector('.leftside').children[0];
createBtn();
btn.style.marginTop = '4px';
btn.classList.add('left-info-block-broadcast-button');
}
if (domain.includes(`/genre`) || domain.includes(`/season`) || domain.includes('/magazine')) {
for (const card of document.querySelectorAll('.seasonal-anime')) {
titleJap = card.querySelector('.title').innerText;

btnSpace = document.getElementById('broadcast-block')
? document.getElementById('broadcast-block')
: document.querySelector('.leftside').children[0];
createBtn();
btn.style.marginTop = '4px';
btn.classList.add('left-info-block-broadcast-button');
btnSpace = card.querySelector('.broadcast');
createBtn(btnSpace);
btn.style.background = 'url(https://i.imgur.com/9Fr2BRG.png) center/20px no-repeat';
btn.style.padding = '0 11px';
btn.title = 'Search on Nyaa';
btn.href = `https://nyaa.si/?f=${filter}&c=${category}&q=${titleJap}&s=${sort}&o=${order}`;
btn.target = '_blank';
}
}
break;

case domain.includes(`anime-planet.com/${media}/`):
Expand Down Expand Up @@ -183,10 +199,7 @@ const searchNyaa = () => {

btnSpace = card.querySelector('.lc-anime-card--related-links');
createBtn(btnSpace);
btn.style.backgroundImage = 'url(https://i.imgur.com/9Fr2BRG.png)';
btn.style.backgroundSize = '20px';
btn.style.backgroundRepeat = 'no-repeat';
btn.style.backgroundPosition = 'center';
btn.style.background = 'url(https://i.imgur.com/9Fr2BRG.png) center/20px no-repeat';
btn.classList.add('lc-anime-card--related-links--action-button');
btn.title = 'Search on Nyaa';
btn.href = `https://nyaa.si/?f=${filter}&c=${category}&q=${tempQuery}&s=${sort}&o=${order}`;
Expand All @@ -202,10 +215,7 @@ const searchNyaa = () => {

btnSpace = card.querySelector('.related-links');
createBtn(btnSpace);
btn.style.backgroundImage = 'url(https://i.imgur.com/9Fr2BRG.png)';
btn.style.backgroundSize = '20px';
btn.style.backgroundRepeat = 'no-repeat';
btn.style.backgroundPosition = 'center';
btn.style.background = 'url(https://i.imgur.com/9Fr2BRG.png) center/20px no-repeat';
btn.classList.add('action-button');
btn.title = 'Search on Nyaa';
btn.href = `https://nyaa.si/?f=${filter}&c=${category}&q=${tempQuery}&s=${sort}&o=${order}`;
Expand Down
2 changes: 1 addition & 1 deletion src/manifest-chrome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Nyaa Linker",
"version": "1.2.1",
"version": "1.3.0",
"description": "Adds a button to Anime and Manga database websites that opens a relevant Nyaa search",
"manifest_version": 3,

Expand Down
2 changes: 1 addition & 1 deletion src/manifest-firefox.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Nyaa Linker",
"version": "1.2.1",
"version": "1.3.0",
"description": "Adds a button to Anime and Manga database websites that opens a relevant Nyaa search",
"manifest_version": 2,

Expand Down

0 comments on commit 6692532

Please sign in to comment.