Skip to content

Commit

Permalink
feat: support new agefans
Browse files Browse the repository at this point in the history
  • Loading branch information
IronKinoko committed Jul 15, 2023
1 parent 2580071 commit 856b7b3
Show file tree
Hide file tree
Showing 27 changed files with 139 additions and 1,098 deletions.
1 change: 1 addition & 0 deletions meta.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// @include https://pro.ascepan.top/*
// @include https://danmu.yhdmjx.com/*
// @include https://www.odcoc.com/*
// @include https://*.sp-flv.com*
// @run-at document-end
// @require https://unpkg.com/[email protected]/dist/jquery.min.js
// @require https://unpkg.com/[email protected]/dist/plyr.min.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"@types/jquery": "^3.5.14",
"@types/lodash-es": "^4.17.6",
"bocchi": "^1.1.1",
"bocchi": "^1.1.3",
"gh-pages": "^3.2.3",
"husky": "^6.0.0",
"lint-staged": "^11.2.6",
Expand Down
17 changes: 13 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/adapter/_iframe_player_parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parser } from './parser'

// 这是个解析器网站,里面只有一个播放器。将其替换成 KPlayer
runtime.register({
domains: ['pro.ascepan.top', 'danmu.yhdmjx.com'],
domains: ['pro.ascepan.top', 'danmu.yhdmjx.com', 'sp-flv.com'],
opts: [
{
test: () => window.location.href.includes('danmu.yhdmjx.com/m3u8.php'),
Expand All @@ -15,6 +15,11 @@ runtime.register({
runInIframe: true,
run: parser['pro.ascepan.top'],
},
{
test: () => !!window.location.href.match(/sp-flv\.com.*url=/),
runInIframe: true,
run: parser['sp-flv.com'],
},
],
search: {
getSearchName: () => {
Expand Down
27 changes: 27 additions & 0 deletions src/adapter/_iframe_player_parser/parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { KPlayer } from '../../player'
import { execInUnsafeWindow } from '../../utils/execInUnsafeWindow'
import { queryDom } from '../../utils/queryDom'
import { wait } from '../../utils/wait'

let player: KPlayer

Expand All @@ -22,4 +23,30 @@ export const parser = {
player = new KPlayer('#player', { eventToParentWindow: true })
player.src = await execInUnsafeWindow(() => window.config.url)
},
'sp-flv.com': async () => {
const video = await queryDom<HTMLVideoElement>('video')

await wait(() => !!video.currentSrc)
let url = video.currentSrc

if (url.startsWith('blob:')) {
url = await execInUnsafeWindow(() => window.video_url)

if (url) {
video.src = ''
player = new KPlayer('#mplayer-media-wrapper', {
eventToParentWindow: true,
})
player.src = url
}
} else {
video.src = ''
player = new KPlayer('#mplayer-media-wrapper', {
eventToParentWindow: true,
})
player.src = url
}

console.log("🚀 ~ file: parser.ts:29 ~ 'vip.sp-flv.com': ~ url:", url)
},
}
47 changes: 0 additions & 47 deletions src/adapter/agefans/index.scss
Original file line number Diff line number Diff line change
@@ -1,47 +0,0 @@
.agefans-wrapper {
.loginout a {
cursor: pointer;
text-decoration: underline;
}
.loginout a + a {
margin-left: 8px;
}
.nav_button {
cursor: pointer;
}
.res_links {
word-break: break-all;
word-wrap: break-word;
}
}

@media (max-width: 576px) {
.nav_button:nth-child(n + 6) {
display: inline-block;
}

#nav {
position: relative;
overflow-x: auto;
white-space: nowrap;
height: 91px;
&::-webkit-scrollbar {
display: none;
}
.nav_button {
white-space: nowrap;
}
}

#top_search_from {
width: calc(100% - 16px);
float: left;
margin-top: 10px;
position: sticky;
left: 8px;
margin: 8px;
}
#new_tip1 {
margin-top: 10px !important;
}
}
24 changes: 2 additions & 22 deletions src/adapter/agefans/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { runtime } from '../../runtime/index'
import './index.scss'
import { detailModule } from './pages/detail'
import { historyModule } from './pages/history'
import { homeModule } from './pages/home'
import { playModule } from './pages/play'
import { rankModule } from './pages/rank'
import { recommendModule } from './pages/recommend'
import { settingModule } from './pages/setting'
import { updateModule } from './pages/update'
import { playModule } from './play'

runtime.register({
domains: ['age.tv', 'agemys', 'agefans', 'agedm'],
Expand All @@ -16,25 +9,12 @@ runtime.register({
test: '*',
run: () => {
$('body').addClass('agefans-wrapper')
if (process.env.NODE_ENV === 'development') {
document.cookie = 'username=admin; path=/; max-age=99999999;'
}

settingModule()
historyModule()
},
},
{ test: '/play', run: playModule },
{ test: '/detail', run: detailModule },
{ test: '/recommend', run: recommendModule },
{ test: '/update', run: updateModule },
{ test: '/rank', run: rankModule },
{ test: /^\/$/, run: homeModule },
],
search: {
name: 'agefans',
search: (name) => `https://www.agemys.net/search?query=${name}&page=1`,
getSearchName: () => $('#detailname a').text(),
getEpisode: () => $("li a[style*='color: rgb(238, 0, 0)']").text(),
search: (name) => `https://www.agefans.com/search?query=${name}`,
},
})
12 changes: 0 additions & 12 deletions src/adapter/agefans/pages/detail.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/adapter/agefans/pages/history.scss

This file was deleted.

Loading

0 comments on commit 856b7b3

Please sign in to comment.