Cookie Manager

For Developers Only. Control Cookies everywhere via DevTools

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

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

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

Автор
𝖢𝖸 𝖥𝗎𝗇𝗀
Инсталации дневно
0
Инсталации общо
185
Рейтинг
0 0 0
Версия
0.5
Създаден
21.12.2022
Обновен
10.01.2023
Размер
3 КБ
Лиценз
MIT
Работи на
Всички сайтове

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.