Skip to content

Commit

Permalink
fix: livechart-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Metacor committed Mar 27, 2024
1 parent 1296624 commit 8df6a78
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 32 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
![](https://i.imgur.com/MVR68qM.jpg)

## What the Extension Does

- Adds a "Search on Nyaa" Button to Anime and Manga pages
- Sites: **[MyAnimeList](https://i.imgur.com/1hymaOS.png), [AniList](https://i.imgur.com/DtNugQF.png), [Kitsu](https://i.imgur.com/TVKqRcK.png), [Anime-Planet](https://i.imgur.com/zohAYbs.png), [AnimeNewsNetwork](https://i.imgur.com/xOYS17r.png), [AniDB](https://i.imgur.com/pRDcUVh.png)**
- Sites: **[MyAnimeList](https://i.imgur.com/1hymaOS.png), [AniList](https://i.imgur.com/DtNugQF.png), [Kitsu](https://i.imgur.com/TVKqRcK.png), [Anime-Planet](https://i.imgur.com/zohAYbs.png), [AnimeNewsNetwork](https://i.imgur.com/xOYS17r.png), [AniDB](https://i.imgur.com/pRDcUVh.png), [LiveChart](https://imgur.com/plZxpBN)**
- Search Parameters can be changed and saved in the [Extension Popup window](https://i.imgur.com/bzaChNf.png)

- For Manga pages, the Category setting will search for the "Literature" equivalent
- All tabs with a supported website currently open will automatically refresh on Save

- By default the search will include both the Japanese(Romaji) & English titles — if they exist, and they are different
- the search will also add the base titles, if they include: ("Season"|"Part"|": "|" - ")
- for example, clicking the button on [Shingeki no Kyojin Season 3 Part 2](https://myanimelist.net/anime/38524/Shingeki_no_Kyojin_Season_3_Part_2) will return the search query:
- _"Shingeki no Kyojin Season 3 Part 2"|"Attack on Titan Season 3 Part 2"|"Shingeki no Kyojin"|"Attack on Titan"_
- _**additional "Query" types are available**: the Default combines both "Exact" and "Base"._
- Fuzzy: Searches for the site's default title only, without quotes ~ allows fuzzy matching
- _"Shingeki no Kyojin Season 3 Part 2"|"Attack on Titan Season 3 Part 2"|"Shingeki no Kyojin"|"Attack on Titan"_
- _**additional "Query" types are available**: the Default combines both "Exact" and "Base"._
- Fuzzy: Searches for the site's default title only, without quotes ~ allows fuzzy matching
- Exact: Japanese and English full titles ~ searches for exact title names as written
- Base: Japanese and English base titles ~ searches with Seasons and Parts removed

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "nyaa-linker",
"version": "1.2.0",
"version": "1.2.1",
"description": "Adds a button to Anime and Manga database websites that opens a relevant Nyaa search",
"scripts": {
"zip": "npm run firefox && npm run chrome",
"firefox": "mv src/manifest-firefox.json src/manifest.json && cd src && zip -r ..\\nyaa-linker-%npm_package_version%-%npm_lifecycle_event%.zip . -x manifest-*.json && cd .. && mv src/manifest.json src/manifest-firefox.json",
"chrome": "mv src/manifest-chrome.json src/manifest.json && cd src && zip -r ..\\nyaa-linker-%npm_package_version%-%npm_lifecycle_event%.zip . -x manifest-*.json && cd .. && mv src/manifest.json src/manifest-chrome.json"
"firefox": "mv src/manifest-firefox.json src/manifest.json && cd src && 7z a ..\\nyaa-linker-%npm_package_version%-%npm_lifecycle_event%.zip * -r -x!manifest-*.json && cd .. && mv src/manifest.json src/manifest-firefox.json",
"chrome": "mv src/manifest-chrome.json src/manifest.json && cd src && 7z a ..\\nyaa-linker-%npm_package_version%-%npm_lifecycle_event%.zip * -r -x!manifest-*.json && cd .. && mv src/manifest.json src/manifest-chrome.json"
},
"devDependencies": {
"eslint": "^8.26.0",
Expand Down
48 changes: 25 additions & 23 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,46 +167,48 @@ const searchNyaa = () => {
case domain.includes('livechart.me'):
setTimeout(() => {
if (domain.includes(`livechart.me/${media}/`)) {
tempEng = document.querySelector('h4 small');
titleEng = tempEng.innerText;
tempEng.textContent = '';
titleJap = document.querySelector('h4').innerText;
tempEng.textContent = titleEng;

btnContainer = document.querySelector('#content > div.row div.text-center');
btnSpace = btnContainer.parentNode.insertBefore(document.createElement('div'), btnContainer);
titleJap = document.querySelector('.grow .text-xl').innerText;
titleEng = document.querySelector('.grow .text-lg').innerText;

btnSpace = document.querySelector('.lc-poster-col');
createBtn(btnSpace);
btn.classList.add('button', 'expanded');
} else if (domain.includes("livechart.me/franchises/")) {
btn.classList.add('lc-btn', 'lc-btn-sm', 'lc-btn-outline');
} else if (domain.includes('livechart.me/franchises/')) {
for (const card of document.querySelectorAll('.lc-anime')) {
titleJap = card.querySelector('.lc-anime-card--title').innerText;
btnContainer = card.querySelector('.lc-anime-card--related-links');
btnSpace = btnContainer.appendChild(document.createElement('li'));
titleJap = card.getAttribute('data-romaji');
titleEng = card.getAttribute('data-english');

let tempQuery;
titleEng == null ? (tempQuery = titleJap) : (tempQuery = `"${titleJap}"|"${titleEng}"`);

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.classList.add('website-icon');

btn.href = `https://nyaa.si/?f=${filter}&c=${category}&q=${titleJap}&s=${sort}&o=${order}`;
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}`;
btn.target = '_blank';
}
} else {
for (const card of document.querySelectorAll('.anime-card')) {
titleJap = card.querySelector('.main-title').innerText;
btnContainer = card.querySelector('.related-links');
btnSpace = btnContainer.appendChild(document.createElement('li'));
for (const card of document.querySelectorAll('.anime')) {
titleJap = card.getAttribute('data-romaji');
titleEng = card.getAttribute('data-english');

let tempQuery;
titleEng == null ? (tempQuery = titleJap) : (tempQuery = `"${titleJap}"|"${titleEng}"`);

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.classList.add('website-icon');

btn.href = `https://nyaa.si/?f=${filter}&c=${category}&q=${titleJap}&s=${sort}&o=${order}`;
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}`;
btn.target = '_blank';
}
}
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.0",
"version": "1.2.1",
"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.0",
"version": "1.2.1",
"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 8df6a78

Please sign in to comment.