zoukankan      html  css  js  c++  java
  • hook cookie

    // ==UserScript==
    // @name         cookie
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  try to take over the world!
    // @author       公众号:python学习开发
    // @include      *
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        var cookie_cache = document.cookie;
        Object.defineProperty(document, 'cookie', {
            get: function() {
                console.log(cookie_cache);
                return cookie_cache;
            },
            set: function(val) {
                debugger;
                var cookie = val.split(";")[0];
                var ncookie = cookie.split("=");
                var flag = false;
                var cache = cookie_cache.split(";");
                cache = cache.map(function(a){
                    if (a.split("=")[0] === ncookie[0]){
                        flag = true;
                        return cookie;
                    }
                    return a;
                })
                cookie_cache = cache.join(";");
                if (!flag){
                    cookie_cache += cookie + ";";
                }
            },
        });
    
    })();
    
  • 相关阅读:
    GIT 相关
    createFile
    值传递、指针传递、引用传递
    Sightseeing trip
    find the longest of the shortest
    Laurenty and Shop
    Dima and Lisa
    Marina and Vasya
    Kolya and Tanya
    Two Substrings
  • 原文地址:https://www.cnblogs.com/c-x-a/p/11813419.html
Copyright © 2011-2022 走看看