-
Notifications
You must be signed in to change notification settings - Fork 6
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
fcde7c7
commit 1ae15ba
Showing
7 changed files
with
115 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ import './ntdm9' | |
import './bimiacg' | ||
import './mutean' | ||
import './cycanime' | ||
import './xfani' |
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,8 @@ | ||
.xfani.widescreen { | ||
.header_nav0, | ||
.top-back.hoa, | ||
.fixedGroup { | ||
visibility: hidden; | ||
pointer-events: none; | ||
} | ||
} |
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,44 @@ | ||
import { runtime } from '../../runtime' | ||
import { iframePlayer, runInTop, parser } from './play' | ||
import './index.scss' | ||
|
||
runtime.register({ | ||
domains: ['.xfani.', 'player.moedot'], | ||
opts: [ | ||
{ test: '/watch', run: runInTop }, | ||
{ test: '/watch', run: iframePlayer.runInIframe, runInIframe: true }, | ||
{ | ||
test: () => location.hostname.includes('player.moedot'), | ||
run: parser, | ||
runInIframe: true, | ||
}, | ||
], | ||
search: { | ||
name: '稀饭动漫', | ||
search: (name) => `https://dick.xfani.com/search.html?wd=${name}`, | ||
getSearchName: () => { | ||
return new Promise((resolve) => { | ||
const fn = (e: MessageEvent<any>) => { | ||
if (e.data.key === 'getSearchName') { | ||
resolve(e.data.name) | ||
window.removeEventListener('message', fn) | ||
} | ||
} | ||
window.addEventListener('message', fn) | ||
parent.postMessage({ key: 'getSearchName' }, '*') | ||
}) | ||
}, | ||
getEpisode: () => { | ||
return new Promise((resolve) => { | ||
const fn = (e: MessageEvent<any>) => { | ||
if (e.data.key === 'getEpisode') { | ||
resolve(e.data.name) | ||
window.removeEventListener('message', fn) | ||
} | ||
} | ||
window.addEventListener('message', fn) | ||
parent.postMessage({ key: 'getEpisode' }, '*') | ||
}) | ||
}, | ||
}, | ||
}) |
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,58 @@ | ||
import { KPlayer } from '../../player' | ||
import { execInUnsafeWindow } from '../../utils/execInUnsafeWindow' | ||
import { queryDom } from '../../utils/queryDom' | ||
import { wait } from '../../utils/wait' | ||
import { defineIframePlayer } from '../common/defineIframePlayer' | ||
function getActive() { | ||
return $<HTMLAnchorElement>('.anthology-list-play li.on > a') | ||
} | ||
function switchPart(next: boolean) { | ||
return getActive().parent()[next ? 'next' : 'prev']().find('a')[0]?.href | ||
} | ||
|
||
export function runInTop() { | ||
$('body').addClass('xfani') | ||
$('.player-news').remove() | ||
iframePlayer.runInTop() | ||
} | ||
|
||
export const iframePlayer = defineIframePlayer({ | ||
iframeSelector: '#playleft iframe', | ||
getActive, | ||
setActive: (href) => { | ||
$<HTMLAnchorElement>('.anthology-list-play li a').each((_, el) => { | ||
if (el.href === href) { | ||
el.parentElement!.classList.add('ecnav-dt', 'on') | ||
$('.play-on').insertAfter($(el).find('span')) | ||
} else { | ||
el.parentElement!.classList.remove('ecnav-dt', 'on') | ||
} | ||
}) | ||
}, | ||
search: { | ||
getSearchName: () => $('.player-title-link').text(), | ||
getEpisode: () => getActive().text(), | ||
}, | ||
getEpisodeList: () => $('.anthology-list-play li a'), | ||
switchEpisode: (next) => switchPart(next), | ||
}) | ||
|
||
export async function parser() { | ||
const video = await queryDom<HTMLVideoElement>('video') | ||
|
||
await wait(() => !!video.currentSrc) | ||
let url = video.currentSrc | ||
video.src = '' | ||
|
||
const player = new KPlayer('#player', { | ||
eventToParentWindow: true, | ||
}) | ||
player.src = url | ||
|
||
$('#loading').remove() | ||
|
||
await execInUnsafeWindow(() => { | ||
// @ts-ignore | ||
PlayEr.void.destroy() | ||
}) | ||
} |