Skip to content

Commit

Permalink
Add Wakanim web integration
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowFish085 committed Apr 19, 2020
1 parent 904b849 commit be9cfe5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
38 changes: 38 additions & 0 deletions src/content-scripts/wakanim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import WebIntegration from '@/utils/WebIntegration';
import * as Enum from '@/utils/Enum';

/**
* Try to get an anime title from the page.
*/
function getAnimeTitle(): string | null {
const titleNode = document.querySelector('body > .SerieV2 meta[itemprop="alternativeHeadline"]');

return titleNode ? titleNode.getAttribute('content') : null;
}

/**
* Try to get an anime display name from the page.
*/
function getDisplayTitle(): string | null {
const titleNode = document.querySelector('body > .SerieV2 meta[itemprop="name"]');

return titleNode ? titleNode.getAttribute('content') : null;
}

async function init() {
try {
if (!(await WebIntegration.isEnabled())) return;

// In case we are on a video page.
if (document.querySelector('body > .SerieV2')) {
const title = getAnimeTitle();

if (title) WebIntegration.displayButton(title, Enum.SearchType.ANIME, getDisplayTitle());
}
}
catch (e) {
console.error(e);
}
}

init();
12 changes: 6 additions & 6 deletions src/manifest_chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"js/content/crunchyroll.js"
]
"matches": ["*://www.crunchyroll.com/*"],
"js": ["js/content/crunchyroll.js"]
},
{
"matches": ["*://www.wakanim.tv/*"],
"js": ["js/content/wakanim.js"]
}
]
}
4 changes: 4 additions & 0 deletions src/manifest_firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
{
"matches": ["*://www.crunchyroll.com/*"],
"js": ["js/content/crunchyroll.js"]
},
{
"matches": ["*://www.wakanim.tv/*"],
"js": ["js/content/wakanim.js"]
}
],
"chrome_settings_overrides": {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/WebIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getHtml(
justify-content: flex-end;
position: fixed;
right: 20px;
z-index: 99999;
z-index: 2147483647;
}
#al-search__button {
Expand Down Expand Up @@ -129,6 +129,10 @@ function getHtml(
padding: 0 12px;
}
#al-search__menu > ul > li {
list-style: none !important;
}
#al-search__menu > ul > li:first-child {
font-weight: bold;
margin-right: 20px;
Expand Down Expand Up @@ -160,6 +164,7 @@ function getHtml(
#al-search__menu > ul > li.action > a > svg {
color: rgb(61,180,242);
vertical-align: initial !important; /* Wakanim */
}
#al-search__arrow {
Expand Down
1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const scripts = {
content: {
// 'script': './src/content-scripts/script.ts',
'crunchyroll': './src/content-scripts/crunchyroll.ts',
'wakanim': './src/content-scripts/wakanim.ts',
},
};

Expand Down

0 comments on commit be9cfe5

Please sign in to comment.