Skip to content

Commit

Permalink
Add ADN web integration
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowFish085 committed Sep 11, 2020
1 parent 8938361 commit 2348996
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/content-scripts/adn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable no-param-reassign */
import create from '@/content-scripts/web-integration';

function init(): void {
// In case we are on an anime page.
if (document.querySelector('body .adn-maincontent meta[itemprop="name"]')) {
create({
selector: 'body .adn-maincontent meta[itemprop="name"]',
getValue: (node: HTMLElement) => node.getAttribute('content'),
getTitle: (node: HTMLElement) => node.getAttribute('content'),
appendInPage(node: HTMLElement): void {
node.style.marginBottom = '10px';
node.style.textAlign = 'left';

const target = document.querySelector('body .adn-maincontent .header h1');
if (target) target.prepend(node);

const targetMobile = document.querySelector('body .adn-maincontent .mobile-h1');
if (targetMobile) targetMobile.prepend(node.cloneNode(true));
},
});
}

// In case we are on an anime episode page.
if (document.querySelector('body .adn-maincontent .adn-player-header h1 > a')) {
create({
selector: 'body .adn-maincontent .adn-player-header h1 > a',
appendInPage(node: HTMLElement): void {
node.style.marginBottom = '10px';
node.style.textAlign = 'left';

const target = document.querySelector('body .adn-maincontent .adn-player-header h1');
if (target) target.prepend(node);
},
});
}
}

init();
4 changes: 4 additions & 0 deletions src/manifest_chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
{
"matches": ["*://www.hidive.com/*"],
"js": ["js/content/hidive.js"]
},
{
"matches": ["*://animedigitalnetwork.fr/*"],
"js": ["js/content/adn.js"]
}
]
}
4 changes: 4 additions & 0 deletions src/manifest_firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
{
"matches": ["*://www.hidive.com/*"],
"js": ["js/content/hidive.js"]
},
{
"matches": ["*://animedigitalnetwork.fr/*"],
"js": ["js/content/adn.js"]
}
],
"chrome_settings_overrides": {
Expand Down
1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const scripts = {
wakanim: './src/content-scripts/wakanim.ts',
animelab: './src/content-scripts/animelab.ts',
hidive: './src/content-scripts/hidive.ts',
adn: './src/content-scripts/adn.ts',
},
};

Expand Down

0 comments on commit 2348996

Please sign in to comment.