Cookie Manager

For Developers Only. Control Cookies everywhere via DevTools

Terá de instalar uma extensão como Tampermonkey, Greasemonkey ou Violentmonkey para instalar este script.

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

Terá de instalar uma extensão como Tampermonkey ou Violentmonkey para instalar este script.

Terá de instalar uma extensão como Tampermonkey ou Userscripts para instalar este script.

Terá de instalar uma extensão como Tampermonkey para instalar este script.

Terá de instalar uma extensão de gestão de scripts de utilizador para instalar este script.

(Já tenho um gestor de scripts de utilizador, deixe-me instalá-lo!)

Terá de instalar uma extensão como Stylus para instalar este estilo.

Terá de instalar uma extensão como Stylus para instalar este estilo.

Terá de instalar uma extensão como Stylus para instalar este estilo.

Terá de instalar uma extensão de gestão de estilos de utilizador para instalar este estilo.

Terá de instalar uma extensão de gestão de estilos de utilizador para instalar este estilo.

Terá de instalar uma extensão de gestão de estilos de utilizador para instalar este estilo.

(Já tenho um gestor de estilos de utilizador, deixe-me instalá-lo!)

Autor
𝖢𝖸 𝖥𝗎𝗇𝗀
Instalações diárias
1
Total de instalações
217
Classificações
0 0 0
Versão
0.5
Criado
21/12/2022
Atualizado
10/01/2023
Tamanho
3 KB
Licença
MIT
Aplica-se a
Todos os sites

This script, named "Cookie Manager", is a UserScript that is intended to be used by developers for managing cookies on a website via the developer console. It allows developers to get, set, and remove cookies using simple commands, as well as create new cookie "chefs" with specific parameters. It does so by injecting a proxy object, cook, into the unsafeWindow scope, which is an alias for the standard JavaScript global object window in Tampermonkey and other UserScript environments.

Here is a more detailed breakdown of the key components:

  1. @require: The script includes the library js-cookie, a powerful and easy-to-use JavaScript library that simplifies working with cookies. This library provides a simple, straightforward API for managing cookies, such as setting, getting, and deleting them.

  2. Initialization: The script immediately calls an anonymous function with the Cookies object from js-cookie as an argument. Inside this function, the get, set, and remove methods from Cookies are deconstructed and saved for later use.

  3. Chef Function: The script defines a function named chefFunc. This function is used to create new cookie "chefs", i.e., versions of the Cookies object with specific converters and attributes. This function is then bound to the Cookies object and added to the target object.

  4. Proxy Object: The script creates a Proxy object that is assigned to unsafeWindow.cook. The Proxy object intercepts and defines custom behavior for fundamental operations on the object it wraps. In this case, the Proxy is used to allow getting and setting cookies using dot notation. For example, cook.myvar = 'abc' sets a cookie named 'myvar' with a value of 'abc', and cook.myvar retrieves the value of the 'myvar' cookie.

The usage examples at the top of the script demonstrate how to use these capabilities. For example, cook.set('hello-world',100) sets a cookie named 'hello-world' with a value of 100, and cook.get('hello-world') retrieves the value of the 'hello-world' cookie.

This script is intended for use in the context of a browser's DevTools console, allowing developers to easily manage cookies on a website for development and testing purposes. It has a MIT license and is expected to be used on all HTTP and HTTPS websites.