mark last read

Bookmark Kemono entries

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         mark last read
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Bookmark Kemono entries
// @author       SoloJessy
// @match        https://kemono.su/patreon/user/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=kemono.party
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let currPath = window.location.pathname;
    let highlightColor = "Aqua";

    document.querySelectorAll("article.post-card").forEach((cV, idx, arr) => {
        cV.style.position = "relative";

        let button = document.createElement('button');
        button.innerText = "*";
        button.style.position = "absolute";
        button.style.top = "3px";
        button.style.right = "3px";
        button.style.zIndex = "5";

        let id = cV.dataset.id;
        button.addEventListener("click", () => {
            let mark = localStorage.getItem(currPath);

            let oldTarget = document.querySelector(`[data-id='${mark}']>a`);
            if (oldTarget) oldTarget.style.background = "";

            let newTarget = document.querySelector(`[data-id='${id}']>a`);
            if (newTarget) newTarget.style.background = highlightColor;

            localStorage.setItem(currPath, id);
        });

        cV.appendChild(button);
    });

    let elem = document.querySelector("[data-id='" + localStorage.getItem(currPath) + "']>a");
    if (elem) elem.style.background = highlightColor;
})();