Cookie Downloader

Download all cookies as JSON

Click here to install Browse More Scripts
// ==UserScript==
// @name         Cookie Downloader
// @namespace    d2f87dffb50ad69fe1c4c72347febf72d79c51d3
// @version      0.1
// @description  Download all cookies as JSON
// @author       /u/AyrA_ch
// @match        https://*
// @match        http://*
// @grant        GM_cookie
// @grant        unsafeWindow
// @run-at       context-menu
// ==/UserScript==

(function () {
    'use strict';
    GM_cookie('list', {}, function (cookies, error) {
        if (!error) {
            //Decode the value property
            var decoded = JSON.parse(JSON.stringify(cookies)).map(function (v) {
                v.value = decodeURIComponent(v.value);
                return v;
            });
            //Produce formatted JSON and store as an URL
            var formatted = JSON.stringify(decoded, undefined, '    ');
            var link = URL.createObjectURL(new Blob([formatted], {
                        type: "application/json"
                    }));
            //Trigger download
            var handler = unsafeWindow.document.createElement("a");
            handler.href = link;
            handler.download = "cookies.json";
            handler.textContent = "Download";
            handler.click();
            //Remove old URLs from memory
            setTimeout(function () {
                URL.revokeObjectURL(link);
            }, 10000);
        }
    });
})();

/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

Copyright © 2018 by Kevin Gut 📧 | More services | Generated for 3.15.156.140