2016-12-20 3 views

答えて

2

これは、(コンソールで実行します)動作するはずです:

origDescriptor = Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie'); 
Object.defineProperty(document, 'cookie', { 
    get() { 
    return origDescriptor.get.call(this); 
    }, 
    set(value) { 
    debugger; 
    return origDescriptor.set.call(this, value); 
    }, 
    enumerable: true, 
    configurable: true 
}); 
+0

FireBugの魅力のように機能します。助けてくれてありがとう[fflorent](http://stackoverflow.com/users/915465/fflorent)! – haba713

0

Ifステートメントでそれを設定してみてください。

if(document.cookie.indexOf('...') >= 0){ 
    debugger; 
} 

注:firefoxを使用するときは、コンソールを開いておく必要があります。クロムではそうではありません。

+0

これは 'document.cookie ='行の実行を一時停止しません。私は特定のクッキーが設定されているJSコードのどこにあるのかを調べようとしています。 – haba713

0

https://stackoverflow.com/a/41247745/2158271はChromeで動作するようには思えません。 HTMLの→ヘッドブロックの初めにこのスニペットを追加すると、正常に動作します:

<script type="text/javascript"> 
    function debugAccess(obj, prop, debugGet){ 
     var origValue = obj[prop]; 
     Object.defineProperty(obj, prop, { 
      get: function() { 
       if (debugGet) 
        debugger; 
       return origValue; 
      }, 
      set: function(val) { 
       debugger; 
       return origValue = val; 
      } 
     }); 
    }; 
    debugAccess(document, 'cookie'); 
</script> 

詳細については、this Angular University pageを参照してください。

関連する問題