diff --git a/docs/anime.md b/docs/anime.md index a344f927a..e5c78b45c 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -662,6 +662,12 @@ Sources ## 禁漫天堂 +::: tip 提示 + +禁漫天堂有多个备用域名,本路由默认使用域名 ,若该域名无法访问,可以通过在路由最后加上 `?domain=<域名>` 指定路由访问的域名。如指定备用域名为 ,则在所有禁漫天堂路由最后加上 `?domain=jmcomic1.me` 即可,此时路由为 [`/18comic?domain=jmcomic1.me`](https://rsshub.app/18comic?domain=jmcomic1.me) + +::: + ### 成人 A 漫 diff --git a/lib/v2/18comic/album.js b/lib/v2/18comic/album.js index 0c9ea43a0..070597f7a 100644 --- a/lib/v2/18comic/album.js +++ b/lib/v2/18comic/album.js @@ -2,10 +2,12 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); -const { rootUrl } = require('./utils'); +const { defaultDomain, getRootUrl } = require('./utils'); module.exports = async (ctx) => { const id = ctx.params.id; + const { domain = defaultDomain } = ctx.query; + const rootUrl = getRootUrl(domain, ctx); const currentUrl = `${rootUrl}/album/${id}`; diff --git a/lib/v2/18comic/blogs.js b/lib/v2/18comic/blogs.js index 9b341a690..a62f0e671 100644 --- a/lib/v2/18comic/blogs.js +++ b/lib/v2/18comic/blogs.js @@ -2,10 +2,12 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); -const { rootUrl } = require('./utils'); +const { defaultDomain, getRootUrl } = require('./utils'); module.exports = async (ctx) => { const category = ctx.params.category ?? ''; + const { domain = defaultDomain } = ctx.query; + const rootUrl = getRootUrl(domain, ctx); const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}`; diff --git a/lib/v2/18comic/index.js b/lib/v2/18comic/index.js index 29aa5dd8b..4d1543c9d 100644 --- a/lib/v2/18comic/index.js +++ b/lib/v2/18comic/index.js @@ -1,12 +1,14 @@ -const { rootUrl, ProcessItems } = require('./utils'); +const { defaultDomain, getRootUrl, ProcessItems } = require('./utils'); module.exports = async (ctx) => { const category = ctx.params.category ?? 'all'; const keyword = ctx.params.keyword ?? ''; const time = ctx.params.time ?? 'a'; const order = ctx.params.order ?? 'mr'; + const { domain = defaultDomain } = ctx.query; + const rootUrl = getRootUrl(domain, ctx); const currentUrl = `${rootUrl}/albums${category !== 'all' ? `/${category}` : ''}${keyword ? `?screen=${keyword}` : '?'}${time !== 'a' ? `&t=${time}` : ''}${order !== 'mr' ? `&o=${order}` : ''}`; - ctx.state.data = await ProcessItems(ctx, currentUrl); + ctx.state.data = await ProcessItems(ctx, currentUrl, rootUrl); }; diff --git a/lib/v2/18comic/search.js b/lib/v2/18comic/search.js index dfb537b02..0d5346ae6 100644 --- a/lib/v2/18comic/search.js +++ b/lib/v2/18comic/search.js @@ -1,4 +1,4 @@ -const { rootUrl, ProcessItems } = require('./utils'); +const { defaultDomain, getRootUrl, ProcessItems } = require('./utils'); module.exports = async (ctx) => { const option = ctx.params.option ?? 'photos'; @@ -6,8 +6,10 @@ module.exports = async (ctx) => { const keyword = ctx.params.keyword ?? ''; const time = ctx.params.time ?? 'a'; const order = ctx.params.order ?? 'mr'; + const { domain = defaultDomain } = ctx.query; + const rootUrl = getRootUrl(domain, ctx); const currentUrl = `${rootUrl}/search/${option}${category !== 'all' ? `/${category}` : ''}${keyword ? `?search_query=${keyword}` : '?'}${time !== 'a' ? `&t=${time}` : ''}${order !== 'mr' ? `&o=${order}` : ''}`; - ctx.state.data = await ProcessItems(ctx, currentUrl); + ctx.state.data = await ProcessItems(ctx, currentUrl, rootUrl); }; diff --git a/lib/v2/18comic/utils.js b/lib/v2/18comic/utils.js index 829090d09..0c8071daf 100644 --- a/lib/v2/18comic/utils.js +++ b/lib/v2/18comic/utils.js @@ -3,13 +3,24 @@ const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); const { art } = require('@/utils/render'); const path = require('path'); +const config = require('@/config').value; -const rootUrl = 'https://jmcomic.me'; -// list of address: https://jmcomic1.bet +const defaultDomain = 'jmcomic1.me'; +// list of address: https://jmcomic2.bet +const allowDomain = ['18comic.vip', '18comic.org', 'jmcomic.me', 'jmcomic1.me', 'jm-comic3.art', 'jm-comic.club', 'jm-comic2.ark']; + +const getRootUrl = (domain, ctx) => { + if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.includes(domain)) { + ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); + } + + return `https://${domain}`; +}; module.exports = { - rootUrl, - ProcessItems: async (ctx, currentUrl) => { + defaultDomain, + getRootUrl, + ProcessItems: async (ctx, currentUrl, rootUrl) => { currentUrl = currentUrl.replace(/\?$/, ''); const response = await got(currentUrl);