-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX FirstKiss : domain change and new template (#6150)
* FIX FirstKiss : domain change and new template * Update FirstKiss.mjs * Update FirstKiss.mjs
- Loading branch information
Showing
1 changed file
with
67 additions
and
4 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 |
---|---|---|
@@ -1,14 +1,77 @@ | ||
import WordPressMadara from './templates/WordPressMadara.mjs'; | ||
import Connector from '../engine/Connector.mjs'; | ||
import Manga from '../engine/Manga.mjs'; | ||
|
||
export default class FirstKiss extends WordPressMadara { | ||
export default class FirstKiss extends Connector { | ||
|
||
constructor() { | ||
super(); | ||
super.id = 'firstkiss'; | ||
super.label = '1st Kiss Manga'; | ||
super.label = 'LikeManga.io'; | ||
this.tags = ['webtoon', 'english']; | ||
this.url = 'https://1stkissmanga.me'; | ||
this.url = 'https://likemanga.io'; | ||
this.requestOptions.headers.set('x-referer', this.url); | ||
this.requestOptions.headers.set('x-origin', this.url); | ||
} | ||
|
||
async _getMangaFromURI(uri) { | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchDOM(request, 'h1#title-detail-manga'); | ||
return new Manga(this, uri.pathname, data[0].textContent.trim()); | ||
} | ||
|
||
async _getMangas() { | ||
let mangaList = []; | ||
const uri = new URL(this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchDOM(request, 'ul.pagination li:last-of-type a'); | ||
const pageCount = parseInt(data[0].search.match(/(\d+)$/)[1]); | ||
for(let page = 1; page <= pageCount; page++) { | ||
const mangas = await this._getMangasFromPage(page); | ||
mangaList.push(...mangas); | ||
} | ||
return mangaList; | ||
} | ||
|
||
async _getMangasFromPage(page) { | ||
const uri = new URL(`?act=home&pageNum=${page}`, this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchDOM(request, 'div.card-body p.card-text a'); | ||
return data.map(element => { | ||
return { | ||
id: this.getRootRelativeOrAbsoluteLink(element, this.url), | ||
title: element.text.trim() | ||
}; | ||
}); | ||
} | ||
|
||
async _getChapters(manga) { | ||
const chapterList = []; | ||
for (let page = 1, run = true; run; page++) { | ||
const chapters = await this._getChaptersFromPage(manga, page); | ||
chapters.length > 0 ? chapterList.push(...chapters) : run = false; | ||
} | ||
return chapterList; | ||
} | ||
|
||
async _getChaptersFromPage(manga, page) { | ||
const mangaid = manga.id.match(/-(\d+)\/$/)[1]; | ||
const uri = new URL( `?act=ajax&code=load_list_chapter&manga_id=${mangaid}&page_num=${page}`, this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const response = await this.fetchJSON(request); | ||
let data = this.createDOM(response.list_chap); | ||
data = [...data.querySelectorAll( 'li.wp-manga-chapter a' )]; | ||
return data.map(element => { | ||
return { | ||
id: new URL(element.href, request.url).pathname, | ||
title: element.text.trim(), | ||
}; | ||
}); | ||
} | ||
|
||
async _getPages(chapter) { | ||
const uri = new URL(chapter.id, this.url); | ||
const request = new Request(uri, this.requestOptions); | ||
const data = await this.fetchDOM(request, 'div.reading-detail div.page-chapter source'); | ||
return data.map(image => this.createConnectorURI(this.getAbsolutePath(image, request.url))); | ||
} | ||
} |