mark last read

Bookmark Kemono entries

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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;
})();