43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
export const hostname = 'nhentai.net';
|
|
export const url = `https://${hostname}/`;
|
|
|
|
export const paths = {
|
|
books: 'g/',
|
|
login: 'login/',
|
|
favorites: 'favorites/',
|
|
};
|
|
|
|
export const downloadLinkId = 'download';
|
|
|
|
export const nextFavoritePageSelector = 'a.next';
|
|
export const coverLinkSelector = 'a.cover';
|
|
export const preTitleSelector = 'h1.title .before';
|
|
export const mainTitleSelector = 'h1.title .pretty';
|
|
export const postTitleSelector = 'h1.title .after';
|
|
export const labeledTagContainerSelector = '.tag-container.field-name';
|
|
export const tagSelector = '.tag';
|
|
export const tagNameSelector = 'span.name';
|
|
|
|
export const tagLabelParodies = 'Parodies';
|
|
export const tagLabelCharacters = 'Characters';
|
|
export const tagLabelTags = 'Tags';
|
|
export const tagLabelArtists = 'Artists';
|
|
export const tagLabelGroups = 'Groups';
|
|
|
|
export function getFavoritePageUrl(page?: number): string {
|
|
return `${url + paths.favorites}${page ? `?page=${page}` : ''}`;
|
|
}
|
|
|
|
export function getBookUrl(galleryId: string): string {
|
|
return `${url}g/${galleryId}/`;
|
|
}
|
|
|
|
export function getGalleryId(bookUrl: string): string {
|
|
const regExpExecArray = /https:\/\/nhentai\.net\/g\/(\d+)/.exec(bookUrl);
|
|
if (regExpExecArray && regExpExecArray[1]) {
|
|
return regExpExecArray[1];
|
|
} else {
|
|
throw new TypeError(`could not get nhentai gallery if from the book url ${bookUrl}`);
|
|
}
|
|
}
|