-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
904b849
commit be9cfe5
Showing
5 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters