gbCookies

优雅的搜索引擎跳转助手专用COOKIES处理函数

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/460897/1684038/gbCookies.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          gbCookies
// @description   cookies tool for SearchEngine Assistant
// @author        F9y4ng
// @version       1.9.1
// @license       GPL-3.0-only
// ==/UserScript==

(function (c) {
  class d {
    getItem(a) {
      a = new RegExp("(?:(?:^|.*;)\\s*" + a.replace(/[-.+*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$");
      return decodeURIComponent(c.document.cookie.replace(a, "$1")) || null;
    }
    setItem(a) {
      var b = a.sKey,
        f = a.sValue,
        e = a.sEnd,
        h = a.sPath,
        k = a.sDomain,
        l = a.sSameSite;
      a = a.sSecure;
      if (!b || /^(?:expires|max-age|path|domain|samesite|secure)$/i.test(b)) return !1;
      var g = "";
      if (e)
        switch (e.constructor) {
          case Number:
            g = Infinity === e ? "; expires=Sat, 23 Oct 2099 13:31:44 GMT" : "; expires=" + new Date(Date.now() + 864e5 * e).toUTCString();
            break;
          case String:
            g = "; expires=" + new Date(e).toUTCString();
            break;
          case Date:
            g = "; expires=" + e.toUTCString();
        }
      c.document.cookie = b + "=" + f + g + (k ? "; domain=" + k : "") + (h ? "; path=" + h : "") + (l ? "; SameSite=" + l : "") + (a ? "; secure" : "");
      return !0;
    }
    removeItem(a) {
      var b = a.sKey,
        f = a.sPath;
      a = a.sDomain;
      if (!b || !this.hasItem(b)) return !1;
      c.document.cookie = b + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (a ? "; domain=" + a : "") + (f ? "; path=" + f : "");
      return !0;
    }
    hasItem(a) {
      return new RegExp("(?:^|;\\s*)" + a.replace(/[-.+*]/g, "\\$&") + "\\s*\\=").test(c.document.cookie);
    }
  }
  "undefined" === typeof c.GBCookies && (c.GBCookies = d);
  return d;
})("undefined" !== typeof window ? window : this);
//# sourceMappingURL=gbCookies.js.map