Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit 39b7590

Browse files
authored
Merge pull request #6 from robzimpulse/master
Add mangatx plugin
2 parents af95515 + 73ce376 commit 39b7590

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

plugins/mangatx/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Mangatx Plugin
2+
3+
This is the Mango plugin for [MangaTX](https://mangatx.com/) and other wordpress-based manga hosting (ex: [MangaClash](https://mangaclash.com/)]).
4+
5+
Note that
6+
7+
- All downloaded chapters will be placed in their respective series folder in your library.
8+
- Cloudflare rate limits extensive downloads. Adjust `wait_seconds` in `info.json` if you plan to download many chapters in one go (or chapters with many pages).
9+
10+
Maintained by [@robzimpulse](https://github.com/robzimpulse).

plugins/mangatx/index.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
var headers = {
2+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0'
3+
};
4+
5+
var data = []
6+
var pageCount = 0;
7+
8+
function listChapters(url) {
9+
10+
var html = mango.get(url, headers).body
11+
12+
var titleNode = mango.css(html, '.post-title')[0]
13+
14+
var title = mango.text(titleNode).trim()
15+
16+
var chaptersNode = mango.css(html, '.wp-manga-chapter')
17+
18+
var chapters = []
19+
20+
chaptersNode.forEach(function(element) {
21+
var chapterTitleNode = mango.css(element, '[href]')[0]
22+
var chapterTitle = mango.text(chapterTitleNode).trim().split(" ").slice(0, 2).join(" ")
23+
var id = mango.attribute(chapterTitleNode, 'href')
24+
chapters.push({ id: toHex(id), title: chapterTitle })
25+
})
26+
27+
return JSON.stringify({ chapters: chapters, title: title })
28+
}
29+
30+
function selectChapter(id) {
31+
32+
var link = fromHex(id)
33+
34+
var html = mango.get(link, headers).body
35+
36+
var titleNode = mango.css(html, '.main-col h1')[0]
37+
38+
var title = mango.text(titleNode).trim()
39+
40+
var readingContentNode = mango.css(html, '.reading-content .page-break img')
41+
42+
readingContentNode.forEach(function (element) {
43+
var url = mango.attribute(element, 'data-src')
44+
var id = mango.attribute(element, 'id')
45+
data.push({ url: url, id: id })
46+
})
47+
48+
return JSON.stringify({
49+
title: title,
50+
pages: data.length
51+
});
52+
}
53+
54+
function nextPage() {
55+
56+
if (pageCount == data.length) {
57+
return JSON.stringify({});
58+
}
59+
60+
var url = data[pageCount].url
61+
62+
var filename = data[pageCount].id
63+
64+
pageCount += 1;
65+
66+
return JSON.stringify({
67+
url: url,
68+
filename: filename + '.jpg',
69+
headers: headers
70+
});
71+
}
72+
73+
// convert url to hex string
74+
function toHex(s) {
75+
// utf8 to latin1
76+
var s = unescape(encodeURIComponent(s))
77+
var h = ''
78+
for (var i = 0; i < s.length; i++) {
79+
h += s.charCodeAt(i).toString(16)
80+
}
81+
return h
82+
}
83+
84+
// convert hex string to url
85+
function fromHex(h) {
86+
var s = ''
87+
for (var i = 0; i < h.length; i+=2) {
88+
s += String.fromCharCode(parseInt(h.substr(i, 2), 16))
89+
}
90+
return decodeURIComponent(escape(s))
91+
}

plugins/mangatx/info.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "Mangatx",
3+
"title": "Mangatx",
4+
"author": "Robzimpulse - [email protected]",
5+
"version": "v1.0",
6+
"placeholder": "Mangatx manga URL",
7+
"wait_seconds": 5
8+
}

0 commit comments

Comments
 (0)