Cat Cleaner+++

gives user possibility to clear website data, directly from page user uses.

当前为 2022-08-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Cat Cleaner+++
// @namespace -
// @version 1.0.0
// @description gives user possibility to clear website data, directly from page user uses.
// @author NotYou
// @include *
// @run-at document-body
// @license GPL-3.0-or-later
// @grant GM.registerMenuCommand
// @grant GM.notification
// ==/UserScript==

/*

ICONS LICENSED UNDER "Linkware" LICENSE

BACKLINK: http://www.iconka.com

README FILE: https://iconarchive.com/icons/iconka/meow/meow-me.txt

*/

let t = 'Cat clearer+++'

function clearCookie() {
    let cookieLength = document.cookie.split(';').length
    for(let i = 0; i < cookieLength; i++) {
        let cookie = document.cookie
        document.cookie = cookie + ";max-age=0"
    }
    GM.notification('Cookies for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow/128/cat-clean-icon.png')
}

function clearLocalStorage() {
    localStorage.clear()
    GM.notification('Local storage for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow/128/cat-walk-icon.png')
}

function clearSessionStorage() {
    sessionStorage.clear()
    GM.notification('Session storage for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow/128/cat-poo-icon.png')
}

function clearCache() {
    caches.keys().then((keyList) => Promise.all(keyList.map((key) => caches.delete(key))))
    caches.delete()
    GM.notification('Chache storage for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow-2/128/cat-paper-icon.png')
}

function clearIndexedDB() {
    indexedDB.deleteDatabase(true)
    GM.notification('Indexed database for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow-2/128/cat-paper-icon.png')
}

function clearEverything() {
    let cookieLength = document.cookie.split(';').length
    for(let i = 0; i < cookieLength; i++) {
        let cookie = document.cookie
        document.cookie = cookie + ";max-age=0"
    }

    localStorage.clear()

    sessionStorage.clear()

    caches.keys().then((keyList) => Promise.all(keyList.map((key) => caches.delete(key))))
    caches.delete()

    indexedDB.deleteDatabase(true)

    GM.notification('Cookies, local storage, session storage, cache storage, indexed db for that website cleared.', t, 'https://icons.iconarchive.com/icons/iconka/meow/128/cat-grumpy-icon.png')
}

GM.registerMenuCommand('Clear everything', clearEverything)
GM.registerMenuCommand('Clear cookies', clearCookie)
GM.registerMenuCommand('Clear local storage', clearLocalStorage)
GM.registerMenuCommand('Clear session storage', clearSessionStorage)
GM.registerMenuCommand('Clear cache storage', clearCache)
GM.registerMenuCommand('Clear indexed DB', clearIndexedDB)