├── Browsers
├── policies.json
├── Images
│ ├── Firefox 01.jpg
│ ├── Firefox 02.jpg
│ ├── Firefox 03.jpg
│ ├── Firefox 04.jpg
│ ├── Firefox 05.jpg
│ ├── Firefox 06.jpg
│ ├── Firefox 07.jpg
│ ├── Firefox 08.jpg
│ ├── Firefox 09.jpg
│ ├── Firefox 10.jpg
│ ├── Firefox 11.jpg
│ ├── Firefox 12.jpg
│ └── Firefox 13.jpg
└── README.md
├── src
├── icons
│ ├── md-128.png
│ ├── md-16.png
│ ├── md-32.png
│ ├── md-48.png
│ ├── md-528.png
│ └── md-96.png
├── clear.js
├── Styles
│ └── md-style.css
├── Scripts
│ ├── kissmanga.js
│ ├── mangafox.js
│ ├── mangatown.js
│ ├── mangapanda.js
│ ├── full-metal-alchemist.js
│ ├── kiryuu.js
│ ├── funmanga.js
│ ├── mangadex.js
│ ├── lovehug.js
│ ├── sektekomik.js
│ ├── readopm.js
│ ├── mangafast.js
│ ├── readblackclover.js
│ ├── loveheaven.js
│ ├── readnaruto.js
│ ├── manhuaus.js
│ ├── readmanhwa.js
│ ├── mangareader.js
│ └── mangasail.js
├── index.js
└── manifest.json
└── README.md
/Browsers/policies.json:
--------------------------------------------------------------------------------
1 | {
2 | "policies": {
3 | "DisableAppUpdate": true
4 | }
5 | }
--------------------------------------------------------------------------------
/src/icons/md-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-128.png
--------------------------------------------------------------------------------
/src/icons/md-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-16.png
--------------------------------------------------------------------------------
/src/icons/md-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-32.png
--------------------------------------------------------------------------------
/src/icons/md-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-48.png
--------------------------------------------------------------------------------
/src/icons/md-528.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-528.png
--------------------------------------------------------------------------------
/src/icons/md-96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/src/icons/md-96.png
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 01.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 02.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 03.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 04.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 05.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 06.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 07.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 07.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 08.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 08.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 09.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 09.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 10.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 11.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 12.jpg
--------------------------------------------------------------------------------
/Browsers/Images/Firefox 13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllaliAdil/Manga-Downloader-Extension/HEAD/Browsers/Images/Firefox 13.jpg
--------------------------------------------------------------------------------
/src/clear.js:
--------------------------------------------------------------------------------
1 | function clearConsole() {
2 | console.API;
3 | if (typeof console._commandLineAPI !== 'undefined') {
4 | console.API = console._commandLineAPI; //chrome
5 | } else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
6 | console.API = console._inspectorCommandLineAPI; //Safari
7 | } else if (typeof console.clear !== 'undefined') {
8 | console.API = console;
9 | }
10 |
11 | console.API.clear();
12 | }
--------------------------------------------------------------------------------
/Browsers/README.md:
--------------------------------------------------------------------------------
1 | # Chrome 80 (Chromium 80)
2 |
3 | windows x64 version
4 | got to https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/722274/
5 | and download "chrome-win.zip" (141.22MB)
6 | unzip and enjoy the protable version
7 |
8 | I used this website to find the version
9 | https://omahaproxy.appspot.com/
10 | you have to get Branch base position (v80.0.3987.87 = 722274) by using the lookup tool
11 | the go to https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
12 | and choose the operating system
13 | then use the filter "722274" to find the folder
14 | then download "chrome-win.zip"
15 |
16 |
17 | # Firefox 86 (how to download and disable updates)
18 |
19 | go to http://releases.mozilla.org/pub/firefox/releases/86.0/
20 |
21 | Choose your operatin system
22 | 
23 |
24 | Choose a language
25 | 
26 |
27 | Download the file
28 | 
29 |
30 | Installation steps
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 |
38 | go to "Mozilla Firefox 86" folder and create new folder "distribution"
39 | 
40 |
41 | download and move "policies.json" file inside
42 | 
43 |
44 | Launch Firefox
45 | 
46 |
47 | Click the menu button Menu(3 horizontal lines), click Help and select About Firefox
48 | 
49 |
--------------------------------------------------------------------------------
/src/Styles/md-style.css:
--------------------------------------------------------------------------------
1 | .md-download-button {
2 | border: 1px solid #1d1d1d;
3 | background-color: #f4f4f4;
4 | color: #000000;
5 | padding: 0 10px;
6 | }
7 |
8 | .md-download-button:hover {
9 | border: 1px solid #000000;
10 | background-color: #dfdfdf;
11 | color: #000000;
12 | }
13 |
14 | .md-download-button:disabled,
15 | .md-download-button[disabled]{
16 | border: 1px solid #999999;
17 | background-color: #999999;
18 | color: #666666;
19 | }
20 |
21 | .md-mangakakalot-highlight:hover {
22 | background: rgba(255, 115, 0, 0.09);
23 | }
24 |
25 | .md-highlight:hover {
26 | background: rgba(255, 255, 255, 0.274);
27 | }
28 |
29 | .md-float-modal {
30 | display: none; /* Hidden by default */
31 | position: fixed; /* Stay in place */
32 | z-index: 999; /* Sit on top */
33 | left: 50%;
34 | top: 50%;
35 | transform: translate(-50%, -50%);
36 | width: 100%; /* Full width */
37 | background-color: rgb(0,0,0); /* Fallback color */
38 | background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
39 | }
40 |
41 | /* Modal Content/Box */
42 | .md-float-modal-content {
43 | background-color: #fefefe;
44 | margin: 15% auto; /* 15% from the top and centered */
45 | padding: 20px;
46 | border: 1px solid #888;
47 | width: 80%; /* Could be more or less, depending on screen size */
48 | }
49 |
50 | /* The Close Button */
51 | .md-float-close {
52 | color: #aaa;
53 | float: right;
54 | font-size: 28px;
55 | font-weight: bold;
56 | }
57 |
58 | .md-float-close:hover,
59 | .md-float-close:focus {
60 | color: black;
61 | text-decoration: none;
62 | cursor: pointer;
63 | }
64 |
65 | /* The batch download Progress bar */
66 | .md-progress-container {
67 | width: 100%;
68 | background-color: grey;
69 | margin-top: 10px;
70 | }
71 |
72 | .md-progress-bar {
73 | width: 0%;
74 | height: 30px;
75 | background-color: #4CAF50;
76 | text-align: center; /* To center it horizontally (if you want) */
77 | line-height: 30px; /* To center it vertically */
78 | color: white;
79 | }
80 |
81 | /* all chapter list in select */
82 | #md-float-chapter-list {
83 | width: 100%;
84 | margin-top: 10px;
85 | }
86 |
87 | .md-qiman6-chapter {
88 | display: inline-block;
89 | border: 1px solid #dadada;
90 | margin-left: 20px;
91 | margin-top: 15px;
92 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IMPORTANT NOTE
2 | -New websites will not be add for now. The SOURCE CODE is available, you can add the websites you want.
3 |
4 | # Manga-Downloader-Extension
5 | Chrome/Firefox extension to download Manga/Manhua/Manhwa/Webtoons/Comics chapters as PDF/ZIP(images) from many websites.
6 |
7 |
8 |
9 | # How to install (Chromium 80 / Firefox 86)
10 | https://github.com/AllaliAdil/Manga-Downloader-Extension/tree/main/Browsers
11 |
12 | # Chrome 80 or less
13 | https://chrome.google.com/webstore/detail/manga-downloader/fojcpnmhelbpakmgaakfhjlmjokocgjg
14 |
15 | # FireFox
16 | https://addons.mozilla.org/en-US/firefox/addon/manga-downloader/
17 |
18 | # Supported Websites
19 | -The source code is available, you can add the websites you want.
20 |
21 | -mangakiss.org
22 | -mangakomi.com
23 | -mangakakalot.com
24 | -manganelo.com
25 | -readnaruto.com (Naruto & Boruto)
26 | -tokyoghoulre.com
27 | -readhaikyuu.com
28 | -readopm.com (One Punch Man)
29 | -readonepiece.com
30 | -readsnk.com (Shingeki no Kyojin)
31 | -readfairytail.com
32 | -readblackclover.com
33 | -readbleachmanga.com
34 | -readneverland.com
35 | -readnoblesse.com
36 | -readkingdom.com
37 | -readtowerofgod.com
38 | -readvinlandsaga.com
39 | -readmha.com (My Hero Academia)
40 | -readkaguyasama.com
41 | -readjujutsukaisen.com
42 | -readchainsawman.com
43 | -demonslayermanga.com
44 | -read7deadlysins.com
45 | -readsololeveling.org
46 | -readhxh.com (Hunter X Hunter)
47 | -readberserk.com
48 | -readdrstone.com
49 | -dbsmanga.com (Dragon Ball Super)
50 | -rawdevart.com
51 | -mangasee123.com
52 | -webtoons.com
53 | -manga4life.com
54 | -mangafort.com
55 | -1stkissmanga.com
56 | -mangasail.co
57 | -mangatail.me (redirect to www.mangasaki.com)
58 | -www.mangasaki.com
59 | -zinmanga.com
60 | -365manga.com
61 | -toonily.net
62 | -manhuaus.com
63 | -mangatx.com
64 | -readmanhwa.com
65 | -mangatown.com
66 | -www.qiman6.com
67 | -qingman5.com
68 | -full-metal-alchemist.com
69 | -manhuaplus.com
70 | -mangaclash.com
71 | -www.funmanga.com
72 | -www.mngdoom.com
73 | -www.mangainn.net
74 | -mangafast.net
75 | -kissaway.net
76 |
77 | -kissmanga.com (Terminated)
78 | -mangareader.net (Not working)
79 | -mangapanda.com (Not working)
80 | -ww3.mangafox.online (most of the images don't show)
81 |
82 |
83 | ## Thank you to the awesome backers via Patreon
84 |
85 | -Nicole Marie T. Ma-amo
86 | -Anne Marrie
87 | -innesfree
88 | -kelvin
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/src/Scripts/kissmanga.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This website is Terminated
3 | * only .com is legit
4 | */
5 | function kissmangaF() {
6 | // check if viewing chapters list page
7 | if(document.querySelector("div.chapterList table.listing") !== null){
8 | addNote();
9 | }
10 |
11 | if(document.querySelector("select#selectReadType") !== null){
12 | //check reading type
13 | let readingType = document.querySelector("select#selectReadType").selectedOptions[0].text;
14 | if(readingType === "All pages"){
15 | addDownloadButtons();
16 | }
17 | else{
18 | let downloadNote = document.createElement("span");
19 | downloadNote.style.cssText = "font-weight: bold;font-size: large;color: red;";
20 | downloadNote.textContent = "(Manga Downloader) to download this chapter change the reading type to \"All pages\"";
21 | let container = document.querySelector("div#divImage").parentNode;
22 | container.insertBefore(downloadNote,container.firstChild);
23 | return;
24 | }
25 | }
26 | // add a note for users
27 | function addNote(){
28 | let chapterList = document.querySelector("div.chapterList table.listing").parentNode;
29 | let note = document.createElement("span");
30 | note.style.fontSize = "x-large";
31 | chapterList.insertBefore(note,chapterList.querySelector("table.listing"));
32 | }
33 | // add download buttons
34 | function addDownloadButtons(){
35 | let pdfButton = document.createElement("button");
36 | let zipButton = document.createElement("button");
37 | pdfButton.style.width = "50px";
38 | zipButton.style.width = "50px";
39 | pdfButton.id = "pdfButtonId";
40 | zipButton.id = "zipButtonId";
41 | pdfButton.textContent = "pdf";
42 | zipButton.textContent = "zip";
43 | // disable the button until all images loads
44 | pdfButton.disabled = "true";
45 | zipButton.disabled = "true";
46 |
47 | let title;
48 | if(document.querySelector("select.selectChapter") !== null){
49 | title = document.querySelector("select.selectChapter").selectedOptions[0].text;
50 | }
51 | else{
52 | title = document.querySelector("select#selectChapter").selectedOptions[0].text;
53 | }
54 |
55 | pdfButton.title = title;
56 | zipButton.title = title;
57 |
58 | let buttonsHolder = document.createElement("span");
59 | buttonsHolder.appendChild(pdfButton);
60 | buttonsHolder.appendChild(zipButton);
61 | let hint = document.createElement("span");
62 | hint.textContent = " Wait for all images to load";
63 | buttonsHolder.appendChild(hint);
64 |
65 | let container = document.querySelector("div#divImage").parentNode;
66 | container.insertBefore(buttonsHolder,container.firstChild);
67 |
68 | if (document.readyState == "complete") {
69 | hint.remove();
70 | getImages();
71 | }
72 | else{
73 | window.addEventListener('load', function () {
74 | hint.remove();
75 | getImages();
76 | });
77 | }
78 | }
79 |
80 | function getImages(){
81 | let pdfButton = document.querySelector("button#pdfButtonId");
82 | let zipButton = document.querySelector("button#zipButtonId");
83 | pdfButton.imgs = [];
84 | zipButton.imgs = [];
85 | let imgs = document.querySelectorAll("div#divImage img");
86 | for(let img of imgs){
87 | pdfButton.imgs.push(img.src);
88 | zipButton.imgs.push(img.src);
89 | }
90 | pdfButton.removeAttribute("disabled");
91 | zipButton.removeAttribute("disabled");
92 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
93 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/Scripts/mangafox.js:
--------------------------------------------------------------------------------
1 | function mangafoxF() {
2 | // to store links of each chapter
3 | let links = [];
4 | // get all chapters displayed in the table
5 | let chapterList;
6 | // get all the rows
7 | let rows;
8 | // to store download button for easy access
9 | let pdfButtons = [];
10 | let zipButtons = [];
11 | // check if viewing chapters list page
12 | if(document.querySelector("div.manga_chapter_list") !== null){
13 | chapterList = document.querySelector("div.manga_chapter_list");
14 | // get all the rows
15 | rows = chapterList.querySelectorAll("ul > li");
16 | // hide views column
17 | let el = document.querySelectorAll("div.chapter_time");
18 | for(let e of el){
19 | e.style.display = "none";
20 | }
21 |
22 | // calling function
23 | addNote();
24 | addDownloadHeader();
25 | addDownloadButtons();
26 | }
27 | // add a note for users
28 | function addNote(){
29 | let chapterDiv = document.querySelector("div.manga_chapter");
30 | let note = document.createElement("span");
31 | note.style.fontSize = "x-large";
32 | note.style.color = "black";
33 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
34 | }
35 | // add a header for download row
36 | function addDownloadHeader(){
37 | let header = document.querySelector("div.title_list_chapter");
38 | let downloadHeader = document.createElement("div");
39 | downloadHeader.textContent = "Download";
40 | downloadHeader.className = "chapter_time";
41 | header.appendChild(downloadHeader);
42 | }
43 | // add download button for each chapter
44 | function addDownloadButtons(){
45 | for (let i=0;i img");
91 |
92 | pdfButton.imgs = [];
93 | zipButton.imgs = [];
94 | for(let img of imgs){
95 | pdfButton.imgs.push(img.src);
96 | zipButton.imgs.push(img.src);
97 | }
98 |
99 | pdfButton.removeAttribute("disabled");
100 | zipButton.removeAttribute("disabled");
101 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
102 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
103 | }
104 | };
105 | xhttp.onerror = function (){
106 | clearConsole();
107 | };
108 | xhttp.open("GET", links[i]);
109 | xhttp.send();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | var host = window.location.host;
2 |
3 | if(document.querySelector("span#azerty") === null){
4 | // to make code run only once
5 | if(host !== "www.qiman6.com" && host !== "qingman5.com" && host !== "www.mangapanda.com"){
6 | var mark = document.createElement("span");
7 | mark.id = "azerty";
8 | mark.style.display = "none";
9 |
10 | document.body.appendChild(mark);
11 | // tell the browser to use HTTPS rather than HTTP.
12 | let upgradeInsecure = document.createElement("meta");
13 | upgradeInsecure.httpEquiv = "Content-Security-Policy";
14 | upgradeInsecure.content = "upgrade-insecure-requests";
15 | document.head.insertBefore(upgradeInsecure,document.head.firstElementChild);
16 | }
17 |
18 | switch (host) {
19 | case "www.mangareader.net":
20 | mangareaderF();
21 | break;
22 | case "www.mangapanda.com":
23 | mangapandaF();
24 | break;
25 | case "mangakiss.org":
26 | case "mangakomi.com":
27 | case "mangazone.cc":
28 | case "mangafort.com":
29 | case "1stkissmanga.com":
30 | case "1stkissmanga.io":
31 | case "zinmanga.com":
32 | case "365manga.com":
33 | case "toonily.net":
34 | case "mangatx.com":
35 | case "aloalivn.com":
36 | case "manhuaplus.com":
37 | case "mangaclash.com":
38 | case "manhuasworld.com":
39 | mangakissF(); // is the same as mangakiss.org
40 | break;
41 | case "manhuaus.com":
42 | manhuausF(); // is the same as mangakiss.org
43 | break;
44 | case "ww3.mangafox.online":
45 | case "ww4.mangafox.online":
46 | mangafoxF();
47 | break;
48 | case "kissmanga.com":
49 | kissmangaF();
50 | break;
51 | case "mangakakalot.com":
52 | mangakakalotF();
53 | break;
54 | case "manganelo.com":
55 | case "manganato.com":
56 | case "readmanganato.com":
57 | manganeloF();
58 | break;
59 | case "ww5.readhaikyuu.com":
60 | case "ww7.readsnk.com":
61 | case "ww3.readbleachmanga.com":
62 | case "ww2.readnoblesse.com":
63 | readnarutoF();
64 | break;
65 | case "ww5.readblackclover.com":
66 | case "ww6.readblackclover.com":
67 | case "ww6.dbsmanga.com":
68 | case "ww7.readonepiece.com":
69 | case "ww8.readonepiece.com":
70 | case "ww3.readhaikyuu.com":
71 | case "ww4.readhaikyuu.com":
72 | case "ww6.readhaikyuu.com":
73 | case "ww5.readmha.com":
74 | case "ww6.readmha.com":
75 | case "readjujutsukaisen.com":
76 | case "ww1.readjujutsukaisen.com":
77 | case "readchainsawman.com":
78 | case "ww1.readchainsawman.com":
79 | case "ww2.demonslayermanga.com":
80 | case "ww4.demonslayermanga.com":
81 | case "ww5.demonslayermanga.com":
82 | case "ww2.readdrstone.com":
83 | case "ww3.readdrstone.com":
84 | case "ww6.readnaruto.com":
85 | case "ww7.readnaruto.com":
86 | case "ww7.tokyoghoulre.com":
87 | case "ww8.tokyoghoulre.com":
88 | case "ww4.readfairytail.com":
89 | case "ww1.readkingdom.com":
90 | case "ww2.readkingdom.com":
91 | case "readkaguyasama.com":
92 | case "ww1.readkaguyasama.com":
93 | case "readsololeveling.org":
94 | case "ww2.readneverland.com":
95 | case "ww3.readneverland.com":
96 | case "ww1.readtowerofgod.com":
97 | case "ww1.readvinlandsaga.com":
98 | case "ww3.read7deadlysins.com":
99 | case "ww2.readhxh.com":
100 | readblackcloverF();
101 | break;
102 | case "ww3.readopm.com":
103 | case "readberserk.com":
104 | readopmF();
105 | break;
106 | case "kiryuu.co":
107 | kiryuuF(); // sektekomik.com is the same as kiryuu.co
108 | break;
109 | case "sektekomik.com":
110 | sektekomikF();
111 | break;
112 | case "mangadex.org":
113 | mangadexF();
114 | break;
115 | case "rawdevart.com":
116 | rawdevartF();
117 | break;
118 | case "mangasee123.com":
119 | case "manga4life.com":
120 | mangasee123F(); // manga4life.com is the same as mangasee123.com
121 | break;
122 | case "www.webtoons.com":
123 | webtoonsF();
124 | break;
125 | case "www.mangasail.co":
126 | case "www.mangatail.me":
127 | case "www.mangasaki.com":
128 | mangasailF();
129 | break;
130 | case "readmanhwa.com":
131 | readmanhwaF();
132 | break;
133 | case "www.mangatown.com":
134 | mangatownF();
135 | break;
136 | case "loveheaven.net": // changed to lovehug.net
137 | case "kissaway.net":
138 | case "klmanga.com":
139 | loveheavenF();
140 | break;
141 | case "www.qiman6.com":
142 | qiman6F();
143 | break;
144 | case "qingman5.com":
145 | qingman5F();
146 | break;
147 | case "full-metal-alchemist.com":
148 | full_metal_alchemistF();
149 | break;
150 | case "www.funmanga.com":
151 | case "www.mngdoom.com":
152 | case "www.mangainn.net":
153 | funmangaF();
154 | break;
155 | case "mangafast.net":
156 | case "comic.mangafast.net":
157 | mangafastF();
158 | break;
159 | case "lovehug.net":
160 | lovehugF();
161 | break;
162 | default:
163 | // alert("This should not happen");
164 | // this switch is for controlling which function should be called
165 | // just to not call all the functions
166 | break;
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "name": "Manga Downloader",
4 | "short_name" : "Manga Downloader",
5 | "version": "3.10.15",
6 |
7 | "description": "Download Manga/Manhua/Manhwa/Webtoons/Comics chapters as PDF/ZIP(images) from many websites.",
8 |
9 | "icons": {
10 | "48": "icons/md-48.png",
11 | "96": "icons/md-96.png",
12 | "128": "icons/md-128.png"
13 | },
14 | "permissions" : [
15 | "*://*.imggur.net/*",
16 | "*://*.imgur.com/*",
17 | "*://*.mangapanda.com/*",
18 | "*://mangakiss.org/*",
19 | "*://*.blogspot.com/*",
20 | "*://*.mangakomi.com/*",
21 | "*://*.mkklcdn.com/*",
22 | "*://*.mkklcdnv2.com/*",
23 | "*://*.mkklcdnv3.com/*",
24 | "*://*.mkklcdnv4.com/*",
25 | "*://*.mkklcdnv5.com/*",
26 | "*://*.mkklcdnv6.com/*",
27 | "*://*.mkklcdnv7.com/*",
28 | "*://*.mkklcdnv8.com/*",
29 | "*://*.mkklcdnv31.com/*",
30 | "*://*.mkklcdnv41.com/*",
31 | "*://*.mkklcdnv51.com/*",
32 | "*://*.mkklcdnbuv1.com/*",
33 | "*://*.mgicdn.com/*",
34 | "*://cdndex.com/*",
35 | "*://*.mangafox.online/*",
36 | "*://*.read7deadlysins.com/*",
37 | "*://*.mangabeast01.com/*",
38 | "*://*.mangapark.net/*",
39 | "*://*.wp.com/*",
40 | "*://*.statically.io/*",
41 | "*://yuucdn.com/*",
42 | "*://*.wordpress.com/*",
43 | "*://*.google.com/*",
44 | "*://*.googleusercontent.com/*",
45 | "*://mangadex.org/*",
46 | "*://*.mangadex.network/*",
47 | "*://*.rawdevart.com/*",
48 | "*://*.mangabeast.com/*",
49 | "*://webtoon-phinf.pstatic.net/*",
50 | "*://webtoons-static.pstatic.net/*",
51 | "*://sektecloning.xyz/*",
52 | "*://qcdn.my.id/*",
53 | "*://*.kiryuu.co/*",
54 | "*://*.mangazone.cc/*",
55 | "*://*.mixednet.com/*",
56 | "*://*.1stkissmanga.com/*",
57 | "*://*.zinmanga.com/*",
58 | "*://*.mangaomg.com/*",
59 | "*://*.readmanhwa.com/*",
60 | "*://*.mangahere.org/*",
61 | "*://cdn.imageart.online/*",
62 | "*://*.mangastorage.online/*",
63 | "*://*.imgmirror.club/*",
64 | "*://*.pstatp.com/*",
65 | "*://dingyue.ws.126.net/*",
66 | "*://loveha.net/*",
67 | "*://*.lowee.us/*",
68 | "*://*.planeptune.us/*",
69 | "*://*.lastation.us/*",
70 | "*://*.leanbox.us/*",
71 | "*://*.ivalice.us/*",
72 | "*://*.granpulse.us/*",
73 | "*://*.mangaclash.com/*",
74 | "*://*.b-cdn.net/*",
75 | "*://*.funmanga.com/*",
76 | "*://*.hydaelyn.us/*",
77 | "*://*.eorzea.us/*",
78 | "*://*.readshokugeki.com/*",
79 | "*://*.tokyoghoulre.com/*",
80 | "*://*.readopm.com/*",
81 | "*://*.readmha.com/*",
82 | "*://*.readfairytail.com/*",
83 | "*://*.readblackclover.com/*",
84 | "*://*.readbleachmanga.com/*",
85 | "*://*.readnoblesse.com/*",
86 | "*://*.readtowerofgod.com/*",
87 | "*://*.readvinlandsaga.com/*",
88 | "*://*.readkaguyasama.com/*",
89 | "*://*.readchainsawman.com/*",
90 | "*://*.readsololeveling.org/*",
91 | "*://*.readdrstone.com/*",
92 | "*://*.readonepiece.com/*",
93 | "*://*.readsnk.com/*",
94 | "*://*.readnaruto.com/*",
95 | "*://*.readneverland.com/*",
96 | "*://*.readkingdom.com/*",
97 | "*://*.readjujutsukaisen.com/*",
98 | "*://*.watchgoblinslayer.com/*",
99 | "*://*.watchoverlord2.com/*",
100 | "*://*.readberserk.com/*",
101 | "*://*.demonslayermanga.com/*",
102 | "*://*.dbsmanga.com/*",
103 | "*://*.imfaclub.com/*",
104 | "*://*.mkklcdnv6temp.com/*",
105 | "*://*.mkklcdnv6tempv2.com/*",
106 | "*://*.mkklcdnv6tempv3.com/*",
107 | "*://*.userapi.com/*",
108 | "*://*.mghubcdn.com/*",
109 | "*://*.staticflickr.com/*",
110 | "*://*.static-flickr.com/*",
111 | "*://*.orience.us/*",
112 | "*://*.1stkmg.com/*",
113 | "*://*.1stkmgv1.com/*",
114 | "*://*.manhuaus.com/*",
115 | "*://*.klimv1.xyz/*",
116 | "*://*.ihlv1.xyz/*",
117 | "*://*.mangadex.org/*",
118 | "*://*.bilibilicomics.com/*",
119 | "*://*.readmanganato.com/*",
120 | "*://*.gamindustri.us/*",
121 | "*://*.mangasail.net/*",
122 | "*://*.mangasaki.com/*",
123 | "*://*.manhuaplus.com/*",
124 | "*://*.mangakomicdn.com/*"
125 | ],
126 | "content_scripts": [
127 | {
128 | "matches": ["*://www.mangareader.net/*",
129 | "*://www.mangapanda.com/*",
130 | "*://mangakiss.org/*",
131 | "*://mangakomi.com/*",
132 | "*://*.mangafox.online/*",
133 | "*://kissmanga.com/*",
134 | "*://mangakakalot.com/*",
135 | "*://manganelo.com/*",
136 | "*://manganato.com/*",
137 | "*://*.readmanganato.com/*",
138 | "*://*.readnaruto.com/*",
139 | "*://*.tokyoghoulre.com/*",
140 | "*://*.readhaikyuu.com/*",
141 | "*://*.readopm.com/*",
142 | "*://*.readonepiece.com/*",
143 | "*://*.readsnk.com/*",
144 | "*://*.readfairytail.com/*",
145 | "*://*.readblackclover.com/*",
146 | "*://*.readbleachmanga.com/*",
147 | "*://*.readneverland.com/*",
148 | "*://*.readnoblesse.com/*",
149 | "*://*.readkingdom.com/*",
150 | "*://*.readtowerofgod.com/*",
151 | "*://*.readvinlandsaga.com/*",
152 | "*://*.readmha.com/*",
153 | "*://*.readkaguyasama.com/*",
154 | "*://*.readjujutsukaisen.com/*",
155 | "*://*.readchainsawman.com/*",
156 | "*://*.demonslayermanga.com/*",
157 | "*://*.read7deadlysins.com/*",
158 | "*://*.readsololeveling.org/*",
159 | "*://*.readhxh.com/*",
160 | "*://*.readberserk.com/*",
161 | "*://*.readdrstone.com/*",
162 | "*://*.dbsmanga.com/*",
163 | "*://kiryuu.co/*",
164 | "*://sektekomik.com/*",
165 | "*://mangadex.org/*",
166 | "*://rawdevart.com/*",
167 | "*://mangasee123.com/*",
168 | "*://www.webtoons.com/*",
169 | "*://manga4life.com/*",
170 | "*://mangazone.cc/*",
171 | "*://mangafort.com/*",
172 | "*://1stkissmanga.com/*",
173 | "*://1stkissmanga.io/*",
174 | "*://www.mangasail.co/*",
175 | "*://www.mangatail.me/*",
176 | "*://zinmanga.com/*",
177 | "*://365manga.com/*",
178 | "*://toonily.net/*",
179 | "*://manhuaus.com/*",
180 | "*://mangatx.com/*",
181 | "*://readmanhwa.com/*",
182 | "*://www.mangatown.com/*",
183 | "*://aloalivn.com/*",
184 | "*://loveheaven.net/*",
185 | "*://www.qiman6.com/*",
186 | "*://qingman5.com/*",
187 | "*://full-metal-alchemist.com/*",
188 | "*://manhuaplus.com/*",
189 | "*://mangaclash.com/*",
190 | "*://manhuasworld.com/*",
191 | "*://www.funmanga.com/*",
192 | "*://www.mngdoom.com/*",
193 | "*://www.mangainn.net/*",
194 | "*://*.mangafast.net/*",
195 | "*://kissaway.net/*",
196 | "*://klmanga.com/*",
197 | "*://lovehug.net/*",
198 | "*://www.mangasaki.com/*"
199 | ],
200 | "js": ["External/pdf-lib.js",
201 | "External/jszip.js",
202 | "clear.js",
203 | "functions.js",
204 | "Scripts/mangareader.js",
205 | "Scripts/mangapanda.js",
206 | "Scripts/mangakiss.js",
207 | "Scripts/mangafox.js",
208 | "Scripts/kissmanga.js",
209 | "Scripts/mangakakalot.js",
210 | "Scripts/manganelo.js",
211 | "Scripts/readnaruto.js",
212 | "Scripts/readopm.js",
213 | "Scripts/readblackclover.js",
214 | "Scripts/kiryuu.js",
215 | "Scripts/sektekomik.js",
216 | "Scripts/mangadex.js",
217 | "Scripts/rawdevart.js",
218 | "Scripts/mangasee123.js",
219 | "Scripts/webtoons.js",
220 | "Scripts/mangasail.js",
221 | "Scripts/manhuaus.js",
222 | "Scripts/readmanhwa.js",
223 | "Scripts/mangatown.js",
224 | "Scripts/loveheaven.js",
225 | "Scripts/qiman6.js",
226 | "Scripts/qingman5.js",
227 | "Scripts/full-metal-alchemist.js",
228 | "Scripts/funmanga.js",
229 | "Scripts/mangafast.js",
230 | "Scripts/lovehug.js",
231 | "index.js"
232 | ],
233 | "css": ["Styles/md-style.css"]
234 | }
235 | ]
236 |
237 | }
--------------------------------------------------------------------------------
/src/Scripts/mangatown.js:
--------------------------------------------------------------------------------
1 | function mangatownF() {
2 | // to store number of pages for each chapter
3 | let pages = [];
4 | // to store links of each chapter
5 | let links = [];
6 | // get all the rows
7 | let rows;
8 | // to store download button for easy access
9 | let pdfButtons = [];
10 | let zipButtons = [];
11 | // check if viewing chapters list page
12 | if(document.querySelector("div.chapter_content ul.chapter_list") !== null){
13 | rows = document.querySelectorAll("ul.chapter_list > li");
14 | // calling function
15 | addNote();
16 | addDownloadButtons();
17 | }
18 | // add a note for users
19 | function addNote(){
20 | let chapterDiv = document.querySelector("div.chapter_content");
21 | let note = document.createElement("span");
22 | note.style.fontSize = "x-large";
23 | note.style.color = "black";
24 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
25 | }
26 | // add download button for each chapter
27 | function addDownloadButtons(){
28 | // i for rows and index is for arrays
29 | // i start from 1 because 0 is for header
30 | for (let i = 0; i < rows.length; i++) {
31 | let pdfButton = document.createElement("button");
32 | let zipButton = document.createElement("button");
33 | pdfButton.textContent = "pdf";
34 | zipButton.textContent = "zip";
35 | // disable the button until fetching chapter pages number
36 | pdfButton.disabled = "true";
37 | zipButton.disabled = "true";
38 | // store chapter link
39 | links[i] = rows[i].querySelector("a").href;
40 | pdfButton.referrerLink = rows[i].querySelector("a").href;
41 | // add chapter number and name to button title and trimming extra spaces
42 | let title = rows[i].querySelector("a").textContent.trim();
43 | pdfButton.title = title;
44 | zipButton.title = title;
45 |
46 | rows[i].insertBefore(zipButton,rows[i].firstChild);
47 | rows[i].insertBefore(pdfButton,rows[i].firstChild);
48 | // storing download button for easy access
49 | pdfButtons.push(pdfButton);
50 | zipButtons.push(zipButton);
51 | // to fetch pages number from chapter link
52 | let xhttp = new XMLHttpRequest();
53 | // added id to each xhttp request to know what button called it
54 | xhttp.id = i;
55 | xhttp.onreadystatechange = function () {
56 | let id = this.id;
57 | let pdfButton = pdfButtons[id];
58 | let zipButton = zipButtons[id];
59 | // in case the page does not exist display and abort request
60 | if(this.status === 404){
61 | pdfButton.textContent = "Not Found";
62 | zipButton.style.display = "none";
63 | this.abort();
64 | }
65 | // if the request succeed
66 | if (this.readyState === 4 && this.status === 200) {
67 | // convert text to html DOM
68 | let parser = new DOMParser();
69 | let doc = parser.parseFromString(this.responseText, "text/html");
70 | // get number of pages as string then converting it to an integer
71 | let scripts = doc.querySelectorAll("script");
72 |
73 | let exist = false;
74 | let script;
75 | for(let scr of scripts){
76 | script = scr.textContent.trim();
77 | if(script.includes("total_pages")){
78 | exist = true;
79 | break;
80 | }
81 | }
82 | if(!exist){
83 | return;
84 | }
85 | let str = script.slice(script.indexOf("total_pages"), script.length);
86 | str = str.slice(str.indexOf("=")+1, str.indexOf(";"));
87 | let pagesNum = parseInt(str.trim());
88 | // storing pages number
89 | pages[id] = pagesNum;
90 | // making button clickable and adding listener for click
91 | pdfButton.removeAttribute("disabled");
92 | zipButton.removeAttribute("disabled");
93 | pdfButton.addEventListener("click", function(){getImgs(id,1);});
94 | zipButton.addEventListener("click", function(){getImgs(id,2);});
95 | }
96 | };
97 | xhttp.onerror = function (){
98 | clearConsole();
99 | };
100 | xhttp.open("GET", links[i], true);
101 | xhttp.send();
102 | }
103 | }
104 | // get all images links
105 | function getImgs(id,type){
106 | // check if currently downloading
107 | if(pdfButtons[id].down){
108 | pdfButtons[id].disabled = "true";
109 | zipButtons[id].disabled = "true";
110 | return;
111 | }
112 | pdfButtons[id].down = true;
113 | zipButtons[id].down = true;
114 | let button;
115 | if(type === 1){
116 | button = pdfButtons[id];
117 | }
118 | if(type === 2){
119 | button = zipButtons[id];
120 | }
121 | // check if the user already downloaded this chapter
122 | if(type === 1 && pdfButtons[id].pdf){
123 | downloadFile(pdfButtons[id].pdf,button.title.trim(),"zip");
124 | return;
125 | }
126 | if(type === 2 && zipButtons[id].zip){
127 | downloadFile(zipButtons[id].zip,button.title.trim(),"zip");
128 | return;
129 | }
130 | else{
131 | pdfButtons[id].disabled = "true";
132 | zipButtons[id].disabled = "true";
133 | pdfButtons[id].imgs = [];
134 | zipButtons[id].imgs = [];
135 | button.textContent = "0%";
136 | // to know when all links are found
137 | pdfButtons[id].counter = 0;
138 | // loop throw all chapter pages
139 | let index = 0;
140 | for(let i=1;i<=pages[id];i++){
141 | let xhttp = new XMLHttpRequest();
142 | xhttp.id = id;
143 | xhttp.num = index;
144 | xhttp.type = type;
145 | xhttp.onreadystatechange = function (){
146 | let id = this.id;
147 | let num = this.num;
148 | let type = this.type;
149 | let pdfButton = pdfButtons[id];
150 | let zipButton = zipButtons[id];
151 | // if the request succeed
152 | if(this.readyState === 4 & this.status === 200){
153 | let parser = new DOMParser();
154 | let doc = parser.parseFromString(this.responseText, "text/html");
155 | let img = doc.querySelector("div.read_img img#image");
156 | // storing img link in button for easy access
157 | pdfButton.imgs[num] = img.src;
158 | zipButton.imgs[num] = img.src;
159 | pdfButtons[id].counter++;
160 | // changing button text to visualize process
161 | // the first 50%
162 | let percentage = (pdfButtons[id].counter * 50)/pages[id];
163 | button.textContent = parseInt(percentage)+"%";
164 | // if all links are found make pdf/zip file
165 | if(pdfButtons[id].counter === pages[id]){
166 | embedImages(pdfButton,zipButton,type,true);
167 | }
168 | }
169 | };
170 | xhttp.onerror = function (){
171 | clearConsole();
172 | };
173 | // i because webpages starts from /1
174 | xhttp.open("GET", links[id]+"/"+i+".html");
175 | xhttp.send();
176 | index++;
177 | }
178 | }
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/src/Scripts/mangapanda.js:
--------------------------------------------------------------------------------
1 | function mangapandaF() {
2 | // to store number of pages for each chapter
3 | let pages = [];
4 | // to store links of each chapter
5 | let links = [];
6 | // get all chapters displayed in the table
7 | let chapterList;
8 | // get all the rows
9 | let rows;
10 | // to store download button for easy access
11 | let pdfButtons = [];
12 | let zipButtons = [];
13 | // check if viewing chapters list page
14 | if(document.querySelector("div#chapterList") !== null){
15 | chapterList = document.querySelector("div#chapterList");
16 | rows = chapterList.querySelectorAll("tr");
17 | // calling function
18 | addNote();
19 | addDownloadHeader();
20 | addDownloadButtons();
21 | }
22 | // add a note for users
23 | function addNote(){
24 | var mark = document.createElement("span");
25 | mark.id = "azerty";
26 | mark.style.display = "none";
27 | document.body.appendChild(mark);
28 |
29 | let chapterDiv = document.querySelector("div#chapterlist");
30 | let note = document.createElement("span");
31 | note.style.fontSize = "x-large";
32 | note.style.color = "black";
33 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
34 | }
35 | // add a header for download row
36 | function addDownloadHeader(){
37 | let downloadHeader = document.createElement("th");
38 | downloadHeader.textContent = " Download";
39 | rows[0].appendChild(downloadHeader);
40 | }
41 | // add download button for each chapter
42 | function addDownloadButtons(){
43 | // i for rows and index is for arrays
44 | // i start from 1 because 0 is for header
45 | let index = 0;
46 | for (let i = 1; i < rows.length; i++) {
47 | let pdfButton = document.createElement("button");
48 | let zipButton = document.createElement("button");
49 | pdfButton.textContent = "pdf";
50 | zipButton.textContent = "zip";
51 | // disable the button until fetching chapter pages number
52 | pdfButton.disabled = "true";
53 | zipButton.disabled = "true";
54 | // store chapter link
55 | links[index] = rows[i].querySelector("a").href;
56 | pdfButton.referrerLink = rows[i].querySelector("a").href;
57 | // add chapter number and name to button title and trimming extra spaces
58 | pdfButton.title = rows[i].querySelector("td").textContent;
59 | pdfButton.title = pdfButton.title.trim();
60 | zipButton.title = pdfButton.title;
61 | // create new table cells to append download button for each chapter
62 | let newCell = document.createElement("td");
63 | newCell.appendChild(pdfButton);
64 | newCell.appendChild(zipButton);
65 | rows[i].appendChild(newCell);
66 | // storing download button for easy access
67 | pdfButtons.push(pdfButton);
68 | zipButtons.push(zipButton);
69 | // to fetch pages number from chapter link
70 | let xhttp = new XMLHttpRequest();
71 | // added id to each xhttp request to know what button called it
72 | xhttp.id = index;
73 | xhttp.onreadystatechange = function () {
74 | let id = this.id;
75 | let pdfButton = pdfButtons[id];
76 | let zipButton = zipButtons[id];
77 | // in case the page does not exist display and abort request
78 | if(this.status === 404){
79 | pdfButton.textContent = "Not Found";
80 | zipButton.style.display = "none";
81 | this.abort();
82 | }
83 | // if the request succeed
84 | if (this.readyState === 4 && this.status === 200) {
85 | // convert text to html DOM
86 | let parser = new DOMParser();
87 | let doc = parser.parseFromString(this.responseText, "text/html");
88 | // get number of pages as string then converting it to an integer
89 | let str = doc.querySelector("select#pageMenu").lastElementChild.textContent;
90 | let pagesNum = parseInt(str);
91 | // storing pages number
92 | pages[id] = pagesNum;
93 | // making button clickable and adding listener for click
94 | pdfButton.removeAttribute("disabled");
95 | zipButton.removeAttribute("disabled");
96 | pdfButton.addEventListener("click", function(){getImgs(id,1);});
97 | zipButton.addEventListener("click", function(){getImgs(id,2);});
98 | }
99 | };
100 | xhttp.onerror = function (){
101 | clearConsole();
102 | };
103 | xhttp.open("GET", links[index], true);
104 | xhttp.send();
105 | // for arrays
106 | index++;
107 | }
108 | }
109 | // get all images links
110 | function getImgs(id,type){
111 | // check if currently downloading
112 | if(pdfButtons[id].down){
113 | pdfButtons[id].disabled = "true";
114 | zipButtons[id].disabled = "true";
115 | return;
116 | }
117 | pdfButtons[id].down = true;
118 | zipButtons[id].down = true;
119 | let button;
120 | if(type === 1){
121 | button = pdfButtons[id];
122 | }
123 | if(type === 2){
124 | button = zipButtons[id];
125 | }
126 | // check if the user already downloaded this chapter
127 | if(type === 1 && pdfButtons[id].pdf){
128 | downloadFile(pdfButtons[id].pdf,button.title.trim(),"zip");
129 | return;
130 | }
131 | if(type === 2 && zipButtons[id].zip){
132 | downloadFile(zipButtons[id].zip,button.title.trim(),"zip");
133 | return;
134 | }
135 | else{
136 | pdfButtons[id].disabled = "true";
137 | zipButtons[id].disabled = "true";
138 | pdfButtons[id].imgs = [];
139 | zipButtons[id].imgs = [];
140 | button.textContent = "0%";
141 | // to know when all links are found
142 | pdfButtons[id].counter = 0;
143 | // loop throw all chapter pages
144 | let index = 0;
145 | for(let i=1;i<=pages[id];i++){
146 | let xhttp = new XMLHttpRequest();
147 | xhttp.id = id;
148 | xhttp.num = index;
149 | xhttp.type = type;
150 | xhttp.onreadystatechange = function (){
151 | let id = this.id;
152 | let num = this.num;
153 | let type = this.type;
154 | let pdfButton = pdfButtons[id];
155 | let zipButton = zipButtons[id];
156 | // if the request succeed
157 | if(this.readyState === 4 & this.status === 200){
158 | let parser = new DOMParser();
159 | let doc = parser.parseFromString(this.responseText, "text/html");
160 | let img = doc.getElementById("img");
161 | // storing img link in button for easy access
162 | pdfButton.imgs[num] = img.src;
163 | zipButton.imgs[num] = img.src;
164 | pdfButtons[id].counter++;
165 | // changing button text to visualize process
166 | // the first 50%
167 | let percentage = (pdfButtons[id].counter * 50)/pages[id];
168 | button.textContent = parseInt(percentage)+"%";
169 | // if all links are found make pdf/zip file
170 | if(pdfButtons[id].counter === pages[id]){
171 | embedImages(pdfButton,zipButton,type,true);
172 | }
173 | }
174 | };
175 | xhttp.onerror = function (){
176 | clearConsole();
177 | };
178 | // i because webpages starts from /1
179 | xhttp.open("GET", links[id]+"/"+i);
180 | xhttp.send();
181 | index++;
182 | }
183 | }
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/src/Scripts/full-metal-alchemist.js:
--------------------------------------------------------------------------------
1 | function full_metal_alchemistF() {
2 | // to store links of each chapter
3 | let links = [];
4 | // get all chapters displayed in the table
5 | let rows;
6 | // to store download button for easy access
7 | let pdfButtons = [];
8 | let zipButtons = [];
9 | // to store all chapters images for batch Download (store the buttons)
10 | let chaptersData = [];
11 | // check if viewing chapters list page
12 | if(document.querySelector("div#Chapters_List") !== null){
13 | rows = document.querySelectorAll("div#Chapters_List ul ul li");
14 | // calling function
15 | addNote();
16 | addBatchDownload();
17 | addDownloadButtons();
18 | }
19 | // add a note for users
20 | function addNote(){
21 | let chapterDiv = document.querySelector("div#Chapters_List");
22 | let note = document.createElement("span");
23 | note.id = "md-note";
24 | note.style.fontSize = "x-large";
25 | note.style.color = "black";
26 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
27 | }
28 | // add download button for each chapter
29 | function addDownloadButtons(){
30 | for (let i=0;i res.text()).catch(error => {
63 | fetchError = true;
64 | pdfButton.textContent("Error");
65 | zipButton.style.display = "none";
66 | clearConsole();
67 | });;
68 | // convert text to html DOM
69 | let parser = new DOMParser();
70 | let doc = parser.parseFromString(html, "text/html");
71 | let imgs = doc.querySelectorAll("div.entry-content div.separator img");
72 |
73 | let pdfButton = pdfButtons[i];
74 | let zipButton = zipButtons[i];
75 |
76 | pdfButton.imgs = [];
77 | zipButton.imgs = [];
78 | for(let img of imgs){
79 | let src = img.src;
80 | pdfButton.imgs.push(src);
81 | zipButton.imgs.push(src);
82 | }
83 |
84 | // store the button with all the images for batch download
85 | chaptersData[i] = {
86 | title: pdfButton.title,
87 | images: pdfButton.imgs,
88 | referrerLink: links[i]
89 | };
90 | // check if all buttons are add
91 | let len = chaptersData.reduce((acc,cv)=>(cv)?acc+1:acc,0);
92 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
93 | if(len === chapterCount){
94 | addChaptersToList();
95 | }
96 |
97 | pdfButton.removeAttribute("disabled");
98 | zipButton.removeAttribute("disabled");
99 |
100 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
101 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
102 | }
103 | }
104 | // add batch download button
105 | function addBatchDownload(){
106 | // add the floatDiv to document body
107 | let floatDiv = document.createElement("div");
108 | floatDiv.id = "md-floatDiv";
109 | floatDiv.classList.add("md-float-modal");
110 | let floatDivContent = document.createElement("div");
111 | floatDivContent.classList.add("md-float-modal-content");
112 | let floatCloseButton = document.createElement("span");
113 | floatCloseButton.classList.add("md-float-close");
114 | floatCloseButton.innerHTML = "×";
115 |
116 | floatDivContent.appendChild(floatCloseButton);
117 | floatDiv.appendChild(floatDivContent);
118 | document.body.appendChild(floatDiv);
119 |
120 | // to close floating div
121 | floatCloseButton.onclick = function() {
122 | floatDiv.style.display = "none";
123 | };
124 |
125 | // create the button that show the floatDiv
126 | let batchDownloadButton = document.createElement("button");
127 | batchDownloadButton.textContent = "Batch Download";
128 | batchDownloadButton.classList.add("md-download-button");
129 | batchDownloadButton.id = "md-batch-download-button";
130 | batchDownloadButton.title = "Download multiple chapters at once";
131 | batchDownloadButton.disabled = "true";
132 |
133 | let waitNote = document.createElement("span");
134 | waitNote.textContent = "wait, getting data from all chapters";
135 | waitNote.id = "md-batch-note";
136 | let holder = document.createElement("span");
137 | holder.appendChild(batchDownloadButton);
138 | holder.appendChild(waitNote);
139 | // append batch button after the note
140 | let theNote = document.querySelector("span#md-note");
141 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
142 |
143 | let floatDivChapterList = document.createElement("select");
144 | floatDivChapterList.id = "md-float-chapter-list";
145 | floatDivChapterList.size = 20;
146 | floatDivChapterList.multiple = true;
147 |
148 | floatDivContent.appendChild(floatDivChapterList);
149 |
150 | let pdfButtonBatch = document.createElement("button");
151 | pdfButtonBatch.classList.add("md-download-button");
152 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
153 | let zipButtonBatch = document.createElement("button");
154 | zipButtonBatch.classList.add("md-download-button");
155 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
156 |
157 | let buttonHolder = document.createElement("span");
158 | buttonHolder.appendChild(pdfButtonBatch);
159 | buttonHolder.appendChild(zipButtonBatch);
160 |
161 | floatDivContent.appendChild(buttonHolder);
162 |
163 | pdfButtonBatch.addEventListener("click", function(){
164 | if(floatDivChapterList.selectedOptions.length > 0){
165 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
166 | }
167 | });
168 |
169 | zipButtonBatch.addEventListener("click", function(){
170 | if(floatDivChapterList.selectedOptions.length > 0){
171 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
172 | }
173 | });
174 |
175 | let batchProgressContainer = document.createElement("div");
176 | batchProgressContainer.classList.add("md-progress-container");
177 | let batchProgressBar = document.createElement("div");
178 | batchProgressBar.classList.add("md-progress-bar");
179 | batchProgressBar.textContent = "0%";
180 | batchProgressBar.style.display = "none";
181 |
182 | batchProgressContainer.appendChild(batchProgressBar);
183 | floatDivContent.appendChild(batchProgressContainer);
184 | }
185 | // add chapters to list inside floatDiv
186 | function addChaptersToList(){
187 | let waitNote = document.querySelector("span#md-batch-note");
188 | waitNote.textContent = "wait, adding Chapters to list.";
189 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
190 |
191 | for(let i=0 ;i ul > li");
14 | // calling function
15 | addNote();
16 | addBatchDownload();
17 | addDownloadButtons();
18 | }
19 | // add a note for users
20 | function addNote(){
21 | let chapterDiv = document.querySelector("div.bixbox.bxcl");
22 | let note = document.createElement("span");
23 | note.id = "md-note";
24 | note.style.fontSize = "x-large";
25 | note.style.color = "black";
26 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
27 | }
28 | // add download button for each chapter
29 | function addDownloadButtons(){
30 | for (let i=0;i(cv)?acc+1:acc,0);
90 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
91 | if(len === chapterCount){
92 | addChaptersToList();
93 | }
94 |
95 | pdfButton.removeAttribute("disabled");
96 | zipButton.removeAttribute("disabled");
97 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
98 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
99 | }
100 | };
101 | xhttp.onerror = function (){
102 | clearConsole();
103 | };
104 | xhttp.open("GET", links[i]);
105 | xhttp.send();
106 | }
107 | }
108 | // add batch download button
109 | function addBatchDownload(){
110 | // add the floatDiv to document body
111 | let floatDiv = document.createElement("div");
112 | floatDiv.id = "md-floatDiv";
113 | floatDiv.classList.add("md-float-modal");
114 | let floatDivContent = document.createElement("div");
115 | floatDivContent.classList.add("md-float-modal-content");
116 | let floatCloseButton = document.createElement("span");
117 | floatCloseButton.classList.add("md-float-close");
118 | floatCloseButton.innerHTML = "×";
119 |
120 | floatDivContent.appendChild(floatCloseButton);
121 | floatDiv.appendChild(floatDivContent);
122 | document.body.appendChild(floatDiv);
123 |
124 | // to close floating div
125 | floatCloseButton.onclick = function() {
126 | floatDiv.style.display = "none";
127 | };
128 |
129 | // create the button that show the floatDiv
130 | let batchDownloadButton = document.createElement("button");
131 | batchDownloadButton.textContent = "Batch Download";
132 | batchDownloadButton.id = "md-batch-download-button";
133 | batchDownloadButton.title = "Download multiple chapters at once";
134 | batchDownloadButton.disabled = "true";
135 |
136 | let waitNote = document.createElement("span");
137 | waitNote.textContent = "wait, getting data from all chapters";
138 | waitNote.id = "md-batch-note";
139 | let holder = document.createElement("span");
140 | holder.appendChild(batchDownloadButton);
141 | holder.appendChild(waitNote);
142 | // append batch button after the note
143 | let theNote = document.querySelector("span#md-note");
144 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
145 |
146 | let floatDivChapterList = document.createElement("select");
147 | floatDivChapterList.id = "md-float-chapter-list";
148 | floatDivChapterList.size = 20;
149 | floatDivChapterList.multiple = true;
150 |
151 | floatDivContent.appendChild(floatDivChapterList);
152 |
153 | let pdfButtonBatch = document.createElement("button");
154 | pdfButtonBatch.classList.add("md-download-button");
155 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
156 | let zipButtonBatch = document.createElement("button");
157 | zipButtonBatch.classList.add("md-download-button");
158 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
159 |
160 | let buttonHolder = document.createElement("span");
161 | buttonHolder.appendChild(pdfButtonBatch);
162 | buttonHolder.appendChild(zipButtonBatch);
163 |
164 | floatDivContent.appendChild(buttonHolder);
165 |
166 | pdfButtonBatch.addEventListener("click", function(){
167 | if(floatDivChapterList.selectedOptions.length > 0){
168 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
169 | }
170 | });
171 |
172 | zipButtonBatch.addEventListener("click", function(){
173 | if(floatDivChapterList.selectedOptions.length > 0){
174 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
175 | }
176 | });
177 |
178 | let batchProgressContainer = document.createElement("div");
179 | batchProgressContainer.classList.add("md-progress-container");
180 | let batchProgressBar = document.createElement("div");
181 | batchProgressBar.classList.add("md-progress-bar");
182 | batchProgressBar.textContent = "0%";
183 | batchProgressBar.style.display = "none";
184 |
185 | batchProgressContainer.appendChild(batchProgressBar);
186 | floatDivContent.appendChild(batchProgressContainer);
187 | }
188 | // add chapters to list inside floatDiv
189 | function addChaptersToList(){
190 | let waitNote = document.querySelector("span#md-batch-note");
191 | waitNote.textContent = "wait, adding Chapters to list.";
192 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
193 |
194 | for(let i=0 ;i(cv)?acc+1:acc,0);
89 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
90 | if(len === chapterCount){
91 | addChaptersToList();
92 | }
93 |
94 | pdfButton.removeAttribute("disabled");
95 | zipButton.removeAttribute("disabled");
96 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
97 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
98 | }
99 | };
100 | xhttp.onerror = function (){
101 | clearConsole();
102 | };
103 | xhttp.open("GET", links[i]);
104 | xhttp.send();
105 | }
106 | }
107 | // add batch download button
108 | function addBatchDownload(){
109 | // add the floatDiv to document body
110 | let floatDiv = document.createElement("div");
111 | floatDiv.id = "md-floatDiv";
112 | floatDiv.classList.add("md-float-modal");
113 | let floatDivContent = document.createElement("div");
114 | floatDivContent.classList.add("md-float-modal-content");
115 | let floatCloseButton = document.createElement("span");
116 | floatCloseButton.classList.add("md-float-close");
117 | floatCloseButton.innerHTML = "×";
118 | // to close floating div
119 | floatCloseButton.onclick = function() {
120 | floatDiv.style.display = "none";
121 | };
122 | floatDivContent.appendChild(floatCloseButton);
123 | floatDiv.appendChild(floatDivContent);
124 | document.body.appendChild(floatDiv);
125 | // the button that show the floatDiv
126 | // the button that show the floatDiv
127 | let batchDownloadButton = document.createElement("button");
128 | batchDownloadButton.textContent = "Batch Download";
129 | batchDownloadButton.id = "md-batch-download-button";
130 | batchDownloadButton.title = "Download multiple chapters at once";
131 | batchDownloadButton.classList.add("md-download-button");
132 | batchDownloadButton.disabled = "true";
133 |
134 | let waitNote = document.createElement("span");
135 | waitNote.textContent = "wait, getting data from all chapters";
136 | waitNote.id = "md-batch-note";
137 | let holder = document.createElement("span");
138 | holder.appendChild(batchDownloadButton);
139 | holder.appendChild(waitNote);
140 | // append batch button after the note
141 | let theNote = document.querySelector("span#md-note");
142 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
143 |
144 | let floatDivChapterList = document.createElement("select");
145 | floatDivChapterList.id = "md-float-chapter-list";
146 | floatDivChapterList.size = 20;
147 | floatDivChapterList.multiple = true;
148 |
149 | floatDivContent.appendChild(floatDivChapterList);
150 |
151 | let pdfButtonBatch = document.createElement("button");
152 | pdfButtonBatch.classList.add("md-download-button");
153 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
154 | let zipButtonBatch = document.createElement("button");
155 | zipButtonBatch.classList.add("md-download-button");
156 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
157 |
158 | let buttonHolder = document.createElement("span");
159 | buttonHolder.appendChild(pdfButtonBatch);
160 | buttonHolder.appendChild(zipButtonBatch);
161 |
162 | floatDivContent.appendChild(buttonHolder);
163 |
164 | pdfButtonBatch.addEventListener("click", function(){
165 | if(floatDivChapterList.selectedOptions.length > 0){
166 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
167 | }
168 | });
169 |
170 | zipButtonBatch.addEventListener("click", function(){
171 | if(floatDivChapterList.selectedOptions.length > 0){
172 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
173 | }
174 | });
175 |
176 | let batchProgressContainer = document.createElement("div");
177 | batchProgressContainer.classList.add("md-progress-container");
178 | let batchProgressBar = document.createElement("div");
179 | batchProgressBar.classList.add("md-progress-bar");
180 | batchProgressBar.textContent = "0%";
181 | batchProgressBar.style.display = "none";
182 |
183 | batchProgressContainer.appendChild(batchProgressBar);
184 | floatDivContent.appendChild(batchProgressContainer);
185 | }
186 | // add chapters to list inside floatDiv
187 | function addChaptersToList(){
188 | let waitNote = document.querySelector("span#md-batch-note");
189 | waitNote.textContent = "wait, adding Chapters to list.";
190 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
191 |
192 | for(let i=0 ;i {
8 | chrome.runtime.sendMessage({input, init}, messageResponse => {
9 | const [response, error] = messageResponse;
10 | if (response === null) {
11 | reject(error);
12 | } else {
13 | // Use undefined on a 204 - No Content
14 | const body = response.body ? new Blob([response.body]) : undefined;
15 | resolve(new Response(body, {
16 | status: response.status,
17 | statusText: response.statusText,
18 | }));
19 | }
20 | });
21 | });
22 | }
23 |
24 | // background.js
25 | chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
26 | fetch(request.input, request.init).then(function(response) {
27 | return response.text().then(function(text) {
28 | sendResponse([{
29 | body: text,
30 | status: response.status,
31 | statusText: response.statusText,
32 | }, null]);
33 | });
34 | }, function(error) {
35 | sendResponse([null, error]);
36 | });
37 | return true;
38 | });
39 | */
40 | /*
41 | // to store all chapters images links for batch Download
42 | let chaptersData = [];
43 | // check if viewing chapters list page
44 | if(document.querySelector("div.v-item-group") !== null){
45 | // calling function
46 | addNote();
47 | addBatchDownload();
48 | }
49 | else{
50 | loop();
51 | }
52 | function loop(){
53 | if(document.querySelector("div.v-item-group") !== null){
54 | addNote();
55 | addBatchDownload();
56 | }
57 | else{
58 | setTimeout(loop,2000);
59 | }
60 | }
61 | // add a note for users
62 | function addNote(){
63 | let chapterDiv = document.querySelector("div.v-item-group").parentElement;
64 | let note = document.createElement("span");
65 | note.id = "md-note";
66 | note.style.fontSize = "x-large";
67 | note.style.color = "black";
68 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
69 | }
70 | // add batch download button
71 | function addBatchDownload(){
72 | // add the floatDiv to document body
73 | let floatDiv = document.createElement("div");
74 | floatDiv.id = "md-floatDiv";
75 | floatDiv.classList.add("md-float-modal");
76 | let floatDivContent = document.createElement("div");
77 | floatDivContent.classList.add("md-float-modal-content");
78 | let floatCloseButton = document.createElement("span");
79 | floatCloseButton.classList.add("md-float-close");
80 | floatCloseButton.innerHTML = "×";
81 | // to close floating div
82 | floatCloseButton.onclick = function() {
83 | floatDiv.style.display = "none";
84 | };
85 | floatDivContent.appendChild(floatCloseButton);
86 | floatDiv.appendChild(floatDivContent);
87 | document.body.appendChild(floatDiv);
88 | // the button that show the floatDiv
89 | // the button that show the floatDiv
90 | let batchDownloadButton = document.createElement("button");
91 | batchDownloadButton.textContent = "Batch Download";
92 | batchDownloadButton.id = "md-batch-download-button";
93 | batchDownloadButton.title = "Download multiple chapters at once";
94 | batchDownloadButton.classList.add("md-download-button");
95 | batchDownloadButton.disabled = "true";
96 |
97 | let waitNote = document.createElement("span");
98 | waitNote.textContent = "wait, getting data from all chapters";
99 | waitNote.id = "md-batch-note";
100 | let holder = document.createElement("span");
101 | holder.appendChild(batchDownloadButton);
102 | holder.appendChild(waitNote);
103 | // append batch button after the note
104 | let theNote = document.querySelector("span#md-note");
105 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
106 |
107 | let floatDivChapterList = document.createElement("select");
108 | floatDivChapterList.id = "md-float-chapter-list";
109 | floatDivChapterList.size = 20;
110 | floatDivChapterList.multiple = true;
111 |
112 | floatDivContent.appendChild(floatDivChapterList);
113 |
114 | let pdfButtonBatch = document.createElement("button");
115 | pdfButtonBatch.classList.add("md-download-button");
116 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
117 | let zipButtonBatch = document.createElement("button");
118 | zipButtonBatch.classList.add("md-download-button");
119 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
120 |
121 | let buttonHolder = document.createElement("span");
122 | buttonHolder.appendChild(pdfButtonBatch);
123 | buttonHolder.appendChild(zipButtonBatch);
124 |
125 | floatDivContent.appendChild(buttonHolder);
126 |
127 | pdfButtonBatch.addEventListener("click", function(){
128 | if(floatDivChapterList.selectedOptions.length > 0){
129 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
130 | }
131 | });
132 |
133 | zipButtonBatch.addEventListener("click", function(){
134 | if(floatDivChapterList.selectedOptions.length > 0){
135 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
136 | }
137 | });
138 |
139 | let batchProgressContainer = document.createElement("div");
140 | batchProgressContainer.classList.add("md-progress-container");
141 | let batchProgressBar = document.createElement("div");
142 | batchProgressBar.classList.add("md-progress-bar");
143 | batchProgressBar.textContent = "0%";
144 | batchProgressBar.style.display = "none";
145 |
146 | batchProgressContainer.appendChild(batchProgressBar);
147 | floatDivContent.appendChild(batchProgressContainer);
148 |
149 | getAllChapters();
150 | }
151 | // get all chapters from other pages
152 | async function getAllChapters(){
153 | let waitNote = document.querySelector("span#md-batch-note");
154 | waitNote.textContent = "wait, fetching data";
155 |
156 | let mangaUrl = window.location.href;
157 | let manga_id = mangaUrl.split('/').slice(-1)[0];
158 |
159 | let apiUrl = "https://api.mangadex.org/manga/"
160 |
161 |
162 | // get total number of chapters in manga
163 | let total = await fetch(apiUrl+manga_id+"/feed?limit=0").then(res => res.text());
164 |
165 | //total = total.total
166 | console.log(total);
167 | return;
168 |
169 | // if chapters are more than 500
170 | offset = 0;
171 | while (offset < total){
172 | index = 0;
173 | let manga_data = await fetch(apiUrl+manga_id+"/feed?order[chapter]=asc&order[volume]=asc&limit=500").then(res => res.json());
174 | for(var i=0 ; i< manga_data.results.length ; i++){
175 | waitNote.textContent = "wait, fetching data "+(index+1)+"/"+total+" chapters";
176 |
177 | let chapter_title = "Chapter "+manga_data.results[i].data.attributes.chapter;
178 | chapter_title += " "+manga_data.results[i].data.attributes.title;
179 | chapter_title += " ("+manga_data.results[i].data.attributes.translatedLanguage + ")";
180 |
181 | let chapter_hash = manga_data.results[0].data.attributes.hash;
182 | let chapter_data = manga_data.results[0].data.attributes.data;
183 | let chapter_id = manga_data.results[0].data.id;
184 | let chapter_url = "https://mangadex.org/chapter/"+chapter_id;
185 |
186 | let baseUrl = await fetch("https://api.mangadex.org/at-home/server/"+chapter_id).then(res => res.json());
187 | baseUrl = baseUrl.baseUrl;
188 |
189 |
190 | let chapter_images = [];
191 |
192 | for (var image_data of chapter_data){
193 | let image_url = baseUrl+"/" + "data/" + chapter_hash+"/" + image_data;
194 | chapter_images.append(image_url);
195 | }
196 |
197 | console.log(chapter_images);
198 | return;
199 | chaptersData[index] = {
200 | title: chapter_title,
201 | images: chapter_images,
202 | referrerLink: chapter_url
203 | };
204 |
205 | index++;
206 | }
207 | }
208 |
209 | addChaptersToList();
210 | }
211 | // add chapters to list inside floatDiv
212 | function addChaptersToList(){
213 | let waitNote = document.querySelector("span#md-batch-note");
214 | waitNote.textContent = "wait, adding Chapters to list.";
215 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
216 |
217 | for(let i=0 ;i(cv)?acc+1:acc,0);
96 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
97 | if(len === chapterCount){
98 | addChaptersToList();
99 | }
100 |
101 | pdfButton.removeAttribute("disabled");
102 | zipButton.removeAttribute("disabled");
103 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
104 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
105 | }
106 | };
107 | xhttp.onerror = function (){
108 | clearConsole();
109 | };
110 | xhttp.open("GET", links[i]);
111 | xhttp.send();
112 | }
113 | }
114 | // add batch download button
115 | function addBatchDownload(){
116 | // add the floatDiv to document body
117 | let floatDiv = document.createElement("div");
118 | floatDiv.id = "md-floatDiv";
119 | floatDiv.classList.add("md-float-modal");
120 | let floatDivContent = document.createElement("div");
121 | floatDivContent.classList.add("md-float-modal-content");
122 | let floatCloseButton = document.createElement("span");
123 | floatCloseButton.classList.add("md-float-close");
124 | floatCloseButton.innerHTML = "×";
125 | // to close floating div
126 | floatCloseButton.onclick = function() {
127 | floatDiv.style.display = "none";
128 | };
129 | floatDivContent.appendChild(floatCloseButton);
130 | floatDiv.appendChild(floatDivContent);
131 | document.body.appendChild(floatDiv);
132 | // the button that show the floatDiv
133 | // the button that show the floatDiv
134 | let batchDownloadButton = document.createElement("button");
135 | batchDownloadButton.textContent = "Batch Download";
136 | batchDownloadButton.id = "md-batch-download-button";
137 | batchDownloadButton.title = "Download multiple chapters at once";
138 | batchDownloadButton.classList.add("md-download-button");
139 | batchDownloadButton.disabled = "true";
140 |
141 | let waitNote = document.createElement("span");
142 | waitNote.textContent = "wait, getting data from all chapters";
143 | waitNote.id = "md-batch-note";
144 | let holder = document.createElement("span");
145 | holder.appendChild(batchDownloadButton);
146 | holder.appendChild(waitNote);
147 | // append batch button after the note
148 | let theNote = document.querySelector("span#md-note");
149 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
150 |
151 | let floatDivChapterList = document.createElement("select");
152 | floatDivChapterList.id = "md-float-chapter-list";
153 | floatDivChapterList.size = 20;
154 | floatDivChapterList.multiple = true;
155 |
156 | floatDivContent.appendChild(floatDivChapterList);
157 |
158 | let pdfButtonBatch = document.createElement("button");
159 | pdfButtonBatch.classList.add("md-download-button");
160 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
161 | let zipButtonBatch = document.createElement("button");
162 | zipButtonBatch.classList.add("md-download-button");
163 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
164 |
165 | let buttonHolder = document.createElement("span");
166 | buttonHolder.appendChild(pdfButtonBatch);
167 | buttonHolder.appendChild(zipButtonBatch);
168 |
169 | floatDivContent.appendChild(buttonHolder);
170 |
171 | pdfButtonBatch.addEventListener("click", function(){
172 | if(floatDivChapterList.selectedOptions.length > 0){
173 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
174 | }
175 | });
176 |
177 | zipButtonBatch.addEventListener("click", function(){
178 | if(floatDivChapterList.selectedOptions.length > 0){
179 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
180 | }
181 | });
182 |
183 | let batchProgressContainer = document.createElement("div");
184 | batchProgressContainer.classList.add("md-progress-container");
185 | let batchProgressBar = document.createElement("div");
186 | batchProgressBar.classList.add("md-progress-bar");
187 | batchProgressBar.textContent = "0%";
188 | batchProgressBar.style.display = "none";
189 |
190 | batchProgressContainer.appendChild(batchProgressBar);
191 | floatDivContent.appendChild(batchProgressContainer);
192 | }
193 | // add chapters to list inside floatDiv
194 | function addChaptersToList(){
195 | let waitNote = document.querySelector("span#md-batch-note");
196 | waitNote.textContent = "wait, adding Chapters to list.";
197 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
198 |
199 | for(let i=0 ;i ul > li");
14 | // calling function
15 | addNote();
16 | addBatchDownload();
17 | addDownloadButtons();
18 | }
19 | // add a note for users
20 | function addNote(){
21 | let chapterDiv = document.querySelector("div.bixbox.bxcl");
22 | let note = document.createElement("span");
23 | note.id = "md-note";
24 | note.style.fontSize = "x-large";
25 | note.style.color = "black";
26 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
27 | }
28 | // add download button for each chapter
29 | function addDownloadButtons(){
30 | for (let i=0;i(cv)?acc+1:acc,0);
103 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
104 | if(len === chapterCount){
105 | addChaptersToList();
106 | }
107 |
108 | pdfButton.removeAttribute("disabled");
109 | zipButton.removeAttribute("disabled");
110 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
111 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
112 | }
113 | };
114 | xhttp.onerror = function (){
115 | clearConsole();
116 | };
117 | xhttp.open("GET", links[i]);
118 | xhttp.send();
119 | }
120 | }
121 | // add batch download button
122 | function addBatchDownload(){
123 | // add the floatDiv to document body
124 | let floatDiv = document.createElement("div");
125 | floatDiv.id = "md-floatDiv";
126 | floatDiv.classList.add("md-float-modal");
127 | let floatDivContent = document.createElement("div");
128 | floatDivContent.classList.add("md-float-modal-content");
129 | let floatCloseButton = document.createElement("span");
130 | floatCloseButton.classList.add("md-float-close");
131 | floatCloseButton.innerHTML = "×";
132 |
133 | floatDivContent.appendChild(floatCloseButton);
134 | floatDiv.appendChild(floatDivContent);
135 | document.body.appendChild(floatDiv);
136 |
137 | // to close floating div
138 | floatCloseButton.onclick = function() {
139 | floatDiv.style.display = "none";
140 | };
141 |
142 | // create the button that show the floatDiv
143 | let batchDownloadButton = document.createElement("button");
144 | batchDownloadButton.textContent = "Batch Download";
145 | batchDownloadButton.id = "md-batch-download-button";
146 | batchDownloadButton.title = "Download multiple chapters at once";
147 | batchDownloadButton.disabled = "true";
148 |
149 | let waitNote = document.createElement("span");
150 | waitNote.textContent = "wait, getting data from all chapters";
151 | waitNote.id = "md-batch-note";
152 | let holder = document.createElement("span");
153 | holder.appendChild(batchDownloadButton);
154 | holder.appendChild(waitNote);
155 | // append batch button after the note
156 | let theNote = document.querySelector("span#md-note");
157 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
158 |
159 | let floatDivChapterList = document.createElement("select");
160 | floatDivChapterList.id = "md-float-chapter-list";
161 | floatDivChapterList.size = 20;
162 | floatDivChapterList.multiple = true;
163 |
164 | floatDivContent.appendChild(floatDivChapterList);
165 |
166 | let pdfButtonBatch = document.createElement("button");
167 | pdfButtonBatch.classList.add("md-download-button");
168 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
169 | let zipButtonBatch = document.createElement("button");
170 | zipButtonBatch.classList.add("md-download-button");
171 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
172 |
173 | let buttonHolder = document.createElement("span");
174 | buttonHolder.appendChild(pdfButtonBatch);
175 | buttonHolder.appendChild(zipButtonBatch);
176 |
177 | floatDivContent.appendChild(buttonHolder);
178 |
179 | pdfButtonBatch.addEventListener("click", function(){
180 | if(floatDivChapterList.selectedOptions.length > 0){
181 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
182 | }
183 | });
184 |
185 | zipButtonBatch.addEventListener("click", function(){
186 | if(floatDivChapterList.selectedOptions.length > 0){
187 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
188 | }
189 | });
190 |
191 | let batchProgressContainer = document.createElement("div");
192 | batchProgressContainer.classList.add("md-progress-container");
193 | let batchProgressBar = document.createElement("div");
194 | batchProgressBar.classList.add("md-progress-bar");
195 | batchProgressBar.textContent = "0%";
196 | batchProgressBar.style.display = "none";
197 |
198 | batchProgressContainer.appendChild(batchProgressBar);
199 | floatDivContent.appendChild(batchProgressContainer);
200 | }
201 | // add chapters to list inside floatDiv
202 | function addChaptersToList(){
203 | let waitNote = document.querySelector("span#md-batch-note");
204 | waitNote.textContent = "wait, adding Chapters to list.";
205 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
206 |
207 | for(let i=0 ;i div.card-body > table.table") !== null){
18 | rows = document.querySelectorAll("div.card-table > div.card-body > table.table > tbody > tr");
19 | if(allChaptersPage){
20 | addNote();
21 | addBatchDownload();
22 | }
23 | // calling function
24 | addDownloadButtons();
25 | }
26 | // add a note for users
27 | function addNote(){
28 | let chapterDiv = document.querySelector("div.card-table");
29 | let note = document.createElement("span");
30 | note.id = "md-note";
31 | note.style.fontSize = "x-large";
32 | note.style.color = "black";
33 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
34 | }
35 | // add download button for each chapter
36 | function addDownloadButtons(){
37 | for (let i=0;i(cv)?acc+1:acc,0);
99 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
100 | if(len === chapterCount){
101 | addChaptersToList();
102 | }
103 | }
104 |
105 | pdfButton.removeAttribute("disabled");
106 | zipButton.removeAttribute("disabled");
107 |
108 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
109 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
110 | }
111 | };
112 | xhttp.onerror = function (){
113 | clearConsole();
114 | };
115 | xhttp.open("GET", links[i]);
116 | xhttp.send();
117 | }
118 | }
119 | // add batch download button
120 | function addBatchDownload(){
121 | // add the floatDiv to document body
122 | let floatDiv = document.createElement("div");
123 | floatDiv.id = "md-floatDiv";
124 | floatDiv.classList.add("md-float-modal");
125 | let floatDivContent = document.createElement("div");
126 | floatDivContent.classList.add("md-float-modal-content");
127 | let floatCloseButton = document.createElement("span");
128 | floatCloseButton.classList.add("md-float-close");
129 | floatCloseButton.innerHTML = "×";
130 |
131 | floatDivContent.appendChild(floatCloseButton);
132 | floatDiv.appendChild(floatDivContent);
133 | document.body.appendChild(floatDiv);
134 |
135 | // to close floating div
136 | floatCloseButton.onclick = function() {
137 | floatDiv.style.display = "none";
138 | };
139 |
140 | // create the button that show the floatDiv
141 | let batchDownloadButton = document.createElement("button");
142 | batchDownloadButton.textContent = "Batch Download";
143 | batchDownloadButton.classList.add("md-download-button");
144 | batchDownloadButton.id = "md-batch-download-button";
145 | batchDownloadButton.title = "Download multiple chapters at once";
146 | batchDownloadButton.disabled = "true";
147 |
148 | let waitNote = document.createElement("span");
149 | waitNote.textContent = "wait, getting data from all chapters";
150 | waitNote.id = "md-batch-note";
151 | let holder = document.createElement("span");
152 | holder.appendChild(batchDownloadButton);
153 | holder.appendChild(waitNote);
154 | // append batch button after the note
155 | let theNote = document.querySelector("span#md-note");
156 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
157 |
158 | let floatDivChapterList = document.createElement("select");
159 | floatDivChapterList.id = "md-float-chapter-list";
160 | floatDivChapterList.size = 20;
161 | floatDivChapterList.multiple = true;
162 |
163 | floatDivContent.appendChild(floatDivChapterList);
164 |
165 | let pdfButtonBatch = document.createElement("button");
166 | pdfButtonBatch.classList.add("md-download-button");
167 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
168 | let zipButtonBatch = document.createElement("button");
169 | zipButtonBatch.classList.add("md-download-button");
170 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
171 |
172 | let buttonHolder = document.createElement("span");
173 | buttonHolder.appendChild(pdfButtonBatch);
174 | buttonHolder.appendChild(zipButtonBatch);
175 |
176 | floatDivContent.appendChild(buttonHolder);
177 |
178 | pdfButtonBatch.addEventListener("click", function(){
179 | if(floatDivChapterList.selectedOptions.length > 0){
180 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
181 | }
182 | });
183 |
184 | zipButtonBatch.addEventListener("click", function(){
185 | if(floatDivChapterList.selectedOptions.length > 0){
186 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
187 | }
188 | });
189 |
190 | let batchProgressContainer = document.createElement("div");
191 | batchProgressContainer.classList.add("md-progress-container");
192 | let batchProgressBar = document.createElement("div");
193 | batchProgressBar.classList.add("md-progress-bar");
194 | batchProgressBar.textContent = "0%";
195 | batchProgressBar.style.display = "none";
196 |
197 | batchProgressContainer.appendChild(batchProgressBar);
198 | floatDivContent.appendChild(batchProgressContainer);
199 | }
200 | // add chapters to list inside floatDiv
201 | function addChaptersToList(){
202 | let waitNote = document.querySelector("span#md-batch-note");
203 | waitNote.textContent = "wait, adding Chapters to list.";
204 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
205 |
206 | for(let i=0 ;i(cv)?acc+1:acc,0);
106 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
107 | if(len === chapterCount){
108 | addChaptersToList();
109 | }
110 |
111 | pdfButton.removeAttribute("disabled");
112 | zipButton.removeAttribute("disabled");
113 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
114 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
115 | }
116 | };
117 | xhttp.onerror = function (){
118 | clearConsole();
119 | };
120 | xhttp.open("GET", links[i]);
121 | xhttp.send();
122 | }
123 | }
124 | // add batch download button
125 | function addBatchDownload(){
126 | // add the floatDiv to document body
127 | let floatDiv = document.createElement("div");
128 | floatDiv.id = "md-floatDiv";
129 | floatDiv.classList.add("md-float-modal");
130 | let floatDivContent = document.createElement("div");
131 | floatDivContent.classList.add("md-float-modal-content");
132 | let floatCloseButton = document.createElement("span");
133 | floatCloseButton.classList.add("md-float-close");
134 | floatCloseButton.innerHTML = "×";
135 | // to close floating div
136 | floatCloseButton.onclick = function() {
137 | floatDiv.style.display = "none";
138 | };
139 | floatDivContent.appendChild(floatCloseButton);
140 | floatDiv.appendChild(floatDivContent);
141 | document.body.appendChild(floatDiv);
142 | // the button that show the floatDiv
143 | // the button that show the floatDiv
144 | let batchDownloadButton = document.createElement("button");
145 | batchDownloadButton.textContent = "Batch Download";
146 | batchDownloadButton.id = "md-batch-download-button";
147 | batchDownloadButton.title = "Download multiple chapters at once";
148 | batchDownloadButton.classList.add("md-download-button");
149 | batchDownloadButton.disabled = "true";
150 |
151 | let waitNote = document.createElement("span");
152 | waitNote.textContent = "wait, getting data from all chapters";
153 | waitNote.id = "md-batch-note";
154 | let holder = document.createElement("span");
155 | holder.appendChild(batchDownloadButton);
156 | holder.appendChild(waitNote);
157 | // append batch button after the note
158 | let theNote = document.querySelector("span#md-note");
159 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
160 |
161 | let floatDivChapterList = document.createElement("select");
162 | floatDivChapterList.id = "md-float-chapter-list";
163 | floatDivChapterList.size = 20;
164 | floatDivChapterList.multiple = true;
165 |
166 | floatDivContent.appendChild(floatDivChapterList);
167 |
168 | let pdfButtonBatch = document.createElement("button");
169 | pdfButtonBatch.classList.add("md-download-button");
170 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
171 | let zipButtonBatch = document.createElement("button");
172 | zipButtonBatch.classList.add("md-download-button");
173 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
174 |
175 | let buttonHolder = document.createElement("span");
176 | buttonHolder.appendChild(pdfButtonBatch);
177 | buttonHolder.appendChild(zipButtonBatch);
178 |
179 | floatDivContent.appendChild(buttonHolder);
180 |
181 | pdfButtonBatch.addEventListener("click", function(){
182 | if(floatDivChapterList.selectedOptions.length > 0){
183 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
184 | }
185 | });
186 |
187 | zipButtonBatch.addEventListener("click", function(){
188 | if(floatDivChapterList.selectedOptions.length > 0){
189 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
190 | }
191 | });
192 |
193 | let batchProgressContainer = document.createElement("div");
194 | batchProgressContainer.classList.add("md-progress-container");
195 | let batchProgressBar = document.createElement("div");
196 | batchProgressBar.classList.add("md-progress-bar");
197 | batchProgressBar.textContent = "0%";
198 | batchProgressBar.style.display = "none";
199 |
200 | batchProgressContainer.appendChild(batchProgressBar);
201 | floatDivContent.appendChild(batchProgressContainer);
202 | }
203 | // add chapters to list inside floatDiv
204 | function addChaptersToList(){
205 | let waitNote = document.querySelector("span#md-batch-note");
206 | waitNote.textContent = "wait, adding Chapters to list.";
207 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
208 |
209 | for(let i=0 ;i h1") !== null){
14 | allChaptersPage = true;
15 | }
16 | // check if viewing chapters list page
17 | if(document.querySelector("div.bg-bg-secondary > div.grid") !== null){
18 | rows = document.querySelectorAll("div.bg-bg-secondary > div.grid");
19 | if(allChaptersPage){
20 | addNote();
21 | addBatchDownload();
22 | }
23 | // calling function
24 | addDownloadButtons();
25 | }
26 | // add a note for users
27 | function addNote(){
28 | let chapterDiv = document.querySelector("div.bg-bg-secondary > div.grid").parentElement;
29 | let note = document.createElement("span");
30 | note.id = "md-note";
31 | note.style.fontSize = "x-large";
32 | note.style.color = "black";
33 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
34 | }
35 | // add download button for each chapter
36 | function addDownloadButtons(){
37 | for (let i=0;i(cv)?acc+1:acc,0);
102 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
103 | if(len === chapterCount){
104 | addChaptersToList();
105 | }
106 | }
107 |
108 | pdfButton.removeAttribute("disabled");
109 | zipButton.removeAttribute("disabled");
110 |
111 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
112 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
113 | }
114 | };
115 | xhttp.onerror = function (){
116 | clearConsole();
117 | };
118 | xhttp.open("GET", links[i]);
119 | xhttp.send();
120 | }
121 | }
122 | // add batch download button
123 | function addBatchDownload(){
124 | // add the floatDiv to document body
125 | let floatDiv = document.createElement("div");
126 | floatDiv.id = "md-floatDiv";
127 | floatDiv.classList.add("md-float-modal");
128 | let floatDivContent = document.createElement("div");
129 | floatDivContent.classList.add("md-float-modal-content");
130 | let floatCloseButton = document.createElement("span");
131 | floatCloseButton.classList.add("md-float-close");
132 | floatCloseButton.innerHTML = "×";
133 |
134 | floatDivContent.appendChild(floatCloseButton);
135 | floatDiv.appendChild(floatDivContent);
136 | document.body.appendChild(floatDiv);
137 |
138 | // to close floating div
139 | floatCloseButton.onclick = function() {
140 | floatDiv.style.display = "none";
141 | };
142 |
143 | // create the button that show the floatDiv
144 | let batchDownloadButton = document.createElement("button");
145 | batchDownloadButton.textContent = "Batch Download";
146 | batchDownloadButton.classList.add("md-download-button");
147 | batchDownloadButton.id = "md-batch-download-button";
148 | batchDownloadButton.title = "Download multiple chapters at once";
149 | batchDownloadButton.disabled = "true";
150 |
151 | let waitNote = document.createElement("span");
152 | waitNote.textContent = "wait, getting data from all chapters";
153 | waitNote.id = "md-batch-note";
154 | let holder = document.createElement("span");
155 | holder.appendChild(batchDownloadButton);
156 | holder.appendChild(waitNote);
157 | // append batch button after the note
158 | let theNote = document.querySelector("span#md-note");
159 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
160 |
161 | let floatDivChapterList = document.createElement("select");
162 | floatDivChapterList.id = "md-float-chapter-list";
163 | floatDivChapterList.size = 20;
164 | floatDivChapterList.multiple = true;
165 |
166 | floatDivContent.appendChild(floatDivChapterList);
167 |
168 | let pdfButtonBatch = document.createElement("button");
169 | pdfButtonBatch.classList.add("md-download-button");
170 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
171 | let zipButtonBatch = document.createElement("button");
172 | zipButtonBatch.classList.add("md-download-button");
173 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
174 |
175 | let buttonHolder = document.createElement("span");
176 | buttonHolder.appendChild(pdfButtonBatch);
177 | buttonHolder.appendChild(zipButtonBatch);
178 |
179 | floatDivContent.appendChild(buttonHolder);
180 |
181 | pdfButtonBatch.addEventListener("click", function(){
182 | if(floatDivChapterList.selectedOptions.length > 0){
183 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
184 | }
185 | });
186 |
187 | zipButtonBatch.addEventListener("click", function(){
188 | if(floatDivChapterList.selectedOptions.length > 0){
189 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
190 | }
191 | });
192 |
193 | let batchProgressContainer = document.createElement("div");
194 | batchProgressContainer.classList.add("md-progress-container");
195 | let batchProgressBar = document.createElement("div");
196 | batchProgressBar.classList.add("md-progress-bar");
197 | batchProgressBar.textContent = "0%";
198 | batchProgressBar.style.display = "none";
199 |
200 | batchProgressContainer.appendChild(batchProgressBar);
201 | floatDivContent.appendChild(batchProgressContainer);
202 | }
203 | // add chapters to list inside floatDiv
204 | function addChaptersToList(){
205 | let waitNote = document.querySelector("span#md-batch-note");
206 | waitNote.textContent = "wait, adding Chapters to list.";
207 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
208 |
209 | for(let i=0 ;i(cv)?acc+1:acc,0);
96 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
97 | if(len === chapterCount){
98 | addChaptersToList();
99 | }
100 |
101 | pdfButton.removeAttribute("disabled");
102 | zipButton.removeAttribute("disabled");
103 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
104 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
105 | }
106 | };
107 | xhttp.onerror = function (){
108 | clearConsole();
109 | };
110 | xhttp.open("GET", links[i], true);
111 | xhttp.send();
112 | }
113 | }
114 | // add batch download button
115 | function addBatchDownload(){
116 | // add the floatDiv to document body
117 | let floatDiv = document.createElement("div");
118 | floatDiv.id = "md-floatDiv";
119 | floatDiv.classList.add("md-float-modal");
120 | let floatDivContent = document.createElement("div");
121 | floatDivContent.classList.add("md-float-modal-content");
122 | let floatCloseButton = document.createElement("span");
123 | floatCloseButton.classList.add("md-float-close");
124 | floatCloseButton.innerHTML = "×";
125 |
126 | floatDivContent.appendChild(floatCloseButton);
127 | floatDiv.appendChild(floatDivContent);
128 | document.body.appendChild(floatDiv);
129 |
130 | // to close floating div
131 | floatCloseButton.onclick = function() {
132 | floatDiv.style.display = "none";
133 | };
134 |
135 | // create the button that show the floatDiv
136 | let batchDownloadButton = document.createElement("button");
137 | batchDownloadButton.textContent = "Batch Download";
138 | batchDownloadButton.id = "md-batch-download-button";
139 | batchDownloadButton.title = "Download multiple chapters at once";
140 | batchDownloadButton.disabled = "true";
141 |
142 | let waitNote = document.createElement("span");
143 | waitNote.textContent = "wait, getting data from all chapters";
144 | waitNote.id = "md-batch-note";
145 | let holder = document.createElement("span");
146 | holder.appendChild(batchDownloadButton);
147 | holder.appendChild(waitNote);
148 | // append batch button after the note
149 | let theNote = document.querySelector("span#md-note");
150 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
151 |
152 | let floatDivChapterList = document.createElement("select");
153 | floatDivChapterList.id = "md-float-chapter-list";
154 | floatDivChapterList.size = 20;
155 | floatDivChapterList.multiple = true;
156 |
157 | floatDivContent.appendChild(floatDivChapterList);
158 |
159 | let pdfButtonBatch = document.createElement("button");
160 | pdfButtonBatch.classList.add("md-download-button");
161 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
162 | let zipButtonBatch = document.createElement("button");
163 | zipButtonBatch.classList.add("md-download-button");
164 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
165 |
166 | let buttonHolder = document.createElement("span");
167 | buttonHolder.appendChild(pdfButtonBatch);
168 | buttonHolder.appendChild(zipButtonBatch);
169 |
170 | floatDivContent.appendChild(buttonHolder);
171 |
172 | pdfButtonBatch.addEventListener("click", function(){
173 | if(floatDivChapterList.selectedOptions.length > 0){
174 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
175 | }
176 | });
177 |
178 | zipButtonBatch.addEventListener("click", function(){
179 | if(floatDivChapterList.selectedOptions.length > 0){
180 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
181 | }
182 | });
183 |
184 | let batchProgressContainer = document.createElement("div");
185 | batchProgressContainer.classList.add("md-progress-container");
186 | let batchProgressBar = document.createElement("div");
187 | batchProgressBar.classList.add("md-progress-bar");
188 | batchProgressBar.textContent = "0%";
189 | batchProgressBar.style.display = "none";
190 |
191 | batchProgressContainer.appendChild(batchProgressBar);
192 | floatDivContent.appendChild(batchProgressContainer);
193 | }
194 | // add chapters to list inside floatDiv
195 | function addChaptersToList(){
196 | let waitNote = document.querySelector("span#md-batch-note");
197 | waitNote.textContent = "wait, adding Chapters to list.";
198 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
199 |
200 | for(let i=chaptersData.length-1 ;i>=0 ;i--){
201 | let option = document.createElement("option");
202 | let title = chaptersData[i].title;
203 | option.value = title;
204 | option.title = title;
205 | // trim title in the middle if it's too long
206 | if(title.length > 140){
207 | let middle = title.length / 2;
208 | let difference = title.length - 140;
209 | let start = middle - (difference/2);
210 | let end = middle + (difference/2);
211 | title = title.substring(0, start) + "..." + title.substring(end);
212 | }
213 | option.textContent = title;
214 | option.imgs = chaptersData[i].images;
215 | if(option.imgs === 0){
216 | option.disabled = "true";
217 | }
218 | option.ref = chaptersData[i].referrerLink;
219 | floatDivChapterList.appendChild(option);
220 | }
221 |
222 | waitNote.textContent = "Its Ready.";
223 | waitNote.style.display = "none";
224 |
225 | let batchDownloadButton = document.querySelector("button#md-batch-download-button");
226 | batchDownloadButton.onclick = function(){
227 | let floatDiv = document.querySelector("div#md-floatDiv");
228 | floatDiv.style.display = "block";
229 | };
230 | batchDownloadButton.removeAttribute("disabled");
231 | }
232 | }
--------------------------------------------------------------------------------
/src/Scripts/readnaruto.js:
--------------------------------------------------------------------------------
1 | function readnarutoF() {
2 | // to store links of each chapter
3 | let links = [];
4 | // get all chapters displayed in the table
5 | let rows;
6 | // to store download button for easy access
7 | let pdfButtons = [];
8 | let zipButtons = [];
9 | // to store all chapters images for batch Download (store the buttons)
10 | let chaptersData = [];
11 | // check if it's view all chapters page
12 | let allChaptersPage = false;
13 | if(document.querySelector("div.container > h1") !== null){
14 | allChaptersPage = true;
15 | }
16 | // check if viewing chapters list page
17 | if(document.querySelector("div.ml-auto > div > a") !== null){
18 | rows = document.querySelectorAll("div.ml-auto > div");
19 | if(allChaptersPage){
20 | addNote();
21 | addBatchDownload();
22 | }
23 | // calling function
24 | addDownloadButtons();
25 | }
26 | // add a note for users
27 | function addNote(){
28 | let chapterDiv = document.querySelector("div.ml-auto").parentElement.parentElement;
29 | let note = document.createElement("span");
30 | note.id = "md-note";
31 | note.style.fontSize = "x-large";
32 | note.style.color = "black";
33 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
34 | }
35 | // add download button for each chapter
36 | function addDownloadButtons(){
37 | for (let i=0;i div.text-center > img");
83 |
84 | pdfButton.title = doc.querySelector("div.container h1.text-lg").textContent;
85 | if(doc.querySelector("div.container p.text-sm")){
86 | pdfButton.title += " " + doc.querySelector("div.container p.text-sm").textContent;
87 | }
88 | zipButton.title = pdfButton.title;
89 | pdfButton.imgs = [];
90 | zipButton.imgs = [];
91 | for(let img of imgs){
92 | let src = img.src;
93 | pdfButton.imgs.push(src);
94 | zipButton.imgs.push(src);
95 | }
96 |
97 | if(allChaptersPage){
98 | // store the button with all the images for batch download
99 | chaptersData[id] = {
100 | title: pdfButton.title,
101 | images: pdfButton.imgs,
102 | referrerLink: links[id]
103 | };
104 | // check if all buttons are add
105 | let len = chaptersData.reduce((acc,cv)=>(cv)?acc+1:acc,0);
106 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
107 | if(len === chapterCount){
108 | addChaptersToList();
109 | }
110 | }
111 |
112 | pdfButton.removeAttribute("disabled");
113 | zipButton.removeAttribute("disabled");
114 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
115 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
116 | }
117 | };
118 | xhttp.onerror = function (){
119 | clearConsole();
120 | };
121 | xhttp.open("GET", links[i]);
122 | xhttp.send();
123 | }
124 | }
125 | // add batch download button
126 | function addBatchDownload(){
127 | // add the floatDiv to document body
128 | let floatDiv = document.createElement("div");
129 | floatDiv.id = "md-floatDiv";
130 | floatDiv.classList.add("md-float-modal");
131 | let floatDivContent = document.createElement("div");
132 | floatDivContent.classList.add("md-float-modal-content");
133 | let floatCloseButton = document.createElement("span");
134 | floatCloseButton.classList.add("md-float-close");
135 | floatCloseButton.innerHTML = "×";
136 |
137 | floatDivContent.appendChild(floatCloseButton);
138 | floatDiv.appendChild(floatDivContent);
139 | document.body.appendChild(floatDiv);
140 |
141 | // to close floating div
142 | floatCloseButton.onclick = function() {
143 | floatDiv.style.display = "none";
144 | };
145 |
146 | // create the button that show the floatDiv
147 | let batchDownloadButton = document.createElement("button");
148 | batchDownloadButton.textContent = "Batch Download";
149 | batchDownloadButton.classList.add("md-download-button");
150 | batchDownloadButton.id = "md-batch-download-button";
151 | batchDownloadButton.title = "Download multiple chapters at once";
152 | batchDownloadButton.disabled = "true";
153 |
154 | let waitNote = document.createElement("span");
155 | waitNote.textContent = "wait, getting data from all chapters";
156 | waitNote.id = "md-batch-note";
157 | let holder = document.createElement("span");
158 | holder.appendChild(batchDownloadButton);
159 | holder.appendChild(waitNote);
160 | // append batch button after the note
161 | let theNote = document.querySelector("span#md-note");
162 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
163 |
164 | let floatDivChapterList = document.createElement("select");
165 | floatDivChapterList.id = "md-float-chapter-list";
166 | floatDivChapterList.size = 20;
167 | floatDivChapterList.multiple = true;
168 |
169 | floatDivContent.appendChild(floatDivChapterList);
170 |
171 | let pdfButtonBatch = document.createElement("button");
172 | pdfButtonBatch.classList.add("md-download-button");
173 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
174 | let zipButtonBatch = document.createElement("button");
175 | zipButtonBatch.classList.add("md-download-button");
176 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
177 |
178 | let buttonHolder = document.createElement("span");
179 | buttonHolder.appendChild(pdfButtonBatch);
180 | buttonHolder.appendChild(zipButtonBatch);
181 |
182 | floatDivContent.appendChild(buttonHolder);
183 |
184 | pdfButtonBatch.addEventListener("click", function(){
185 | if(floatDivChapterList.selectedOptions.length > 0){
186 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
187 | }
188 | });
189 |
190 | zipButtonBatch.addEventListener("click", function(){
191 | if(floatDivChapterList.selectedOptions.length > 0){
192 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
193 | }
194 | });
195 |
196 | let batchProgressContainer = document.createElement("div");
197 | batchProgressContainer.classList.add("md-progress-container");
198 | let batchProgressBar = document.createElement("div");
199 | batchProgressBar.classList.add("md-progress-bar");
200 | batchProgressBar.textContent = "0%";
201 | batchProgressBar.style.display = "none";
202 |
203 | batchProgressContainer.appendChild(batchProgressBar);
204 | floatDivContent.appendChild(batchProgressContainer);
205 | }
206 | // add chapters to list inside floatDiv
207 | function addChaptersToList(){
208 | let waitNote = document.querySelector("span#md-batch-note");
209 | waitNote.textContent = "wait, adding Chapters to list.";
210 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
211 |
212 | for(let i=0 ;i i.fa-spinner")){
32 | if(loops < 60){
33 | loops++;
34 | setTimeout(loop,1000);
35 | }
36 | }
37 | else{
38 | start();
39 | }
40 | }
41 | function start(){
42 | // check if viewing chapters list page
43 | if(document.querySelector("div.listing-chapters_wrap") !== null){
44 | // calling function
45 | addNote();
46 | addBatchDownload();
47 | addDownloadButtons();
48 | }
49 | }
50 | // add a note for users
51 | function addNote(){
52 | let chapterDiv = document.querySelector("div.listing-chapters_wrap");
53 | let note = document.createElement("span");
54 | note.id = "md-note";
55 | note.style.fontSize = "x-large";
56 | chapterDiv.insertBefore(note,chapterDiv.firstChild);
57 | }
58 | // add download button for each chapter
59 | function addDownloadButtons(){
60 | // get all chapters displayed in the table
61 | let rows = document.querySelectorAll("li.wp-manga-chapter");
62 | for (let i=0;i(cv)?acc+1:acc,0);
121 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
122 | if(len === chapterCount){
123 | addChaptersToList();
124 | }
125 |
126 | pdfButton.removeAttribute("disabled");
127 | zipButton.removeAttribute("disabled");
128 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
129 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
130 | }
131 | };
132 | xhttp.onerror = function (){
133 | //clearConsole();
134 | };
135 | xhttp.open("GET", links[i]);
136 | xhttp.send();
137 | }
138 | }
139 | // add batch download button
140 | function addBatchDownload(){
141 | // add the floatDiv to document body
142 | let floatDiv = document.createElement("div");
143 | floatDiv.id = "md-floatDiv";
144 | floatDiv.classList.add("md-float-modal");
145 | let floatDivContent = document.createElement("div");
146 | floatDivContent.classList.add("md-float-modal-content");
147 | let floatCloseButton = document.createElement("span");
148 | floatCloseButton.classList.add("md-float-close");
149 | floatCloseButton.innerHTML = "×";
150 |
151 | floatDivContent.appendChild(floatCloseButton);
152 | floatDiv.appendChild(floatDivContent);
153 | document.body.appendChild(floatDiv);
154 |
155 | // to close floating div
156 | floatCloseButton.onclick = function() {
157 | floatDiv.style.display = "none";
158 | };
159 |
160 | // create the button that show the floatDiv
161 | let batchDownloadButton = document.createElement("button");
162 | batchDownloadButton.textContent = "Batch Download";
163 | batchDownloadButton.id = "md-batch-download-button";
164 | batchDownloadButton.title = "Download multiple chapters at once";
165 | batchDownloadButton.disabled = "true";
166 |
167 | let waitNote = document.createElement("span");
168 | waitNote.textContent = "wait, getting data from all chapters";
169 | waitNote.id = "md-batch-note";
170 | let holder = document.createElement("span");
171 | holder.appendChild(batchDownloadButton);
172 | holder.appendChild(waitNote);
173 | // just to fix the margin
174 | let chapterList = document.querySelector("ul.main");
175 | chapterList.style.marginTop = "0px";
176 | // append batch button after the note
177 | let theNote = document.querySelector("span#md-note");
178 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
179 |
180 | let floatDivChapterList = document.createElement("select");
181 | floatDivChapterList.id = "md-float-chapter-list";
182 | floatDivChapterList.size = 20;
183 | floatDivChapterList.multiple = true;
184 |
185 | floatDivContent.appendChild(floatDivChapterList);
186 |
187 | let pdfButtonBatch = document.createElement("button");
188 | pdfButtonBatch.classList.add("md-download-button");
189 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
190 | let zipButtonBatch = document.createElement("button");
191 | zipButtonBatch.classList.add("md-download-button");
192 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
193 |
194 | let buttonHolder = document.createElement("span");
195 | buttonHolder.appendChild(pdfButtonBatch);
196 | buttonHolder.appendChild(zipButtonBatch);
197 |
198 | floatDivContent.appendChild(buttonHolder);
199 |
200 | pdfButtonBatch.addEventListener("click", function(){
201 | if(floatDivChapterList.selectedOptions.length > 0){
202 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
203 | }
204 | });
205 |
206 | zipButtonBatch.addEventListener("click", function(){
207 | if(floatDivChapterList.selectedOptions.length > 0){
208 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
209 | }
210 | });
211 |
212 | let batchProgressContainer = document.createElement("div");
213 | batchProgressContainer.classList.add("md-progress-container");
214 | let batchProgressBar = document.createElement("div");
215 | batchProgressBar.classList.add("md-progress-bar");
216 | batchProgressBar.textContent = "0%";
217 | batchProgressBar.style.display = "none";
218 |
219 | batchProgressContainer.appendChild(batchProgressBar);
220 | floatDivContent.appendChild(batchProgressContainer);
221 | }
222 | // add chapters to list inside floatDiv
223 | function addChaptersToList(){
224 | let waitNote = document.querySelector("span#md-batch-note");
225 | waitNote.textContent = "wait, adding Chapters to list.";
226 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
227 |
228 | for(let i=0 ;i a.comic-chapter");
39 | // calling function
40 | addNote();
41 | addBatchDownload();
42 | addDownloadButtons();
43 | }
44 | }
45 | // add a note for users
46 | function addNote(){
47 | let chapterDiv = document.querySelector("div.comic-chapters").parentElement.parentElement;
48 | let note = document.createElement("span");
49 | note.id = "md-note";
50 | note.style.fontSize = "x-large";
51 | note.style.color = "black";
52 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
53 | }
54 | // add download button for each chapter
55 | function addDownloadButtons(){
56 | for (let i=0;i res.json()).catch(error => {
100 | clearConsole();
101 | pdfButton.removeAttribute("disabled");
102 | zipButton.removeAttribute("disabled");
103 | return;
104 | });
105 | let imgs = data.images;
106 | if(imgs.length > 0){
107 | pdfButton.imgs = [];
108 | zipButton.imgs = [];
109 | for(let img of imgs){
110 | pdfButton.imgs.push(img.source_url);
111 | zipButton.imgs.push(img.source_url);
112 | }
113 |
114 | embedImages(pdfButton,zipButton,type);
115 | }
116 | else{
117 | pdfButton.textContent = "No Images";
118 | zipButton.style.display = "none";
119 | }
120 |
121 | }
122 | // add batch download button
123 | function addBatchDownload(){
124 | // add the floatDiv to document body
125 | let floatDiv = document.createElement("div");
126 | floatDiv.id = "md-floatDiv";
127 | floatDiv.classList.add("md-float-modal");
128 | let floatDivContent = document.createElement("div");
129 | floatDivContent.classList.add("md-float-modal-content");
130 | let floatCloseButton = document.createElement("span");
131 | floatCloseButton.classList.add("md-float-close");
132 | floatCloseButton.innerHTML = "×";
133 | // to close floating div
134 | floatCloseButton.onclick = function() {
135 | floatDiv.style.display = "none";
136 | };
137 | floatDivContent.appendChild(floatCloseButton);
138 | floatDiv.appendChild(floatDivContent);
139 | document.body.appendChild(floatDiv);
140 | // the button that show the floatDiv
141 | // the button that show the floatDiv
142 | let batchDownloadButton = document.createElement("button");
143 | batchDownloadButton.textContent = "Batch Download";
144 | batchDownloadButton.id = "md-batch-download-button";
145 | batchDownloadButton.title = "Download multiple chapters at once";
146 | batchDownloadButton.classList.add("md-download-button");
147 | batchDownloadButton.disabled = "true";
148 |
149 | let waitNote = document.createElement("span");
150 | waitNote.textContent = "wait, getting data from all chapters";
151 | waitNote.style.color = "black";
152 | waitNote.id = "md-batch-note";
153 | let holder = document.createElement("span");
154 | holder.appendChild(batchDownloadButton);
155 | holder.appendChild(waitNote);
156 | // append batch button after the note
157 | let theNote = document.querySelector("span#md-note");
158 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
159 |
160 | let floatDivChapterList = document.createElement("select");
161 | floatDivChapterList.id = "md-float-chapter-list";
162 | floatDivChapterList.size = 20;
163 | floatDivChapterList.multiple = true;
164 |
165 | floatDivContent.appendChild(floatDivChapterList);
166 |
167 | let pdfButtonBatch = document.createElement("button");
168 | pdfButtonBatch.classList.add("md-download-button");
169 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
170 | let zipButtonBatch = document.createElement("button");
171 | zipButtonBatch.classList.add("md-download-button");
172 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
173 |
174 | let buttonHolder = document.createElement("span");
175 | buttonHolder.appendChild(pdfButtonBatch);
176 | buttonHolder.appendChild(zipButtonBatch);
177 |
178 | floatDivContent.appendChild(buttonHolder);
179 |
180 | pdfButtonBatch.addEventListener("click", function(){
181 | if(floatDivChapterList.selectedOptions.length > 0){
182 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
183 | }
184 | });
185 |
186 | zipButtonBatch.addEventListener("click", function(){
187 | if(floatDivChapterList.selectedOptions.length > 0){
188 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
189 | }
190 | });
191 |
192 | let batchProgressContainer = document.createElement("div");
193 | batchProgressContainer.classList.add("md-progress-container");
194 | let batchProgressBar = document.createElement("div");
195 | batchProgressBar.classList.add("md-progress-bar");
196 | batchProgressBar.textContent = "0%";
197 | batchProgressBar.style.display = "none";
198 |
199 | batchProgressContainer.appendChild(batchProgressBar);
200 | floatDivContent.appendChild(batchProgressContainer);
201 | getChaptersData();
202 | }
203 | // get images from each chapter
204 | async function getChaptersData(){
205 | let waitNote = document.querySelector("span#md-batch-note");
206 | waitNote.textContent = "wait, getting images links from each chapter";
207 | waitNote.textContent = "wait, 0/"+rows.length+" Chapters.";
208 | for(let i=0;i res.json()).catch(error => {
217 | clearConsole();
218 | return;
219 | });
220 | let imgs = data.images;
221 | let images = [];
222 | for(let img of imgs){
223 | images.push(img.source_url);
224 | }
225 | chaptersData.push(
226 | {
227 | title: title,
228 | images: images,
229 | referrerLink: rows[i].href
230 | }
231 | );
232 |
233 | waitNote.textContent = "wait, "+(i+1)+"/"+rows.length+" Chapter.";
234 | }
235 | addChaptersToList();
236 | }
237 | // add chapters to list inside floatDiv
238 | function addChaptersToList(){
239 | let waitNote = document.querySelector("span#md-batch-note");
240 | waitNote.textContent = "wait, adding Chapters to list.";
241 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
242 |
243 | for(let i=0 ;i(cv)?acc+1:acc,0);
127 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
128 | if(len === chapterCount){
129 | addChaptersToList();
130 | }
131 |
132 | pdfButton.removeAttribute("disabled");
133 | zipButton.removeAttribute("disabled");
134 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
135 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
136 | }
137 | };
138 | xhttp.onerror = function (){
139 | clearConsole();
140 | };
141 | xhttp.open("GET", links[index], true);
142 | xhttp.send();
143 | // for arrays
144 | index++;
145 | }
146 | }
147 | // add batch download button
148 | function addBatchDownload(){
149 | // add the floatDiv to document body
150 | let floatDiv = document.createElement("div");
151 | floatDiv.id = "md-floatDiv";
152 | floatDiv.classList.add("md-float-modal");
153 | let floatDivContent = document.createElement("div");
154 | floatDivContent.classList.add("md-float-modal-content");
155 | let floatCloseButton = document.createElement("span");
156 | floatCloseButton.classList.add("md-float-close");
157 | floatCloseButton.innerHTML = "×";
158 |
159 | floatDivContent.appendChild(floatCloseButton);
160 | floatDiv.appendChild(floatDivContent);
161 | document.body.appendChild(floatDiv);
162 |
163 | // to close floating div
164 | floatCloseButton.onclick = function() {
165 | floatDiv.style.display = "none";
166 | };
167 |
168 | // create the button that show the floatDiv
169 | let batchDownloadButton = document.createElement("button");
170 | batchDownloadButton.textContent = "Batch Download";
171 | batchDownloadButton.id = "md-batch-download-button";
172 | batchDownloadButton.title = "Download multiple chapters at once";
173 | batchDownloadButton.disabled = "true";
174 |
175 | let waitNote = document.createElement("span");
176 | waitNote.textContent = "wait, getting data from all chapters";
177 | waitNote.id = "md-batch-note";
178 | let holder = document.createElement("span");
179 | holder.appendChild(batchDownloadButton);
180 | holder.appendChild(waitNote);
181 | // append batch button after the note
182 | let theNote = document.querySelector("span#md-note");
183 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
184 |
185 | let floatDivChapterList = document.createElement("select");
186 | floatDivChapterList.id = "md-float-chapter-list";
187 | floatDivChapterList.size = 20;
188 | floatDivChapterList.multiple = true;
189 |
190 | floatDivContent.appendChild(floatDivChapterList);
191 |
192 | let pdfButtonBatch = document.createElement("button");
193 | pdfButtonBatch.classList.add("md-download-button");
194 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
195 | let zipButtonBatch = document.createElement("button");
196 | zipButtonBatch.classList.add("md-download-button");
197 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
198 |
199 | let buttonHolder = document.createElement("span");
200 | buttonHolder.appendChild(pdfButtonBatch);
201 | buttonHolder.appendChild(zipButtonBatch);
202 |
203 | floatDivContent.appendChild(buttonHolder);
204 |
205 | pdfButtonBatch.addEventListener("click", function(){
206 | if(floatDivChapterList.selectedOptions.length > 0){
207 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
208 | }
209 | });
210 |
211 | zipButtonBatch.addEventListener("click", function(){
212 | if(floatDivChapterList.selectedOptions.length > 0){
213 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
214 | }
215 | });
216 |
217 | let batchProgressContainer = document.createElement("div");
218 | batchProgressContainer.classList.add("md-progress-container");
219 | let batchProgressBar = document.createElement("div");
220 | batchProgressBar.classList.add("md-progress-bar");
221 | batchProgressBar.textContent = "0%";
222 | batchProgressBar.style.display = "none";
223 |
224 | batchProgressContainer.appendChild(batchProgressBar);
225 | floatDivContent.appendChild(batchProgressContainer);
226 | }
227 | // add chapters to list inside floatDiv
228 | function addChaptersToList(){
229 | let waitNote = document.querySelector("span#md-batch-note");
230 | waitNote.textContent = "wait, adding Chapters to list.";
231 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
232 |
233 | for(let i=chaptersData.length-1 ;i>=0 ;i--){
234 | let option = document.createElement("option");
235 | option.textContent = chaptersData[i].title;
236 | option.value = chaptersData[i].title;
237 | option.imgs = chaptersData[i].images;
238 | if(option.imgs === 0){
239 | option.disabled = "true";
240 | }
241 | option.ref = chaptersData[i].referrerLink;
242 | floatDivChapterList.appendChild(option);
243 | }
244 |
245 | waitNote.textContent = "Its Ready.";
246 | waitNote.style.display = "none";
247 |
248 | let batchDownloadButton = document.querySelector("button#md-batch-download-button");
249 | batchDownloadButton.onclick = function(){
250 | let floatDiv = document.querySelector("div#md-floatDiv");
251 | floatDiv.style.display = "block";
252 | };
253 | batchDownloadButton.removeAttribute("disabled");
254 | }
255 | }
256 |
--------------------------------------------------------------------------------
/src/Scripts/mangasail.js:
--------------------------------------------------------------------------------
1 | function mangasailF() {
2 | // to store links of each chapter
3 | let links = [];
4 | // get all chapters displayed in the table
5 | let chapterList;
6 | // get all the rows
7 | let rows;
8 | // to store download button for easy access
9 | let pdfButtons = [];
10 | let zipButtons = [];
11 | // to store all chapters images for batch Download (store the buttons)
12 | let chaptersData = [];
13 | // check if viewing chapters list page
14 | if(document.querySelector("table.chlist") !== null){
15 | chapterList = document.querySelector("table.chlist");
16 | rows = chapterList.querySelectorAll("tbody > tr");
17 | // calling function
18 | addNote();
19 | addBatchDownload();
20 | addDownloadHeader();
21 | addDownloadButtons();
22 | }
23 | // add a note for users
24 | function addNote(){
25 | let chapterDiv = document.querySelector("table.chlist");
26 | let note = document.createElement("span");
27 | note.id = "md-note";
28 | note.style.fontSize = "x-large";
29 | note.style.color = "black";
30 | chapterDiv.parentElement.insertBefore(note,chapterDiv);
31 | }
32 |
33 | // add a header for download row
34 | function addDownloadHeader(){
35 | let tableHeader = chapterList.querySelector("thead > tr");
36 | let downloadHeader = document.createElement("th");
37 | downloadHeader.textContent = "Download";
38 | tableHeader.appendChild(downloadHeader);
39 | }
40 | // add download button for each chapter
41 | function addDownloadButtons(){
42 | for (let i = 0; i < rows.length; i++) {
43 | let pdfButton = document.createElement("button");
44 | let zipButton = document.createElement("button");
45 | pdfButton.textContent = "pdf";
46 | zipButton.textContent = "zip";
47 | pdfButton.classList.add("md-download-button");
48 | zipButton.classList.add("md-download-button");
49 | // disable the button until fetching chapter pages number
50 | pdfButton.disabled = "true";
51 | zipButton.disabled = "true";
52 | // store chapter link
53 | links[i] = rows[i].querySelector("a").href;
54 | pdfButton.referrerLink = rows[i].querySelector("a").href;
55 | // add chapter number and name to button title and trimming extra spaces
56 | pdfButton.title = rows[i].querySelector("td").textContent;
57 | pdfButton.title = pdfButton.title.trim();
58 | zipButton.title = pdfButton.title;
59 | // create new table cells to append download button for each chapter
60 | let newCell = document.createElement("td");
61 | newCell.appendChild(pdfButton);
62 | newCell.appendChild(zipButton);
63 | rows[i].appendChild(newCell);
64 | // storing download button for easy access
65 | pdfButtons.push(pdfButton);
66 | zipButtons.push(zipButton);
67 | // to fetch pages number from chapter link
68 | let xhttp = new XMLHttpRequest();
69 | // added id to each xhttp request to know what button called it
70 | xhttp.id = i;
71 | xhttp.chapterCount = rows.length;
72 | xhttp.onreadystatechange = function () {
73 | let waitNote = document.querySelector("span#md-batch-note");
74 | let id = this.id;
75 | let chapterCount = this.chapterCount;
76 | let pdfButton = pdfButtons[id];
77 | let zipButton = zipButtons[id];
78 | // in case the page does not exist display and abort request
79 | if(this.status === 404){
80 | pdfButton.textContent = "Not Found";
81 | zipButton.style.display = "none";
82 | this.abort();
83 | }
84 | // if the request succeed
85 | if (this.readyState === 4 && this.status === 200) {
86 | // convert text to html DOM
87 | let parser = new DOMParser();
88 | let doc = parser.parseFromString(this.responseText, "text/html");
89 | let scripts = doc.querySelectorAll("script");
90 |
91 | let exist = false;
92 | let script;
93 | for(let scr of scripts){
94 | script = scr.textContent.trim();
95 | if(script.includes("\"showmanga\":")){
96 | exist = true;
97 | break;
98 | }
99 | }
100 | if(!exist){
101 | return;
102 | }
103 |
104 | let startIndex = script.indexOf("{");
105 | let endIndex = script.indexOf("});")+1;
106 | let str = script.slice(startIndex, endIndex);
107 | let chapterData = JSON.parse(str);
108 | let imagesData = chapterData.showmanga.paths;
109 |
110 | pdfButton.imgs = [];
111 | zipButton.imgs = [];
112 |
113 | for(let img of imagesData){
114 | pdfButton.imgs.push(img);
115 | zipButton.imgs.push(img);
116 | }
117 |
118 | // store the button with all the images for batch download
119 | chaptersData[id] = {
120 | title: pdfButton.title,
121 | images: pdfButton.imgs,
122 | referrerLink: links[id]
123 | };
124 |
125 | // check if all buttons are add
126 | let len = chaptersData.reduce((acc,cv)=>(cv)?acc+1:acc,0);
127 | waitNote.textContent = "wait, "+len+"/"+chapterCount+" Chapters.";
128 | if(len === chapterCount){
129 | addChaptersToList();
130 | }
131 |
132 | pdfButton.removeAttribute("disabled");
133 | zipButton.removeAttribute("disabled");
134 | pdfButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,1);});
135 | zipButton.addEventListener("click", function(){embedImages(pdfButton,zipButton,2);});
136 | }
137 | };
138 | xhttp.onerror = function (){
139 | clearConsole();
140 | };
141 | xhttp.open("GET", links[i], true);
142 | xhttp.send();
143 | }
144 | }
145 | // add batch download button
146 | function addBatchDownload(){
147 | // add the floatDiv to document body
148 | let floatDiv = document.createElement("div");
149 | floatDiv.id = "md-floatDiv";
150 | floatDiv.classList.add("md-float-modal");
151 | let floatDivContent = document.createElement("div");
152 | floatDivContent.classList.add("md-float-modal-content");
153 | let floatCloseButton = document.createElement("span");
154 | floatCloseButton.classList.add("md-float-close");
155 | floatCloseButton.innerHTML = "×";
156 |
157 | floatDivContent.appendChild(floatCloseButton);
158 | floatDiv.appendChild(floatDivContent);
159 | document.body.appendChild(floatDiv);
160 |
161 | // to close floating div
162 | floatCloseButton.onclick = function() {
163 | floatDiv.style.display = "none";
164 | };
165 |
166 | // create the button that show the floatDiv
167 | let batchDownloadButton = document.createElement("button");
168 | batchDownloadButton.textContent = "Batch Download";
169 | batchDownloadButton.id = "md-batch-download-button";
170 | batchDownloadButton.classList.add("md-download-button");
171 | batchDownloadButton.title = "Download multiple chapters at once";
172 | batchDownloadButton.disabled = "true";
173 |
174 | let waitNote = document.createElement("span");
175 | waitNote.textContent = "wait, getting data from all chapters";
176 | waitNote.id = "md-batch-note";
177 | let holder = document.createElement("span");
178 | holder.appendChild(batchDownloadButton);
179 | holder.appendChild(waitNote);
180 | // append batch button after the note
181 | let theNote = document.querySelector("span#md-note");
182 | theNote.parentElement.insertBefore(holder,theNote.nextElementSibling);
183 |
184 | let floatDivChapterList = document.createElement("select");
185 | floatDivChapterList.id = "md-float-chapter-list";
186 | floatDivChapterList.size = 20;
187 | floatDivChapterList.multiple = true;
188 |
189 | floatDivContent.appendChild(floatDivChapterList);
190 |
191 | let pdfButtonBatch = document.createElement("button");
192 | pdfButtonBatch.classList.add("md-download-button");
193 | pdfButtonBatch.textContent = "Download Selected Chapter/s as PDF files";
194 | let zipButtonBatch = document.createElement("button");
195 | zipButtonBatch.classList.add("md-download-button");
196 | zipButtonBatch.textContent = "Download Selected Chapter/s as ZIP files";
197 |
198 | let buttonHolder = document.createElement("span");
199 | buttonHolder.appendChild(pdfButtonBatch);
200 | buttonHolder.appendChild(zipButtonBatch);
201 |
202 | floatDivContent.appendChild(buttonHolder);
203 |
204 | pdfButtonBatch.addEventListener("click", function(){
205 | if(floatDivChapterList.selectedOptions.length > 0){
206 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,1,floatDivChapterList,batchProgressBar);
207 | }
208 | });
209 |
210 | zipButtonBatch.addEventListener("click", function(){
211 | if(floatDivChapterList.selectedOptions.length > 0){
212 | batchEmbedImages(pdfButtonBatch,zipButtonBatch,2,floatDivChapterList,batchProgressBar);
213 | }
214 | });
215 |
216 | let batchProgressContainer = document.createElement("div");
217 | batchProgressContainer.classList.add("md-progress-container");
218 | let batchProgressBar = document.createElement("div");
219 | batchProgressBar.classList.add("md-progress-bar");
220 | batchProgressBar.textContent = "0%";
221 | batchProgressBar.style.display = "none";
222 |
223 | batchProgressContainer.appendChild(batchProgressBar);
224 | floatDivContent.appendChild(batchProgressContainer);
225 | }
226 | // add chapters to list inside floatDiv
227 | function addChaptersToList(){
228 | let waitNote = document.querySelector("span#md-batch-note");
229 | waitNote.textContent = "wait, adding Chapters to list.";
230 | let floatDivChapterList = document.querySelector("select#md-float-chapter-list");
231 |
232 | for(let i=0 ;i