From dcd63b769dc1e1f35bf42032689e971231ad37e1 Mon Sep 17 00:00:00 2001 From: henrik9999 <22085664+henrik9999@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:48:39 +0200 Subject: [PATCH 1/2] add voidscans --- src/pages/AsuraScans/main.ts | 181 +++++++++++++++++---------------- src/pages/VoidScans/main.ts | 9 ++ src/pages/VoidScans/meta.json | 6 ++ src/pages/VoidScans/style.less | 16 +++ src/pages/VoidScans/tests.json | 31 ++++++ src/pages/pages.ts | 2 + 6 files changed, 159 insertions(+), 86 deletions(-) create mode 100644 src/pages/VoidScans/main.ts create mode 100644 src/pages/VoidScans/meta.json create mode 100644 src/pages/VoidScans/style.less create mode 100644 src/pages/VoidScans/tests.json diff --git a/src/pages/AsuraScans/main.ts b/src/pages/AsuraScans/main.ts index a06c9c1bc3..868128a3c4 100644 --- a/src/pages/AsuraScans/main.ts +++ b/src/pages/AsuraScans/main.ts @@ -1,104 +1,113 @@ import { pageInterface } from '../pageInterface'; -export const AsuraScans: pageInterface = { - name: 'AsuraScans', - domain: ['https://asura.gg', 'https://asurascans.com'], - languages: ['English'], - type: 'manga', - isSyncPage(url) { - if (j.$('#readerarea').length) { - return true; - } - return false; - }, - isOverviewPage(url) { - return j.$('div.thumbook').length > 0 && j.$('div.bixbox.animefull').length > 0; - }, - sync: { - getTitle(url) { - return j.$(j.$('div#content.readercontent div.ts-breadcrumb.bixbox span')[1]).text().trim(); - }, - getIdentifier(url) { - return AsuraScans.overview!.getIdentifier(AsuraScans.sync.getOverviewUrl(url)); +export const AsuraScans: pageInterface = getInter(); + +export function getInter(): pageInterface { + let thisSelf; + /* eslint-disable-next-line prefer-const */ + thisSelf = { + name: 'AsuraScans', + domain: ['https://asura.gg', 'https://asurascans.com'], + languages: ['English'], + type: 'manga', + isSyncPage(url) { + if (j.$('#readerarea').length) { + return true; + } + return false; }, - getOverviewUrl(url) { - return j.$(j.$('div#content.readercontent div.ts-breadcrumb.bixbox a')[1]).attr('href') || ''; + isOverviewPage(url) { + return j.$('div.thumbook').length > 0 && j.$('div.bixbox.animefull').length > 0; }, - getEpisode(url) { - const episodePart = j.$('#chapter > option:selected').text(); + sync: { + getTitle(url) { + return j.$(j.$('div#content.readercontent div.ts-breadcrumb.bixbox span')[1]).text().trim(); + }, + getIdentifier(url) { + return AsuraScans.overview!.getIdentifier(AsuraScans.sync.getOverviewUrl(url)); + }, + getOverviewUrl(url) { + return ( + j.$(j.$('div#content.readercontent div.ts-breadcrumb.bixbox a')[1]).attr('href') || '' + ); + }, + getEpisode(url) { + const episodePart = j.$('#chapter > option:selected').text(); - const temp = episodePart.match(/cha?p?t?e?r?\s*(\d+)/i); + const temp = episodePart.match(/cha?p?t?e?r?\s*(\d+)/i); - if (!temp || temp.length < 2) return 1; + if (!temp || temp.length < 2) return 1; - return Number(temp[1]); - }, - nextEpUrl(url) { - const next = j.$('a.ch-next-btn').attr('href'); + return Number(temp[1]); + }, + nextEpUrl(url) { + const next = j.$('a.ch-next-btn').attr('href'); - if (next === '#/next/') return undefined; + if (next === '#/next/') return undefined; - return next; - }, - }, - overview: { - getTitle(url) { - return j.$('h1.entry-title').text().trim(); - }, - getIdentifier(url) { - return utils.urlPart(url, 4).replace(/^\d+-/gi, ''); - }, - uiSelector(selector) { - j.$('div.bixbox.animefull') - .first() - .after(j.html(`
${selector}
`)); + return next; + }, }, - list: { - offsetHandler: false, - elementsSelector() { - return j.$('div#chapterlist li div.chbox'); + overview: { + getTitle(url) { + return j.$('h1.entry-title').text().trim(); + }, + getIdentifier(url) { + return utils.urlPart(url, 4).replace(/^\d+-/gi, ''); }, - elementUrl(selector) { - return selector.find('a').first().attr('href') || ''; + uiSelector(selector) { + j.$('div.bixbox.animefull') + .first() + .after(j.html(`
${selector}
`)); }, - elementEp(selector) { - const elementEpN = selector.find('span').first().text(); + list: { + offsetHandler: false, + elementsSelector() { + return j.$('div#chapterlist li div.chbox'); + }, + elementUrl(selector) { + return selector.find('a').first().attr('href') || ''; + }, + elementEp(selector) { + const elementEpN = selector.find('span').first().text(); - const temp = elementEpN.match(/chapter \d+/gim); + const temp = elementEpN.match(/chapter \d+/gim); - if (!temp || temp.length === 0) return 0; + if (!temp || temp.length === 0) return 0; - return Number(temp[0].replace(/\D+/g, '')); + return Number(temp[0].replace(/\D+/g, '')); + }, }, }, - }, - init(page) { - api.storage.addStyle( - require('!to-string-loader!css-loader!less-loader!./style.less').toString(), - ); - j.$(document).ready(function () { - if (document.title.includes('Page not found')) { - con.error('404'); - return; - } + init(page) { + api.storage.addStyle( + require('!to-string-loader!css-loader!less-loader!./style.less').toString(), + ); + j.$(document).ready(function () { + if (document.title.includes('Page not found')) { + con.error('404'); + return; + } - if (AsuraScans.isSyncPage(window.location.href)) { - utils.waitUntilTrue( - function () { - if ( - j.$('#chapter > option:selected').length && - j.$('#chapter > option:selected').text() !== 'Select Chapter' - ) - return true; - return false; - }, - function () { - page.handlePage(); - }, - ); - } else { - page.handlePage(); - } - }); - }, -}; + if (AsuraScans.isSyncPage(window.location.href)) { + utils.waitUntilTrue( + function () { + if ( + j.$('#chapter > option:selected').length && + j.$('#chapter > option:selected').text() !== 'Select Chapter' + ) + return true; + return false; + }, + function () { + page.handlePage(); + }, + ); + } else { + page.handlePage(); + } + }); + }, + }; + return thisSelf; +} diff --git a/src/pages/VoidScans/main.ts b/src/pages/VoidScans/main.ts new file mode 100644 index 0000000000..26f71a3583 --- /dev/null +++ b/src/pages/VoidScans/main.ts @@ -0,0 +1,9 @@ +import { pageInterface } from '../pageInterface'; +import { getInter } from '../AsuraScans/main'; + +const clone = getInter(); + +clone.name = 'VoidScans'; +clone.domain = 'https://void-scans.com'; + +export const VoidScans: pageInterface = clone; diff --git a/src/pages/VoidScans/meta.json b/src/pages/VoidScans/meta.json new file mode 100644 index 0000000000..a69cd4dc69 --- /dev/null +++ b/src/pages/VoidScans/meta.json @@ -0,0 +1,6 @@ +{ + "search": "https://void-scans.com/?s={searchtermPlus}", + "urls": { + "match": ["*://void-scans.com/*"] + } +} \ No newline at end of file diff --git a/src/pages/VoidScans/style.less b/src/pages/VoidScans/style.less new file mode 100644 index 0000000000..6a866ffb4a --- /dev/null +++ b/src/pages/VoidScans/style.less @@ -0,0 +1,16 @@ +@import './../pages'; + +@textColor: #b8b8b8; +@inputBackground: #222; + +#malthing { + padding: 10px 15px; +} + +#malp { + span span.info { + color: #d9d9d9 !important; + } + + margin: 0; +} diff --git a/src/pages/VoidScans/tests.json b/src/pages/VoidScans/tests.json new file mode 100644 index 0000000000..6bcde9c35d --- /dev/null +++ b/src/pages/VoidScans/tests.json @@ -0,0 +1,31 @@ +{ + "title": "VoidScans", + "url": "https://void-scans.com", + "testCases": [ + { + "url": "https://void-scans.com/leveling-up-by-only-eating-chapter-101-chosen/", + "expected": { + "sync": true, + "title": "Leveling Up, by Only Eating!", + "identifier": "leveling-up-by-only-eating", + "overviewUrl": "https://void-scans.com/manga/leveling-up-by-only-eating/", + "nextEpUrl": "https://void-scans.com/leveling-up-by-only-eating-chapter-102-pope/", + "episode": 101, + "uiSelector": false + } + }, + { + "url": "https://void-scans.com/manga/leveling-up-by-only-eating/", + "expected": { + "sync": false, + "title": "Leveling Up, by Only Eating!", + "identifier": "leveling-up-by-only-eating", + "uiSelector": true, + "epList": { + "108": "https://void-scans.com/leveling-up-by-only-eating-chapter-108-punk/", + "1": "https://void-scans.com/leveling-up-by-only-eating-chapter-1-ginseng/" + } + } + } + ] + } \ No newline at end of file diff --git a/src/pages/pages.ts b/src/pages/pages.ts index 7fae7394cf..3cabf0e7d8 100644 --- a/src/pages/pages.ts +++ b/src/pages/pages.ts @@ -135,6 +135,7 @@ import { RealmScans } from './RealmScans/main'; import { LuminousScans } from './LuminousScans/main'; import { Animeworld } from './Animeworld/main'; import { MangaBuddy } from './MangaBuddy/main'; +import { VoidScans } from './VoidScans/main'; export const pages = { nineAnime, @@ -274,4 +275,5 @@ export const pages = { LuminousScans, Animeworld, MangaBuddy, + VoidScans, }; From 5b9de7fca4d0f8233c9be2bedc1de2a202085af2 Mon Sep 17 00:00:00 2001 From: henrik9999 <22085664+henrik9999@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:51:23 +0200 Subject: [PATCH 2/2] fix asura test --- src/pages/AsuraScans/tests.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/AsuraScans/tests.json b/src/pages/AsuraScans/tests.json index 766f85ba79..87e0f9cb14 100644 --- a/src/pages/AsuraScans/tests.json +++ b/src/pages/AsuraScans/tests.json @@ -1,28 +1,28 @@ { "title": "AsuraScans", - "url": "https://asurascans.com/", + "url": "https://asura.gg", "testCases": [ { - "url": "https://asurascans.com/sss-class-suicide-hunter-chapter-18/", + "url": "https://asura.gg/sss-class-suicide-hunter-chapter-18/", "expected": { "sync": true, "title": "SSS-Class Suicide Hunter", "identifier": "sss-class-suicide-hunter", - "overviewUrl": "https://asurascans.com/comics/1649969363-sss-class-suicide-hunter/", - "nextEpUrl": "https://asurascans.com/1649969469-sss-class-suicide-hunter-chapter-19/", + "overviewUrl": "https://asura.gg/manga/sss-class-suicide-hunter/", + "nextEpUrl": "https://asura.gg/sss-class-suicide-hunter-chapter-19/", "episode": 18, "uiSelector": false } }, { - "url": "https://asurascans.com/comics/sss-class-suicide-hunter/", + "url": "https://asura.gg/manga/sss-class-suicide-hunter/", "expected": { "sync": false, "title": "SSS-Class Suicide Hunter", "identifier": "sss-class-suicide-hunter", "uiSelector": true, "epList": { - "25": "https://asurascans.com/sss-class-suicide-hunter-chapter-25/" + "25": "https://asura.gg/sss-class-suicide-hunter-chapter-25/" } } }