CookieHelper

show GM_cookie list for Tampermonkey BETA

目前為 2023-11-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         CookieHelper
// @namespace    https://github.com/cloudswave
// @version      0.11
// @description  show GM_cookie list for Tampermonkey BETA
// @author       ethan
// @match        *://*/*
// @grant        GM_cookie
// @license      MIT
// ==/UserScript==

var overlay = document.createElement('div');
function createUI() {
	// 创建悬浮按钮
	var floatingButton = document.createElement('button');
	floatingButton.innerHTML = 'Cookie';
	floatingButton.style.position = 'fixed';
	floatingButton.style.bottom = '20px';
	floatingButton.style.right = '20px';
	floatingButton.style.zIndex = '9999';
	document.body.appendChild(floatingButton);

	// 创建浮层
	overlay.innerHTML = '';
	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-break: break-all; overflow-x: hidden;"
	document.body.appendChild(overlay);

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

	// 点击浮层外部隐藏浮层
	document.addEventListener('click', function(e) {
		if (e.target !== overlay && e.target !== floatingButton) {
			overlay.style.display = 'none';
		}
	});
}
(function() {
	'use strict';
	createUI();
	GM_cookie.list({
		domain: window.location.host
	}, (cookies) => {
		let cookieStr = "";
		for (let i = 0; i < cookies.length; i++) {
			cookieStr += `${cookies[i].name}=${cookies[i].value};`;
		}
		overlay.innerHTML = cookieStr == "" ? "无cookie" : cookieStr;
	});
})();