diff options
Diffstat (limited to 'files/zh-tw/mozilla/add-ons/webextensions/api/cookies/onchangedcause/index.html')
| -rw-r--r-- | files/zh-tw/mozilla/add-ons/webextensions/api/cookies/onchangedcause/index.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/files/zh-tw/mozilla/add-ons/webextensions/api/cookies/onchangedcause/index.html b/files/zh-tw/mozilla/add-ons/webextensions/api/cookies/onchangedcause/index.html new file mode 100644 index 0000000000..592aaf7d6d --- /dev/null +++ b/files/zh-tw/mozilla/add-ons/webextensions/api/cookies/onchangedcause/index.html @@ -0,0 +1,82 @@ +--- +title: cookies.OnChangedCause +slug: Mozilla/Add-ons/WebExtensions/API/cookies/OnChangedCause +translation_of: Mozilla/Add-ons/WebExtensions/API/cookies/OnChangedCause +--- +<div>{{AddonSidebar()}}</div> + +<p>{{WebExtAPIRef("cookies")}} API 的 <code>OnChangedCause</code> 型別,代表觸發 cookie 資料變動的原因。</p> + +<h2 id="型別">型別</h2> + +<p>此型別的所有值都是字串(string)。可用值包括:</p> + +<dl> + <dt><code>evicted</code></dt> + <dd>由於垃圾回收(garbage collection)而被刪除的 cookie。</dd> + <dt><code>expired</code></dt> + <dd>由於過期而被刪除的 cookie。</dd> + <dt><code>explicit</code></dt> + <dd>透過顯式呼叫(explicit call){{WebExtAPIRef("cookies.remove()")}} 而被插入或刪除的 cookie。</dd> + <dt><code>expired_overwrite</code></dt> + <dd>被已過期(already-expired expiration date)cookie 所覆寫的 cookie。</dd> + <dt><code>overwrite</code></dt> + <dd>A call to {{WebExtAPIRef("cookies.set()")}} overwrote this cookie with a different one.</dd> +</dl> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.cookies.OnChangedCause")}}</p> + +<h2 id="示例">示例</h2> + +<p>你可以在 cookie 變更的時候監聽被通知的 {{WebExtAPIRef("cookies.onChanged")}} 事件。此監聽器 passed 含有 <code>cause</code> 屬性,值為 <code>OnChangeCaused</code> 字串的 <code>changeInfo</code> 物件:</p> + +<pre class="brush: js">browser.cookies.onChanged.addListener(function(changeInfo) { + console.log('Cookie changed: ' + + '\n * Cookie: ' + JSON.stringify(changeInfo.cookie) + + '\n * Cause: ' + changeInfo.cause + + '\n * Removed: ' + changeInfo.removed); +});</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>致謝</strong> + +<p>此 API 基於 Chromium 的 <a href="https://developer.chrome.com/extensions/cookies"><code>chrome.cookies</code></a> API 而來,文件改作自 Chromium 程式碼裡的 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/cookies.json"><code>cookies.json</code></a>。</p> + +<p>Microsoft Edge 的相容資訊來自微軟公司,原文以創用 CC 姓名標示 3.0 美國版條款授權大眾使用。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS 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 COPYRIGHT +// OWNER 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. +</pre> +</div> |
