Skip to content
Permalink
Browse files

Add saveOnlyNext option

  • Loading branch information...
Glagan committed Jul 1, 2019
1 parent 900c1b0 commit 18bf5d2d23afa0d0c2f0b5fd32e409ada80e90c3
Showing with 31 additions and 3 deletions.
  1. +4 −0 changelog.md
  2. +1 −1 manifests/manifest.json
  3. +12 −0 options.html
  4. +2 −1 scripts/defaultOptions.js
  5. +7 −0 scripts/myMangaDex.js
  6. +5 −1 scripts/sharedFunctions.js
@@ -1,5 +1,9 @@
# Changelog

## 2.1.4

* Added saveOnlyNext option

## 2.1

* Added support for the /history page on MangaDex
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "MyMangaDex",
"version": "2.1.3",
"version": "2.1.4",
"author": "Glagan",

"description": "Automatically update your MyAnimeList manga list when reading on MangaDex.",
@@ -210,6 +210,18 @@ <h1 class="text-container py-2 px-2"><i class="fas fa-file"></i> Chapter page</h
</div>
</div>
</div>
<div class="form-group text-container p-2">
<label class="font-weight-bold">Save only next chapter <a data-default="saveOnlyNext" class="btn btn-sm btn-secondary"><i class="fas fa-trash"></i><span class="d-none d-xl-inline"> Restore default</span></a></label>
<p class="d-none d-xl-block">Update MyAnimeList only if the chapter you are reading is a following chapter of your last read chapter.</p>
<div data-option="saveOnlyNext" data-type="checkbox" class="col px-0 my-auto input-group">
<div class="input-group-prepend">
<button type="button" class="btn btn-success input-prepend col px-2">Enabled</button>
</div>
<div class="input-group-append">
<button type="button" class="btn btn-secondary input-append col px-2 active">Disabled</button>
</div>
</div>
</div>
<div class="form-group text-container p-2">
<label class="font-weight-bold">Save all opened chapters <a data-default="saveAllOpened" class="btn btn-sm btn-secondary"><i class="fas fa-trash"></i><span class="d-none d-xl-inline"> Restore default</span></a></label>
<p class="d-none d-xl-block">Save a list of all opened chapters for each manga to highlight them in a title page and display them inside tooltips.</p>
@@ -19,6 +19,7 @@ let defaultOptions = {
openedChaptersColor: "rgba(102, 75, 180, 0.6)",
hideLowerChapters: true,
saveOnlyHigher: true,
saveOnlyNext: false,
saveAllOpened: true,
maxChapterSaved: 100,
updateHistoryPage: false,
@@ -35,5 +36,5 @@ let defaultOptions = {
isLoggedIn: false,
token: "",
version: 2.1,
subVersion: 3
subVersion: 4
};
@@ -92,6 +92,13 @@ class MyMangaDex {
return;
}

let isNext = (realChapter == this.manga.lastMyAnimeListChapter || (realChapter == this.manga.lastMyAnimeListChapter+1 ||
(!this.options.saveOnlyHigher && realChapter == this.manga.lastMyAnimeListChapter-1)));
if (usePepper && this.options.saveOnlyNext && this.manga.lastMyAnimeListChapter > 0 && !isNext) {
this.notification(NOTIFY.INFO, "Not updated", "The current chapter is not the next one and it wasn't updated on MyAnimelist.", "https://mangadex.org/images/manga/" + this.manga.mangaDexId + ".thumb.jpg");
return;
}

let oldStatus = this.manga.status;
let {requestURL, body} = buildMyAnimeListBody(usePepper, this.manga, this.csrf, setStatus);

@@ -158,7 +158,11 @@ async function loadOptions() {
}
}

// Nothing in > 2.1.1
// Added saveOnlyNext in 2.1.4
if (data.subVersion < 4) {
data.saveOnlyNext = false;
}

data.subVersion = defaultOptions.subVersion;
}
await storageSet("options", data);

0 comments on commit 18bf5d2

Please sign in to comment.
You can’t perform that action at this time.