Skip to content

Commit

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

/**
* Display overlay for anime page.
*/
function animePage(): void {
const titleNode = document.querySelector('#main > .content-series2');

const title = titleNode ? titleNode.getAttribute('data-title') : null;

if (title) WebIntegration.displayButton(title, Enum.SearchType.ANIME);
}

/**
* Display overlay for anime episode page.
*/
function animeEpisodePage(): void {
const titleNode = document.querySelector('#video-details h1 > a') as HTMLElement;

const title = titleNode ? titleNode.innerText : null;

if (title) WebIntegration.displayButton(title, Enum.SearchType.ANIME);
}

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

// In case we are on an anime page.
if (document.querySelector('#main > .content-series2')) {
animePage();
}

// In case we are on an anime episode page.
if (document.getElementById('video-details')) {
animeEpisodePage();
}
}
catch (e) {
console.error(e);
}
}

init();
4 changes: 4 additions & 0 deletions src/manifest_chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"matches": ["*://www.crunchyroll.com/*"],
"js": ["js/content/crunchyroll.js"]
},
{
"matches": ["*://www.funimation.com/*"],
"js": ["js/content/funimation.js"]
},
{
"matches": ["*://www.wakanim.tv/*"],
"js": ["js/content/wakanim.js"]
Expand Down
4 changes: 4 additions & 0 deletions src/manifest_firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"matches": ["*://www.crunchyroll.com/*"],
"js": ["js/content/crunchyroll.js"]
},
{
"matches": ["*://www.funimation.com/*"],
"js": ["js/content/funimation.js"]
},
{
"matches": ["*://www.wakanim.tv/*"],
"js": ["js/content/wakanim.js"]
Expand Down
4 changes: 3 additions & 1 deletion src/utils/WebIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function getHtml(
flex-direction: row;
height: 100%;
justify-content: flex-end;
margin: 0;
padding: 0 12px;
}
Expand All @@ -135,7 +136,8 @@ function getHtml(
#al-search__menu > ul > li:first-child {
font-weight: bold;
margin-right: 20px;
margin: 0 20px 0 0;
padding: 0;
white-space: nowrap;
}
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',
'funimation': './src/content-scripts/funimation.ts',
'wakanim': './src/content-scripts/wakanim.ts',
},
};
Expand Down

0 comments on commit cf42d8e

Please sign in to comment.