CookieHelper

show GM_cookie list

Tính đến 11-11-2023. Xem phiên bản mới nhất.

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 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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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         CookieHelper
// @namespace    https://github.com/cloudswave
// @version      0.1.5
// @description  show GM_cookie list
// @author       ethan
// @match        *://*/*
// @grant        GM_cookie
// @license      MIT
// ==/UserScript==
var overlay = document.createElement('div');
function getCookies(){
    try{
        GM_cookie.list({}, (cookies, error) => {
            if(error) {
                overlay.innerHTML = `error:${error}`;
                return;
            }
            if(!cookies) {
                return;
            }
            let cookieStr = "";
            for (let i = 0; i < cookies.length; i++) {
                cookieStr += `${cookies[i].name}=${cookies[i].value};`;
            }
            overlay.innerHTML = cookieStr == "" ? "无cookie" : cookieStr;
        });
    } catch(e){
        overlay.innerHTML = `error:${e}`;
    }
}

function createUI() {
	// 创建悬浮按钮
	var floatingButton = document.createElement('div');
	floatingButton.innerHTML = 'GM_cookie';
    floatingButton.style = "background: red;position: fixed;bottom: 20px;right: 20px;color: white;z-index: 9999;padding: 5px;"
	document.body.appendChild(floatingButton);

	// 创建浮层
	overlay.innerHTML = '暂无Cookie信息,请重试';
	overlay.style = "position: fixed; bottom: 0px; width: 60%; max-height: 90%; background-color: rgba(0, 0, 0, 0.8); color: white; padding: 20px; z-index: 10000; display: none; word-wrap: break-word; overflow-y: auto;"
	document.body.appendChild(overlay);

	// 点击悬浮按钮显示浮层
	floatingButton.addEventListener('click', function() {
		overlay.style.display = 'block';
        getCookies();
	});

	// 点击浮层外部隐藏浮层
	document.addEventListener('click', function(e) {
		if (e.target !== overlay && e.target !== floatingButton) {
			overlay.style.display = 'none';
		}
	});
}
(function() {
	'use strict';
	createUI();
})();