Skip to content

Commit

Permalink
add: customizable-hotkey-plus-code-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Metacor committed Apr 9, 2024
1 parent 6692532 commit 4a1e723
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 328 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
![](https://i.imgur.com/MVR68qM.jpg)
![](https://i.imgur.com/DXMg8ha.png)

## 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), [LiveChart](https://imgur.com/plZxpBN)**
- Search Parameters can be changed and saved in the [Extension Popup window](https://i.imgur.com/bzaChNf.png)
- Adds a "Search on Nyaa" Button to Anime and Manga database pages
- Individual: **[MyAnimeList](https://i.imgur.com/IXJ7XuK.png), [AniList](https://i.imgur.com/9xhFu5q.jpeg), [Anime-Planet](https://i.imgur.com/sGsl0Bw.png), [AnimeNewsNetwork](https://i.imgur.com/xXvJXHC.png), [LiveChart](https://i.imgur.com/VyIWtLC.png), [AniDB](https://i.imgur.com/DqSkmOg.jpeg), [Kitsu](https://i.imgur.com/CN2kh4C.jpeg)**
- Card-type: _**MyAnimeList** ([Season](https://i.imgur.com/7M4hr0z.png), [Genre](https://i.imgur.com/SklbImH.png)), **LiveChart** ([Season](https://i.imgur.com/wvLOp8N.jpeg), [Franchises](https://i.imgur.com/wcNv1JC.jpeg))_
- Extension settings can be customized and saved in the [Extension Popup window](https://i.imgur.com/ymIkV63.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
- The primary settings page is used to change Nyaa search parameters
- For Manga pages, the Category setting will search for the "Literature" equivalent
- The secondary page is used to change extension behavior _(accessed by clicking the cog icon)_
- The Hotkey can be used to activate the button _(even when "Hide Button" is enabled)_
- All browser tabs containing a supported website will refresh after pressing the save button

- 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
- 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
- Additional Query types are available: _"Default" combines "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

- "Default" search 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 search Nyaa for:
- _"Shingeki no Kyojin Season 3 Part 2"|"Attack on Titan Season 3 Part 2"|"Shingeki no Kyojin"|"Attack on Titan"_

# Firefox - [Extension Page](https://addons.mozilla.org/en-US/firefox/addon/nyaa-linker/)

# Chrome - ~~Extension Page~~

> I don't have a Chrome Developer Account, Chrome Users will need to manually install the Extension for now
> I don't have a Chrome Developer Account, Chrome Users will need to manually install the Extension
- Download Chrome.zip from the [Latest Release](https://github.com/Metacor/nyaa-linker/releases)
- [Enable "Developer mode" in Chrome](https://i.imgur.com/h7kvj1h.png)
Expand Down
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.3.0",
"version": "2.0.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
11 changes: 7 additions & 4 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
const cringeSites = ['kitsu.io/*', 'anilist.co/*'];
const skip = ['/episodes', '/chapters', '/characters', '/watch', '/reactions', '/franchise', '/staff', '/reviews', '/stats', '/social'];
for (const site in cringeSites) {
if (changeInfo.status === 'complete' && tab.url.match(cringeSites[site]) && !skip.some((e) => tab.url.includes(e))) {
const manifestSites = chrome.runtime.getManifest().content_scripts[0].matches;
if (changeInfo.status === 'complete') {
if (manifestSites.some((site) => tab.url.match(site.split('*://*.').pop()))) {
chrome.tabs.sendMessage(tabId, { type: 'tabUpdated', url: tab.url });
}
}
Expand All @@ -18,6 +17,10 @@ const defaultSettings = () => {
query_setting: 'default',
sort_setting: 'seeders',
order_setting: 'desc',
hide_button_setting: false,
focus_setting: false,
hotkey_key_setting: '',
hotkey_modifier_setting: '',
},
});
};
Loading

0 comments on commit 4a1e723

Please sign in to comment.