From 8df6a78d04778e8589b1c6d3c11a01ae0a183768 Mon Sep 17 00:00:00 2001 From: Metacor Date: Wed, 27 Mar 2024 10:59:47 -0500 Subject: [PATCH] fix: livechart-implementation --- README.md | 11 +++++---- package.json | 6 ++--- src/main.js | 48 ++++++++++++++++++++------------------- src/manifest-chrome.json | 2 +- src/manifest-firefox.json | 2 +- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d8cbe90..d2ed267 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index a376ad9..dca057a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.js b/src/main.js index c5fe1f2..03c58de 100644 --- a/src/main.js +++ b/src/main.js @@ -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'; } } diff --git a/src/manifest-chrome.json b/src/manifest-chrome.json index c7c1a6a..d41b4bd 100644 --- a/src/manifest-chrome.json +++ b/src/manifest-chrome.json @@ -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, diff --git a/src/manifest-firefox.json b/src/manifest-firefox.json index a68c231..08ddc18 100644 --- a/src/manifest-firefox.json +++ b/src/manifest-firefox.json @@ -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,