Sleazy Fork is available in English.

Kemono访问时间记录&去广告

移除页面的部分广告,并且在关注(favorites)页面记录和展示上次的访问时间

// ==UserScript==
// @name         Kemono访问时间记录&去广告
// @namespace    https://greasyfork.org/users/325815
// @version      1.7
// @description  移除页面的部分广告,并且在关注(favorites)页面记录和展示上次的访问时间
// @author       monat151
// @match        http*://kemono.su/*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';
    const _vd_valueKey = 'kemono_monat_last_visit'
    let lastvisit_appended = false
    let lastpage = ''

    const isFavPage = () => {
        return document.location.href.includes('favorites')
    }

    setInterval(() => {
        // 当页面路由发生更改时,重置访问时间元素的生成状态
        if (document.location.href !== lastpage) {
            lastpage = document.location.href
            lastvisit_appended = false
        }

        // 显示上次访问时间 仅限关注(favorites)页面
        if (!lastvisit_appended && isFavPage()) {
            let lastVisitDate = GM_getValue(_vd_valueKey) ?? '';
            var currDate = new Date();
            let currDateString = currDate.toLocaleString();
            GM_setValue(_vd_valueKey, currDateString);
            const _element = document.createElement('div');
            _element.style = 'justify-content: center; display: grid; margin-top: 3px;'
            _element.innerHTML = `<label>- Last Visit: ${lastVisitDate} -</label>`;
            const target = document.location.href.includes('account/favorites/artists') ? document.getElementById('filter-favorites') : document.getElementsByClassName('dropdowns')[0]
            if (target) {
                target.after(_element)
                lastvisit_appended = true
            }
        }

        // 去广告
        (['ad-container', 'root--ujvuu']).forEach(key => {
            const ads = [...(document.getElementsByClassName(key))]
            ads.forEach(ad => {
                ad.style = 'display: none;'
                ad.remove()
            })
        })
    }, 500);
})();