mark last read

Bookmark Kemono entries

Від 20.03.2024. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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