Kemono访问时间记录&去广告

记录和展示上次的访问时间,仅限关注(favorites)页面

// ==UserScript==
// @name         Kemono访问时间记录&去广告
// @namespace    https://greasyfork.org/users/325815
// @version      1.6
// @description  记录和展示上次的访问时间,仅限关注(favorites)页面
// @author       monat151
// @match        http*://kemono.su/favorites*
// @match        http*://kemono.su/account/favorites/artists*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

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

    setInterval(() => {
        if (!lastvisit_appended) {
            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);
})();