-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on TsundokuTraducoes. (Any reason we're using hertzen instead of a good CDN for the js?)
- Loading branch information
1 parent
54f80c3
commit 2be5f77
Showing
1 changed file
with
70 additions
and
0 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 |
---|---|---|
@@ -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/[email protected]/dist/html2canvas.min.js'; | ||
document.body.appendChild(script); | ||
}); | ||
`; | ||
return await Engine.Request.fetchUI(request, script, 30000, true); | ||
} | ||
} |