From ecb835032b5eb4015088c1235790f27ccc877ed8 Mon Sep 17 00:00:00 2001 From: Ignacio Castro Date: Mon, 3 Jul 2023 15:50:37 -0400 Subject: [PATCH] Add GremoryMangas (#5969) * Support for GremoryMangas Based on TsundokuTraducoes. (Any reason we're using hertzen instead of a good CDN for the js?) * [GremoryMangas] Add icon --- src/web/img/connectors/gremorymangas | Bin 0 -> 1819 bytes src/web/mjs/connectors/GremoryMangas.mjs | 70 +++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/web/img/connectors/gremorymangas create mode 100644 src/web/mjs/connectors/GremoryMangas.mjs diff --git a/src/web/img/connectors/gremorymangas b/src/web/img/connectors/gremorymangas new file mode 100644 index 0000000000000000000000000000000000000000..a80b22391daed0fc31177b8dea9d542f54c26497 GIT binary patch literal 1819 zcmV+$2juvPP)5W!FTka)bfi0a0Xz|S7BAu8{{_HL8JoEfmu1G+cP7`(|5P`+6ce!vhXcEDci;i+ecu3XU@8VM zocTd6&%5zAbOX~f^8#DZlNlfQYi2tl=3-*tjlj=w7_ZmsUE`=6h~+d_<7xEQ%|D8h zuqLxPa|`y=Q;ZAD49vzE6~sCvVi#0EH@+tTOX+0JuOxd|$^G=qip*_^?SVNM$R&a~ z(8lV_ts~{+R|FO*5qT4r2QCb($D#k2f}2QPuFQqqIWUx&nfXQHwag`%{>-SrSo}&M z-;Z+%_x`|^z#m4K8u)f7?@hwaz$200VdSU)e$9EAU*az~kU1UKL>6Su%{&p=mKlxn z(Nh=8crdW9%cQ_LftB5o!s`Q@D$q{_zJ=vS_Dn}^Ze~JYN#vQttBG?GziButFe7na zEa7{h#mkW~kqMEUc(UPv%`vS9?0`fqeGbizS;`qq3@kk2p zU~HE=u`%;ZD8Np@EZmaW9eEs|%zQYrCG$d6M^CyV7q-6;I6E^O7@g?^W<>7Ke7#$CySK|`9O@}@gUy4iiyRmDOyugoeIrFl zeW5t$#6WLm4dw(E;E}YfZ1VZU_=b~X3Gvd%TZui1(<1Gf?|ZPmk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F@002ov JPDHLkV1lMrYuW$+ literal 0 HcmV?d00001 diff --git a/src/web/mjs/connectors/GremoryMangas.mjs b/src/web/mjs/connectors/GremoryMangas.mjs new file mode 100644 index 00000000000..78bae961297 --- /dev/null +++ b/src/web/mjs/connectors/GremoryMangas.mjs @@ -0,0 +1,70 @@ +import WordPressMangastream from './templates/WordPressMangastream.mjs'; + +export default class GremoryMangas extends WordPressMangastream { + + constructor() { + super(); + super.id = 'gremorymangas'; + super.label = 'GremoryMangas'; + this.tags = ['spanish', 'scanlation', 'webtoon']; + this.url = 'https://gremorymangas.com'; + this.path = '/manga/list-mode/'; + this.novelContainer = 'div.entry-content'; + this.novelContent = 'div#readerarea.rdminimal'; + //this.novelObstaclesQuery = 'img[src*="Logo-Tsundoku"]'; + this.novelFormat = 'image/png'; + this.novelWidth = '56em';// parseInt(1200 / window.devicePixelRatio) + 'px'; + this.novelPadding = '1.5em'; + } + async _getPages(chapter) { + let request = new Request(new URL(chapter.id, this.url), this.requestOptions); + let data = await this.fetchDOM(request, 'div#readerarea.rdminimal'); + //reader for novel have this class. When its a manga there is no class at all so we call super. + if (data.length == 0) { + return await super._getPages(chapter); + } + let darkmode = Engine.Settings.NovelColorProfile(); + let script =` + new Promise((resolve, reject) => { + document.body.style.width = '${this.novelWidth}'; + document.body.style.backgroundColor = '${darkmode.background}'; + let container = document.querySelector('${this.novelContainer}'); + container.style.maxWidth = '${this.novelWidth}'; + container.style.padding = '0'; + container.style.margin = '0'; + container.style.backgroundColor = '${darkmode.background}'; + + let novel = document.querySelector('${this.novelContent}'); + novel.style.padding = '${this.novelPadding}'; + [...novel.querySelectorAll(":not(:empty)")].forEach(ele => { + ele.style.backgroundColor = '${darkmode.background}' + ele.style.color = '${darkmode.text}' + }); + + novel.style.backgroundColor = '${darkmode.background}' + novel.style.color = '${darkmode.text}'; + document.querySelectorAll('${this.novelObstaclesQuery}').forEach(element => element.style.display = 'none'); + //collect displayed pictures + let pictures = []; + [...novel.querySelectorAll('img.alignnone')].forEach(ele => { + pictures.push(ele.src); + }); + let script = document.createElement('script'); + script.onerror = error => reject(error); + script.onload = async function() { + try { + let canvas = await html2canvas(novel); + pictures.push(canvas.toDataURL('${this.novelFormat}')); + resolve(pictures); + } + catch (error){ + reject(error) + } + } + script.src = 'https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js'; + document.body.appendChild(script); + }); + `; + return await Engine.Request.fetchUI(request, script, 30000, true); + } +} \ No newline at end of file