HPMOR Checklist

Adds a checkbox to each chapter. Stores checked history.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        HPMOR Checklist
// @namespace   http://jaredtylermiller.com
// @description Adds a checkbox to each chapter. Stores checked history.
// @include     http://hpmor.com/
// @include     http://hpmor.com/chapter/*
// @require     https://code.jquery.com/jquery-1.11.2.min.js
// @require     http://cdnjs.cloudflare.com/ajax/libs/store.js/1.3.14/store.min.js
// @version     1.0
// ==/UserScript==


// Grab chapter from URL if possible
var chapterPath = window.location.pathname.split("/")

// If so, let's store that we've read it in DB
if (chapterPath.length === 3) {
  var chapter = chapterPath[chapterPath.length -1]
  store.set(chapter, true)
}

// Add a checkbox to every chapter and check if it needed
$(".toclist a").each(function() {
  var link = $(this),
      chapter = link.closest("li").index()+1

  link.before("<input type='checkbox'>")
  saved = store.get(chapter)

  if (typeof saved !== "undefined") {
    link.siblings("input").prop("checked", saved)
  }
})

// Store in DB if we click a link
$(".toclist a").click(function(e) {
  e.preventDefault()
  var chapter = $(this).closest("li").index()+1,
      checkbox = $(this).find("input"),
      checked = checkbox.prop("checked")

  store.set(chapter, !checked)
  checkbox.prop("checked", !checked)
  window.location.href = $(this).attr("href")
})

// Store when clicking checkboxes
$(".toclist input").click(function(e) {
  var chapter = $(this).closest("li").index()+1,
      checked = $(this).prop("checked")

  store.set(chapter, checked)
})