CookieManager

简单而强大的Cookie编辑器,允许您快速创建、编辑和删除Cookie

目前为 2025-03-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name CookieManager
  3. // @namespace https://github.com/WhiteSevs/TamperMonkeyScript
  4. // @version 2025.3.25
  5. // @author WhiteSevs
  6. // @description 简单而强大的Cookie编辑器,允许您快速创建、编辑和删除Cookie
  7. // @license GPL-3.0-only
  8. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAA/NJREFUeF7tWm1u4jAQjVHusfR3jMQNlp5ky0l2e5K2Jym9ARLO79JzEMgyKF5FqeN5YzuwQPoHqRl/zPObN5NxVHbnf+rO/c9GAEYG3DkCYwjcOQFGETxbCGitF1mWLeq6/qGUmtZ1PW1+t0qpN2PMn0uwcTAA5vP5tKqqp8bhJ8C5R2PMCrBLajIIAFprOs3fkp0eGfFaluVSMiaFbVIAQhy3Tlw1AA3dXyjGQ0/lagFoxO091PGrZkAq5wmEq2NASuevDgCB889HXVjleb6tqmraaASbHeq6ptpgm+f5cr1eb2PDyzdenAUawfsENuXM60VRvBydQ+oCWmJljHkE1go2EQOgtSbB86q9L54FAJIubMuyfAj2DhgoAmA2m1FlR+nO+6eUWm42m9c+IwREO9YYI9ojt7fuc9HkRVF8Uv0OLPLsq+0F82T/DQDCKs8bu1rrGgDxZELh5LKdTCYfPpah88MMkGy6WdwpghL6A054mQaMx/oBaOy3F2xS2ZtNg/SsqqqocrnrUAqRhBggTF0I8MlsYjUCAiCA/skc5CYaHACO/rZq42oDzpHQ55RyXWNRgWQZ0Ef/xvFlu4sjzBShPkPjXPtzDQwGIM/zB1edzjEG2n06I7aUZgFwpS3u1dVX6LSyg83zv8DiKgSWeABczkSUut82ZJun0h4iggaSJhEGuKq20FLXWRylaKm5ABkMAN/Efb0CbjNDCSiXJlkGeOL5GwuYk/TG4xDiyYFOrGEB8NXuVtCoe0M3Pb445jbDVZs0/rRhpegX7T4nEUFJB8erTX3iyTVJulkHFU4uW6EMEN/y9KFgGdPuFQAC2HuK3JtlKgCIbtF9f8ebom12euncV3DRfFxzlkvXEAM4eiL5OMbGp+Lc3rgMAAHQIM02QmOcZMb23hr7AEDoLwEgeRgIAOstuny1A0J/GACOagJnxKYu4UTiH6E/DAAZpipUQvsHRGlqhDb1Bm3Jd8ME9wrZQsgeGbFgt9u9h765nbN/gJ6+iAGxLDhX/wCNfXuwMANoAFC0OGOcU2TJRQkjImzp2x0vAsCCIA0F7lS4ig5RTu5do28OMQAtJiA3xHbd0P4B4ru1CfrKLAgAqR6E9A8knmdZFuS8WAS7mxI2MaT9AxSDYOejAZBqgqR/wHmPtr25eYJDoD1xbI3AbbL7PFTwXOskAaAljPQBxWBt7r6yWApg2z4ZAO2Kkb4RTtnmHsLxoEJIgjSFxX6/XxwOh5+Cj6L+LdF6Z/gY8kvy5AxwgdQG46S8nc/lm/9RY5U+j/uixid6uSk5lEE1IHYjlxp/FgZcyjlk3REABKVbthkZcMuni/g2MgBB6ZZt/gJwetZfo7objAAAAABJRU5ErkJggg==
  9. // @supportURL https://github.com/WhiteSevs/TamperMonkeyScript/issues
  10. // @match *://*/*
  11. // @require https://fastly.jsdelivr.net/gh/WhiteSevs/TamperMonkeyScript@86be74b83fca4fa47521cded28377b35e1d7d2ac/lib/CoverUMD/index.js
  12. // @require https://fastly.jsdelivr.net/npm/@whitesev/utils@2.6.3/dist/index.umd.js
  13. // @require https://fastly.jsdelivr.net/npm/@whitesev/domutils@1.5.1/dist/index.umd.js
  14. // @require https://fastly.jsdelivr.net/npm/@whitesev/pops@2.0.2/dist/index.umd.js
  15. // @require https://fastly.jsdelivr.net/npm/qmsg@1.3.0/dist/index.umd.js
  16. // @connect *
  17. // @grant GM_cookie
  18. // @grant GM_getValue
  19. // @grant GM_info
  20. // @grant GM_registerMenuCommand
  21. // @grant GM_setValue
  22. // @grant GM_unregisterMenuCommand
  23. // @grant unsafeWindow
  24. // @run-at document-start
  25. // ==/UserScript==
  26.  
  27. (function (Qmsg, DOMUtils, Utils, pops) {
  28. 'use strict';
  29.  
  30. var _a;
  31. var _GM_cookie = /* @__PURE__ */ (() => typeof GM_cookie != "undefined" ? GM_cookie : void 0)();
  32. var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  33. var _GM_info = /* @__PURE__ */ (() => typeof GM_info != "undefined" ? GM_info : void 0)();
  34. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  35. var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  36. var _GM_unregisterMenuCommand = /* @__PURE__ */ (() => typeof GM_unregisterMenuCommand != "undefined" ? GM_unregisterMenuCommand : void 0)();
  37. var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
  38. var _monkeyWindow = /* @__PURE__ */ (() => window)();
  39. const PanelSettingConfig = {
  40. /** Toast位置 */
  41. qmsg_config_position: {
  42. key: "qmsg-config-position",
  43. defaultValue: "bottom"
  44. },
  45. /** 最多显示的数量 */
  46. qmsg_config_maxnums: {
  47. key: "qmsg-config-maxnums",
  48. defaultValue: 3
  49. },
  50. /** 逆序弹出 */
  51. qmsg_config_showreverse: {
  52. key: "qmsg-config-showreverse",
  53. defaultValue: false
  54. }
  55. };
  56. const _SCRIPT_NAME_ = "CookieManager";
  57. const utils = Utils.noConflict();
  58. const domUtils = DOMUtils.noConflict();
  59. const __pops = pops;
  60. const log = new utils.Log(
  61. _GM_info,
  62. _unsafeWindow.console || _monkeyWindow.console
  63. );
  64. const SCRIPT_NAME = ((_a = _GM_info == null ? void 0 : _GM_info.script) == null ? void 0 : _a.name) || _SCRIPT_NAME_;
  65. const DEBUG = false;
  66. log.config({
  67. debug: DEBUG,
  68. logMaxCount: 1e3,
  69. autoClearConsole: true,
  70. tag: true
  71. });
  72. Qmsg.config(
  73. Object.defineProperties(
  74. {
  75. html: true,
  76. autoClose: true,
  77. showClose: false
  78. },
  79. {
  80. position: {
  81. get() {
  82. return PopsPanel.getValue(
  83. PanelSettingConfig.qmsg_config_position.key,
  84. PanelSettingConfig.qmsg_config_position.defaultValue
  85. );
  86. }
  87. },
  88. maxNums: {
  89. get() {
  90. return PopsPanel.getValue(
  91. PanelSettingConfig.qmsg_config_maxnums.key,
  92. PanelSettingConfig.qmsg_config_maxnums.defaultValue
  93. );
  94. }
  95. },
  96. showReverse: {
  97. get() {
  98. return PopsPanel.getValue(
  99. PanelSettingConfig.qmsg_config_showreverse.key,
  100. PanelSettingConfig.qmsg_config_showreverse.defaultValue
  101. );
  102. }
  103. },
  104. zIndex: {
  105. get() {
  106. let maxZIndex = Utils.getMaxZIndex();
  107. let popsMaxZIndex = pops.config.InstanceUtils.getPopsMaxZIndex().zIndex;
  108. return Utils.getMaxValue(maxZIndex, popsMaxZIndex) + 100;
  109. }
  110. }
  111. }
  112. )
  113. );
  114. __pops.GlobalConfig.setGlobalConfig({
  115. zIndex: () => {
  116. let maxZIndex = Utils.getMaxZIndex(void 0, void 0, ($ele) => {
  117. var _a2;
  118. if ((_a2 = $ele == null ? void 0 : $ele.classList) == null ? void 0 : _a2.contains("qmsg-shadow-container")) {
  119. return false;
  120. }
  121. if (($ele == null ? void 0 : $ele.closest("qmsg")) && $ele.getRootNode() instanceof ShadowRoot) {
  122. return false;
  123. }
  124. });
  125. let popsMaxZIndex = pops.config.InstanceUtils.getPopsMaxZIndex().zIndex;
  126. return Utils.getMaxValue(maxZIndex, popsMaxZIndex) + 100;
  127. },
  128. mask: {
  129. // 开启遮罩层
  130. enable: true,
  131. // 取消点击遮罩层的事件
  132. clickEvent: {
  133. toClose: false,
  134. toHide: false
  135. }
  136. }
  137. });
  138. const GM_Menu = new utils.GM_Menu({
  139. GM_getValue: _GM_getValue,
  140. GM_setValue: _GM_setValue,
  141. GM_registerMenuCommand: _GM_registerMenuCommand,
  142. GM_unregisterMenuCommand: _GM_unregisterMenuCommand
  143. });
  144. ({
  145. Object: {
  146. defineProperty: _unsafeWindow.Object.defineProperty
  147. },
  148. Function: {
  149. apply: _unsafeWindow.Function.prototype.apply,
  150. call: _unsafeWindow.Function.prototype.call
  151. },
  152. Element: {
  153. appendChild: _unsafeWindow.Element.prototype.appendChild
  154. },
  155. setTimeout: _unsafeWindow.setTimeout
  156. });
  157. utils.addStyle.bind(utils);
  158. document.querySelector.bind(document);
  159. document.querySelectorAll.bind(document);
  160. const utilsCookieManager = new Utils.GM_Cookie();
  161. const KEY = "GM_Panel";
  162. const ATTRIBUTE_INIT = "data-init";
  163. const ATTRIBUTE_KEY = "data-key";
  164. const ATTRIBUTE_DEFAULT_VALUE = "data-default-value";
  165. const ATTRIBUTE_INIT_MORE_VALUE = "data-init-more-value";
  166. const PROPS_STORAGE_API = "data-storage-api";
  167. const UISwitch = function(text, key, defaultValue, clickCallBack, description, afterAddToUListCallBack) {
  168. let result = {
  169. text,
  170. type: "switch",
  171. description,
  172. attributes: {},
  173. props: {},
  174. getValue() {
  175. return Boolean(
  176. this.props[PROPS_STORAGE_API].get(key, defaultValue)
  177. );
  178. },
  179. callback(event, __value) {
  180. let value = Boolean(__value);
  181. log.success(`${value ? "开启" : "关闭"} ${text}`);
  182. if (typeof clickCallBack === "function") {
  183. if (clickCallBack(event, value)) {
  184. return;
  185. }
  186. }
  187. this.props[PROPS_STORAGE_API].set(key, value);
  188. },
  189. afterAddToUListCallBack
  190. };
  191. Reflect.set(result.attributes, ATTRIBUTE_KEY, key);
  192. Reflect.set(result.attributes, ATTRIBUTE_DEFAULT_VALUE, defaultValue);
  193. Reflect.set(result.props, PROPS_STORAGE_API, {
  194. get(key2, defaultValue2) {
  195. return PopsPanel.getValue(key2, defaultValue2);
  196. },
  197. set(key2, value) {
  198. PopsPanel.setValue(key2, value);
  199. }
  200. });
  201. return result;
  202. };
  203. const UISelect = function(text, key, defaultValue, data, callback, description) {
  204. let selectData = [];
  205. if (typeof data === "function") {
  206. selectData = data();
  207. } else {
  208. selectData = data;
  209. }
  210. let result = {
  211. text,
  212. type: "select",
  213. description,
  214. attributes: {},
  215. props: {},
  216. getValue() {
  217. return this.props[PROPS_STORAGE_API].get(key, defaultValue);
  218. },
  219. callback(event, isSelectedValue, isSelectedText) {
  220. let value = isSelectedValue;
  221. log.info(`选择:${isSelectedText}`);
  222. this.props[PROPS_STORAGE_API].set(key, value);
  223. if (typeof callback === "function") {
  224. callback(event, value, isSelectedText);
  225. }
  226. },
  227. data: selectData
  228. };
  229. Reflect.set(result.attributes, ATTRIBUTE_KEY, key);
  230. Reflect.set(result.attributes, ATTRIBUTE_DEFAULT_VALUE, defaultValue);
  231. Reflect.set(result.props, PROPS_STORAGE_API, {
  232. get(key2, defaultValue2) {
  233. return PopsPanel.getValue(key2, defaultValue2);
  234. },
  235. set(key2, value) {
  236. PopsPanel.setValue(key2, value);
  237. }
  238. });
  239. return result;
  240. };
  241. const Component_Common = {
  242. id: "view-general",
  243. title: "通用",
  244. forms: [
  245. {
  246. text: "Toast配置",
  247. type: "forms",
  248. forms: [
  249. UISelect(
  250. "Toast位置",
  251. PanelSettingConfig.qmsg_config_position.key,
  252. PanelSettingConfig.qmsg_config_position.defaultValue,
  253. [
  254. {
  255. value: "topleft",
  256. text: "左上角"
  257. },
  258. {
  259. value: "top",
  260. text: "顶部"
  261. },
  262. {
  263. value: "topright",
  264. text: "右上角"
  265. },
  266. {
  267. value: "left",
  268. text: "左边"
  269. },
  270. {
  271. value: "center",
  272. text: "中间"
  273. },
  274. {
  275. value: "right",
  276. text: "右边"
  277. },
  278. {
  279. value: "bottomleft",
  280. text: "左下角"
  281. },
  282. {
  283. value: "bottom",
  284. text: "底部"
  285. },
  286. {
  287. value: "bottomright",
  288. text: "右下角"
  289. }
  290. ],
  291. (event, isSelectValue, isSelectText) => {
  292. log.info("设置当前Qmsg弹出位置" + isSelectText);
  293. },
  294. "Toast显示在页面九宫格的位置"
  295. ),
  296. UISelect(
  297. "最多显示的数量",
  298. PanelSettingConfig.qmsg_config_maxnums.key,
  299. PanelSettingConfig.qmsg_config_maxnums.defaultValue,
  300. [
  301. {
  302. value: 1,
  303. text: "1"
  304. },
  305. {
  306. value: 2,
  307. text: "2"
  308. },
  309. {
  310. value: 3,
  311. text: "3"
  312. },
  313. {
  314. value: 4,
  315. text: "4"
  316. },
  317. {
  318. value: 5,
  319. text: "5"
  320. }
  321. ],
  322. void 0,
  323. "限制Toast显示的数量"
  324. ),
  325. UISwitch(
  326. "逆序弹出",
  327. PanelSettingConfig.qmsg_config_showreverse.key,
  328. PanelSettingConfig.qmsg_config_showreverse.defaultValue,
  329. void 0,
  330. "修改Toast弹出的顺序"
  331. )
  332. ]
  333. },
  334. {
  335. text: "Cookie配置",
  336. type: "forms",
  337. forms: [
  338. UISwitch(
  339. "启用GM_cookie Api",
  340. "use-GM-cookie",
  341. false,
  342. void 0,
  343. "获取到的Cookie信息会更完善,需要脚本管理器支持该函数"
  344. )
  345. ]
  346. }
  347. ]
  348. };
  349. const PanelUISize = {
  350. /**
  351. * 一般设置界面的尺寸
  352. */
  353. setting: {
  354. get width() {
  355. return window.innerWidth < 550 ? "88vw" : "550px";
  356. },
  357. get height() {
  358. return window.innerHeight < 450 ? "70vh" : "450px";
  359. }
  360. },
  361. /**
  362. * 信息界面,一般用于提示信息之类
  363. */
  364. info: {
  365. get width() {
  366. return window.innerWidth < 350 ? "350px" : "350px";
  367. },
  368. get height() {
  369. return window.innerHeight < 250 ? "250px" : "250px";
  370. }
  371. }
  372. };
  373. const PopsPanel = {
  374. /** 数据 */
  375. $data: {
  376. __data: null,
  377. __oneSuccessExecMenu: null,
  378. __onceExec: null,
  379. __listenData: null,
  380. /**
  381. * 菜单项的默认值
  382. */
  383. get data() {
  384. if (PopsPanel.$data.__data == null) {
  385. PopsPanel.$data.__data = new utils.Dictionary();
  386. }
  387. return PopsPanel.$data.__data;
  388. },
  389. /**
  390. * 成功只执行了一次的项
  391. */
  392. get oneSuccessExecMenu() {
  393. if (PopsPanel.$data.__oneSuccessExecMenu == null) {
  394. PopsPanel.$data.__oneSuccessExecMenu = new utils.Dictionary();
  395. }
  396. return PopsPanel.$data.__oneSuccessExecMenu;
  397. },
  398. /**
  399. * 成功只执行了一次的项
  400. */
  401. get onceExec() {
  402. if (PopsPanel.$data.__onceExec == null) {
  403. PopsPanel.$data.__onceExec = new utils.Dictionary();
  404. }
  405. return PopsPanel.$data.__onceExec;
  406. },
  407. /** 脚本名,一般用在设置的标题上 */
  408. get scriptName() {
  409. return SCRIPT_NAME;
  410. },
  411. /** 菜单项的总值在本地数据配置的键名 */
  412. key: KEY,
  413. /** 菜单项在attributes上配置的菜单键 */
  414. attributeKeyName: ATTRIBUTE_KEY,
  415. /** 菜单项在attributes上配置的菜单默认值 */
  416. attributeDefaultValueName: ATTRIBUTE_DEFAULT_VALUE
  417. },
  418. /** 监听器 */
  419. $listener: {
  420. /**
  421. * 值改变的监听器
  422. */
  423. get listenData() {
  424. if (PopsPanel.$data.__listenData == null) {
  425. PopsPanel.$data.__listenData = new utils.Dictionary();
  426. }
  427. return PopsPanel.$data.__listenData;
  428. }
  429. },
  430. init() {
  431. let contentConfigList = this.getPanelContentConfig();
  432. this.initPanelConfigDefaultValue([...contentConfigList]);
  433. this.registerMenu();
  434. },
  435. /** 判断是否是顶层窗口 */
  436. isTopWindow() {
  437. return _unsafeWindow.top === _unsafeWindow.self;
  438. },
  439. /** 初始化进行注册(不可用)油猴菜单 */
  440. registerMenu() {
  441. if (!this.isTopWindow()) {
  442. return;
  443. }
  444. GM_Menu.add([
  445. {
  446. key: "show_pops_panel_setting",
  447. text: "⚙ 设置",
  448. autoReload: false,
  449. isStoreValue: false,
  450. showText(text) {
  451. return text;
  452. },
  453. callback: () => {
  454. this.showPanel();
  455. }
  456. }
  457. ]);
  458. },
  459. /** 初始化菜单项的默认值保存到本地数据中 */
  460. initPanelConfigDefaultValue(contentConfigList) {
  461. let that = this;
  462. function initDefaultValue(config) {
  463. if (!config.attributes) {
  464. return;
  465. }
  466. let needInitConfig = {};
  467. let key = config.attributes[ATTRIBUTE_KEY];
  468. if (key != null) {
  469. needInitConfig[key] = config.attributes[ATTRIBUTE_DEFAULT_VALUE];
  470. }
  471. let __attr_init__ = config.attributes[ATTRIBUTE_INIT];
  472. if (typeof __attr_init__ === "function") {
  473. let __attr_result__ = __attr_init__();
  474. if (typeof __attr_result__ === "boolean" && !__attr_result__) {
  475. return;
  476. }
  477. }
  478. let initMoreValue = config.attributes[ATTRIBUTE_INIT_MORE_VALUE];
  479. if (initMoreValue && typeof initMoreValue === "object") {
  480. Object.assign(needInitConfig, initMoreValue);
  481. }
  482. let needInitConfigList = Object.keys(needInitConfig);
  483. if (!needInitConfigList.length) {
  484. if (config.type !== "button") {
  485. log.warn("请先配置键", config);
  486. }
  487. return;
  488. }
  489. needInitConfigList.forEach((__key) => {
  490. let __defaultValue = needInitConfig[__key];
  491. if (that.$data.data.has(__key)) {
  492. log.warn("请检查该key(已存在): " + __key);
  493. }
  494. that.$data.data.set(__key, __defaultValue);
  495. });
  496. }
  497. function loopInitDefaultValue(configList) {
  498. for (let index = 0; index < configList.length; index++) {
  499. let configItem = configList[index];
  500. initDefaultValue(configItem);
  501. let childForms = configItem.forms;
  502. if (childForms && Array.isArray(childForms)) {
  503. loopInitDefaultValue(childForms);
  504. }
  505. }
  506. }
  507. for (let index = 0; index < contentConfigList.length; index++) {
  508. let leftContentConfigItem = contentConfigList[index];
  509. if (!leftContentConfigItem.forms) {
  510. continue;
  511. }
  512. let rightContentConfigList = leftContentConfigItem.forms;
  513. if (rightContentConfigList && Array.isArray(rightContentConfigList)) {
  514. loopInitDefaultValue(rightContentConfigList);
  515. }
  516. }
  517. },
  518. /**
  519. * 设置值
  520. * @param key 键
  521. * @param value 值
  522. */
  523. setValue(key, value) {
  524. let locaData = _GM_getValue(KEY, {});
  525. let oldValue = locaData[key];
  526. locaData[key] = value;
  527. _GM_setValue(KEY, locaData);
  528. if (this.$listener.listenData.has(key)) {
  529. this.$listener.listenData.get(key).callback(key, oldValue, value);
  530. }
  531. },
  532. /**
  533. * 获取值
  534. * @param key 键
  535. * @param defaultValue 默认值
  536. */
  537. getValue(key, defaultValue) {
  538. let locaData = _GM_getValue(KEY, {});
  539. let localValue = locaData[key];
  540. if (localValue == null) {
  541. if (this.$data.data.has(key)) {
  542. return this.$data.data.get(key);
  543. }
  544. return defaultValue;
  545. }
  546. return localValue;
  547. },
  548. /**
  549. * 删除值
  550. * @param key 键
  551. */
  552. deleteValue(key) {
  553. let locaData = _GM_getValue(KEY, {});
  554. let oldValue = locaData[key];
  555. Reflect.deleteProperty(locaData, key);
  556. _GM_setValue(KEY, locaData);
  557. if (this.$listener.listenData.has(key)) {
  558. this.$listener.listenData.get(key).callback(key, oldValue, void 0);
  559. }
  560. },
  561. /**
  562. * 监听调用setValue、deleteValue
  563. * @param key 需要监听的键
  564. * @param callback
  565. */
  566. addValueChangeListener(key, callback, option) {
  567. let listenerId = Math.random();
  568. this.$listener.listenData.set(key, {
  569. id: listenerId,
  570. key,
  571. callback
  572. });
  573. if (option) {
  574. if (option.immediate) {
  575. callback(key, this.getValue(key), this.getValue(key));
  576. }
  577. }
  578. return listenerId;
  579. },
  580. /**
  581. * 移除监听
  582. * @param listenerId 监听的id
  583. */
  584. removeValueChangeListener(listenerId) {
  585. let deleteKey = null;
  586. for (const [key, value] of this.$listener.listenData.entries()) {
  587. if (value.id === listenerId) {
  588. deleteKey = key;
  589. break;
  590. }
  591. }
  592. if (typeof deleteKey === "string") {
  593. this.$listener.listenData.delete(deleteKey);
  594. } else {
  595. console.warn("没有找到对应的监听器");
  596. }
  597. },
  598. /**
  599. * 主动触发菜单值改变的回调
  600. * @param key 菜单键
  601. * @param newValue 想要触发的新值,默认使用当前值
  602. * @param oldValue 想要触发的旧值,默认使用当前值
  603. */
  604. triggerMenuValueChange(key, newValue, oldValue) {
  605. if (this.$listener.listenData.has(key)) {
  606. let listenData = this.$listener.listenData.get(key);
  607. if (typeof listenData.callback === "function") {
  608. let value = this.getValue(key);
  609. let __newValue = value;
  610. let __oldValue = value;
  611. if (typeof newValue !== "undefined" && arguments.length > 1) {
  612. __newValue = newValue;
  613. }
  614. if (typeof oldValue !== "undefined" && arguments.length > 2) {
  615. __oldValue = oldValue;
  616. }
  617. listenData.callback(key, __oldValue, __newValue);
  618. }
  619. }
  620. },
  621. /**
  622. * 判断该键是否存在
  623. * @param key 键
  624. */
  625. hasKey(key) {
  626. let locaData = _GM_getValue(KEY, {});
  627. return key in locaData;
  628. },
  629. /**
  630. * 自动判断菜单是否启用,然后执行回调
  631. * @param key
  632. * @param callback 回调
  633. * @param isReverse 逆反判断菜单启用
  634. * @param checkEnableCallBack 自定义检测菜单的值,可自行决定是否强制启用菜单,true是启用菜单,false是不启用菜单
  635. */
  636. execMenu(key, callback, isReverse = false, checkEnableCallBack) {
  637. if (!(typeof key === "string" || typeof key === "object" && Array.isArray(key))) {
  638. throw new TypeError("key 必须是字符串或者字符串数组");
  639. }
  640. let runKeyList = [];
  641. if (typeof key === "object" && Array.isArray(key)) {
  642. runKeyList = [...key];
  643. } else {
  644. runKeyList.push(key);
  645. }
  646. let value = void 0;
  647. for (let index = 0; index < runKeyList.length; index++) {
  648. const runKey = runKeyList[index];
  649. if (!this.$data.data.has(runKey)) {
  650. log.warn(`${key} 键不存在`);
  651. return;
  652. }
  653. let runValue = PopsPanel.getValue(runKey);
  654. if (isReverse) {
  655. runValue = !runValue;
  656. }
  657. if (typeof checkEnableCallBack === "function") {
  658. let checkResult = checkEnableCallBack(runKey, runValue);
  659. if (typeof checkResult === "boolean") {
  660. runValue = checkResult;
  661. }
  662. }
  663. if (!runValue) {
  664. break;
  665. }
  666. value = runValue;
  667. }
  668. if (value) {
  669. callback(value);
  670. }
  671. },
  672. /**
  673. * 自动判断菜单是否启用,然后执行回调,只会执行一次
  674. * @param key
  675. * @param callback 回调
  676. * @param getValueFn 自定义处理获取当前值,值true是启用并执行回调,值false是不执行回调
  677. * @param handleValueChangeFn 自定义处理值改变时的回调,值true是启用并执行回调,值false是不执行回调
  678. * @param checkEnableCallBack 自定义检测菜单的值,可自行决定是否强制启用菜单,true是启用菜单,false是不启用菜单
  679. */
  680. execMenuOnce(key, callback, getValueFn, handleValueChangeFn, checkEnableCallBack) {
  681. if (typeof key !== "string") {
  682. throw new TypeError("key 必须是字符串");
  683. }
  684. if (!this.$data.data.has(key)) {
  685. log.warn(`${key} 键不存在`);
  686. return;
  687. }
  688. if (this.$data.oneSuccessExecMenu.has(key)) {
  689. return;
  690. }
  691. this.$data.oneSuccessExecMenu.set(key, 1);
  692. let __getValue = () => {
  693. let localValue = PopsPanel.getValue(key);
  694. return typeof getValueFn === "function" ? getValueFn(key, localValue) : localValue;
  695. };
  696. let resultStyleList = [];
  697. let dynamicPushStyleNode = ($style) => {
  698. let __value = __getValue();
  699. let dynamicResultList = [];
  700. if ($style instanceof HTMLStyleElement) {
  701. dynamicResultList = [$style];
  702. } else if (Array.isArray($style)) {
  703. dynamicResultList = [
  704. ...$style.filter(
  705. (item) => item != null && item instanceof HTMLStyleElement
  706. )
  707. ];
  708. }
  709. if (__value) {
  710. resultStyleList = resultStyleList.concat(dynamicResultList);
  711. } else {
  712. for (let index = 0; index < dynamicResultList.length; index++) {
  713. let $css = dynamicResultList[index];
  714. $css.remove();
  715. dynamicResultList.splice(index, 1);
  716. index--;
  717. }
  718. }
  719. };
  720. let checkMenuEnableCallBack = (currentValue) => {
  721. return typeof checkEnableCallBack === "function" ? checkEnableCallBack(key, currentValue) : currentValue;
  722. };
  723. let changeCallBack = (currentValue) => {
  724. let resultList = [];
  725. if (checkMenuEnableCallBack(currentValue)) {
  726. let result = callback(currentValue, dynamicPushStyleNode);
  727. if (result instanceof HTMLStyleElement) {
  728. resultList = [result];
  729. } else if (Array.isArray(result)) {
  730. resultList = [
  731. ...result.filter(
  732. (item) => item != null && item instanceof HTMLStyleElement
  733. )
  734. ];
  735. }
  736. }
  737. for (let index = 0; index < resultStyleList.length; index++) {
  738. let $css = resultStyleList[index];
  739. $css.remove();
  740. resultStyleList.splice(index, 1);
  741. index--;
  742. }
  743. resultStyleList = [...resultList];
  744. };
  745. this.addValueChangeListener(
  746. key,
  747. (__key, oldValue, newValue) => {
  748. let __newValue = newValue;
  749. if (typeof handleValueChangeFn === "function") {
  750. __newValue = handleValueChangeFn(__key, newValue, oldValue);
  751. }
  752. changeCallBack(__newValue);
  753. }
  754. );
  755. let value = __getValue();
  756. if (value) {
  757. changeCallBack(value);
  758. }
  759. },
  760. /**
  761. * 父子菜单联动,自动判断菜单是否启用,然后执行回调,只会执行一次
  762. * @param key 菜单键
  763. * @param childKey 子菜单键
  764. * @param callback 回调
  765. * @param replaceValueFn 用于修改mainValue,返回undefined则不做处理
  766. */
  767. execInheritMenuOnce(key, childKey, callback, replaceValueFn) {
  768. let that = this;
  769. const handleInheritValue = (key2, childKey2) => {
  770. let mainValue = that.getValue(key2);
  771. let childValue = that.getValue(childKey2);
  772. if (typeof replaceValueFn === "function") {
  773. let changedMainValue = replaceValueFn(mainValue, childValue);
  774. if (changedMainValue != null) {
  775. return changedMainValue;
  776. }
  777. }
  778. return mainValue;
  779. };
  780. this.execMenuOnce(
  781. key,
  782. callback,
  783. () => {
  784. return handleInheritValue(key, childKey);
  785. },
  786. () => {
  787. return handleInheritValue(key, childKey);
  788. }
  789. );
  790. this.execMenuOnce(
  791. childKey,
  792. () => {
  793. },
  794. () => false,
  795. () => {
  796. this.triggerMenuValueChange(key);
  797. return false;
  798. }
  799. );
  800. },
  801. /**
  802. * 根据自定义key只执行一次
  803. * @param key 自定义key
  804. */
  805. onceExec(key, callback) {
  806. if (typeof key !== "string") {
  807. throw new TypeError("key 必须是字符串");
  808. }
  809. if (this.$data.onceExec.has(key)) {
  810. return;
  811. }
  812. callback();
  813. this.$data.onceExec.set(key, 1);
  814. },
  815. /**
  816. * 显示设置面板
  817. */
  818. showPanel() {
  819. __pops.panel({
  820. title: {
  821. text: `${SCRIPT_NAME}-设置`,
  822. position: "center",
  823. html: false,
  824. style: ""
  825. },
  826. content: this.getPanelContentConfig(),
  827. mask: {
  828. enable: true,
  829. clickEvent: {
  830. toClose: true,
  831. toHide: false
  832. }
  833. },
  834. zIndex() {
  835. let maxZIndex = Utils.getMaxZIndex();
  836. let popsMaxZIndex = __pops.config.InstanceUtils.getPopsMaxZIndex().zIndex;
  837. return Utils.getMaxValue(maxZIndex, popsMaxZIndex) + 100;
  838. },
  839. width: PanelUISize.setting.width,
  840. height: PanelUISize.setting.height,
  841. drag: true,
  842. only: true
  843. });
  844. },
  845. /**
  846. * 获取配置内容
  847. */
  848. getPanelContentConfig() {
  849. let configList = [Component_Common];
  850. return configList;
  851. }
  852. };
  853. const CookieManager = {
  854. get cookieManagerApiName() {
  855. let managerApi = PopsPanel.getValue(
  856. "cookie-manager-api",
  857. "document.cookie"
  858. );
  859. return managerApi;
  860. },
  861. get cookieManager() {
  862. if (this.cookieManagerApiName === "GM_cookie") {
  863. return _GM_cookie;
  864. } else if (this.cookieManagerApiName === "cookieStore") {
  865. let cookieStore = _unsafeWindow.cookieStore;
  866. return {
  867. list(options, callback) {
  868. cookieStore.getAll().then((result) => {
  869. callback(result);
  870. }).catch((reason) => {
  871. log.error(reason);
  872. Qmsg.error(reason.toString());
  873. });
  874. },
  875. set(cookieInfo, callback) {
  876. cookieStore.set(cookieInfo).then(() => {
  877. callback();
  878. }).catch((reason) => {
  879. callback(reason);
  880. });
  881. },
  882. delete(cookieInfo, callback) {
  883. cookieStore.delete(cookieInfo).then((result) => {
  884. callback();
  885. }).catch((reason) => {
  886. callback(reason);
  887. });
  888. }
  889. };
  890. } else {
  891. return utilsCookieManager;
  892. }
  893. },
  894. /**
  895. * 查询所有Cookie
  896. */
  897. queryAllCookie() {
  898. return new Promise((resolve) => {
  899. this.cookieManager.list({}, (cookieListResult) => {
  900. let __cookieListResult__ = cookieListResult || [];
  901. __cookieListResult__ = __cookieListResult__.sort(
  902. (a, b) => a.name.localeCompare(b.name)
  903. );
  904. resolve(__cookieListResult__);
  905. });
  906. });
  907. },
  908. /**
  909. * 清除所有Cookie
  910. */
  911. deleteAllCookie() {
  912. return new Promise((resolve) => {
  913. this.cookieManager.list({}, async (cookieListResult) => {
  914. const __cookieListResult__ = cookieListResult || [];
  915. const result = {
  916. success: 0,
  917. error: 0
  918. };
  919. for (let index = 0; index < __cookieListResult__.length; index++) {
  920. const cookieListItem = __cookieListResult__[index];
  921. let deleteError = await new Promise((deleteResolve) => {
  922. this.deleteCookie(cookieListItem).then((deleteResult) => {
  923. deleteResolve(deleteResult);
  924. });
  925. });
  926. if (deleteError) {
  927. result.error++;
  928. } else {
  929. result.success++;
  930. }
  931. }
  932. resolve(result);
  933. });
  934. });
  935. },
  936. /**
  937. * 添加Cookie
  938. */
  939. addCookie(cookieInfo) {
  940. return new Promise((resolve) => {
  941. delete cookieInfo.hostOnly;
  942. CookieManager.cookieManager.set(cookieInfo, (error) => {
  943. log.info(["添加Cookie", cookieInfo]);
  944. resolve(error);
  945. });
  946. });
  947. },
  948. /**
  949. * 删除Cookie
  950. */
  951. deleteCookie(cookieInfo) {
  952. return new Promise((resolve) => {
  953. CookieManager.cookieManager.delete(cookieInfo, (error) => {
  954. log.info(["删除Cookie", cookieInfo]);
  955. resolve(error);
  956. });
  957. });
  958. },
  959. /**
  960. * 更新Cookie
  961. */
  962. updateCookie(cookieInfo) {
  963. return new Promise(async (resolve) => {
  964. let result;
  965. try {
  966. log.info(["更新Cookie", cookieInfo]);
  967. let deleteError = await CookieManager.deleteCookie(cookieInfo);
  968. log.error(deleteError);
  969. if (deleteError) {
  970. throw new TypeError(deleteError.toString());
  971. }
  972. let addError = await CookieManager.addCookie(cookieInfo);
  973. log.error(addError);
  974. if (addError) {
  975. throw new TypeError(addError.toString());
  976. }
  977. } catch (error) {
  978. result = error;
  979. } finally {
  980. resolve(result);
  981. }
  982. });
  983. }
  984. };
  985. let edit_ui_input = (text, getValue, setValue, disabled) => {
  986. let config = {
  987. text,
  988. type: "input",
  989. isNumber: false,
  990. isPassword: false,
  991. props: {},
  992. attributes: {},
  993. description: "",
  994. getValue() {
  995. return getValue();
  996. },
  997. callback(event, value) {
  998. setValue(value);
  999. },
  1000. placeholder: "",
  1001. disabled: Boolean(disabled)
  1002. };
  1003. return config;
  1004. };
  1005. let edit_ui_select = (text, data, getValue, setValue, disabled) => {
  1006. let config = {
  1007. text,
  1008. type: "select",
  1009. description: "",
  1010. attributes: {},
  1011. props: {},
  1012. getValue() {
  1013. return getValue();
  1014. },
  1015. callback(event, isSelectedValue, isSelectedText) {
  1016. let value = isSelectedValue;
  1017. setValue(value);
  1018. },
  1019. // @ts-ignore
  1020. data,
  1021. disabled: Boolean(disabled)
  1022. };
  1023. return config;
  1024. };
  1025. const CookieManagerEditView = {
  1026. init() {
  1027. },
  1028. /**
  1029. * 显示视图
  1030. * @param cookieInfo 需要编辑的cookie
  1031. * @param dialogCloseCallBack 弹窗关闭的回调
  1032. */
  1033. showView(__cookieInfo__, dialogCloseCallBack) {
  1034. let isEdit = !!__cookieInfo__;
  1035. let cookieInfo = utils.assign(
  1036. {
  1037. name: "",
  1038. value: "",
  1039. domain: window.location.hostname,
  1040. path: "/",
  1041. secure: false,
  1042. hostOnly: false,
  1043. httpOnly: false,
  1044. sameSite: "lax",
  1045. expirationDate: Date.now() + 60 * 60 * 24 * 30 * 1e3
  1046. },
  1047. __cookieInfo__,
  1048. true
  1049. );
  1050. if (CookieManager.cookieManagerApiName === "cookieStore") {
  1051. if (cookieInfo.expires) {
  1052. cookieInfo.expirationDate = cookieInfo.expires;
  1053. }
  1054. }
  1055. let $dialog = __pops.confirm({
  1056. title: {
  1057. text: isEdit ? "编辑Cookie" : "添加Cookie",
  1058. position: "center"
  1059. },
  1060. content: {
  1061. text: "",
  1062. html: true
  1063. },
  1064. drag: true,
  1065. btn: {
  1066. position: "center",
  1067. ok: {
  1068. text: isEdit ? "编辑" : "添加",
  1069. async callback(eventDetails, event) {
  1070. let valid = CookieManagerEditView.validCookieInfo(cookieInfo);
  1071. if (!valid) {
  1072. return;
  1073. }
  1074. cookieInfo.value = encodeURIComponent(cookieInfo.value);
  1075. if (CookieManager.cookieManagerApiName === "document.cookie") {
  1076. cookieInfo.domain = "";
  1077. } else if (CookieManager.cookieManagerApiName === "GM_cookie") {
  1078. cookieInfo.expirationDate = Math.floor(
  1079. cookieInfo.expirationDate / 1e3
  1080. );
  1081. }
  1082. if (isEdit) {
  1083. let result = await CookieManager.updateCookie(cookieInfo);
  1084. if (result) {
  1085. Qmsg.error(result.toString());
  1086. } else {
  1087. Qmsg.success("修改成功");
  1088. eventDetails.close();
  1089. }
  1090. } else {
  1091. let result = await CookieManager.addCookie(cookieInfo);
  1092. if (result) {
  1093. Qmsg.error(result.toString());
  1094. } else {
  1095. Qmsg.success("添加成功");
  1096. eventDetails.close();
  1097. }
  1098. }
  1099. if (typeof dialogCloseCallBack === "function") {
  1100. dialogCloseCallBack(cookieInfo);
  1101. }
  1102. }
  1103. },
  1104. cancel: {
  1105. text: "取消"
  1106. }
  1107. },
  1108. mask: {
  1109. enable: true
  1110. },
  1111. width: window.innerWidth > 350 ? "350px" : "80vw",
  1112. height: PanelUISize.setting.height,
  1113. style: (
  1114. /*css*/
  1115. `
  1116. ${__pops.config.cssText.panelCSS}
  1117.  
  1118. .pops-panel-input input:disabled{
  1119. color: #b4b4b4;
  1120. }
  1121. .pops-confirm-content{
  1122. padding: 10px;
  1123. }
  1124. .pops-confirm-content li{
  1125. display: flex;
  1126. flex-direction: column;
  1127. }
  1128. .pops-panel-item-left-text{
  1129. margin-bottom: 5px;
  1130. }
  1131. .pops-panel-input.pops-input-disabled{
  1132. border: 1px solid #dcdfe6;
  1133. }
  1134. #cookie-item-property-expires{
  1135. border: 1px solid rgb(184, 184, 184, var(--pops-bd-opacity));
  1136. border-radius: 4px;
  1137. background-color: #ffffff;
  1138. width: 100%;
  1139. height: 32px;
  1140. padding: 0px 8px;
  1141. }
  1142. #cookie-item-property-expires:hover{
  1143. box-shadow: 0 0 0 1px #c0c4cc inset;
  1144. }
  1145. #cookie-item-property-expires:focus,
  1146. #cookie-item-property-expires:focus-within{
  1147. outline: 0;
  1148. border: 1px solid #409eff;
  1149. border-radius: 4px;
  1150. box-shadow: none;
  1151. }
  1152. `
  1153. )
  1154. });
  1155. let $editContent = $dialog.$shadowRoot.querySelector(
  1156. ".pops-confirm-content"
  1157. );
  1158. let panelHandleContentUtils = __pops.config.panelHandleContentUtils();
  1159. let $name = panelHandleContentUtils.createSectionContainerItem_input(
  1160. edit_ui_input(
  1161. "name",
  1162. () => cookieInfo.name,
  1163. (value) => cookieInfo.name = value,
  1164. isEdit
  1165. )
  1166. );
  1167. let $value = panelHandleContentUtils.createSectionContainerItem_input(
  1168. edit_ui_input(
  1169. "value",
  1170. () => cookieInfo.value,
  1171. (value) => cookieInfo.value = value
  1172. )
  1173. );
  1174. let $domain = panelHandleContentUtils.createSectionContainerItem_input(
  1175. edit_ui_input(
  1176. "domain",
  1177. () => cookieInfo.domain,
  1178. (value) => cookieInfo.domain = value
  1179. )
  1180. );
  1181. let $path = panelHandleContentUtils.createSectionContainerItem_input(
  1182. edit_ui_input(
  1183. "path",
  1184. () => cookieInfo.path,
  1185. (value) => cookieInfo.path = value
  1186. )
  1187. );
  1188. let $expires;
  1189. if (cookieInfo.session) {
  1190. $expires = panelHandleContentUtils.createSectionContainerItem_input(
  1191. edit_ui_input(
  1192. "expires",
  1193. () => "会话",
  1194. (value) => {
  1195. },
  1196. true
  1197. )
  1198. );
  1199. } else {
  1200. $expires = panelHandleContentUtils.createSectionContainerItem_own({
  1201. type: "own",
  1202. getLiElementCallBack: function(liElement) {
  1203. let $li = domUtils.createElement("li", {
  1204. innerHTML: (
  1205. /*html*/
  1206. `
  1207. <div class="pops-panel-item-left-text">
  1208. <p class="pops-panel-item-left-main-text">expires</p>
  1209. </div>
  1210. <div class="pops-panel-item-right-wrapper">
  1211. <input type="datetime-local" id="cookie-item-property-expires">
  1212. </div>
  1213. `
  1214. )
  1215. });
  1216. let $dateTime = $li.querySelector(
  1217. "#cookie-item-property-expires"
  1218. );
  1219. $dateTime.valueAsNumber = cookieInfo.expirationDate;
  1220. domUtils.on(
  1221. $dateTime,
  1222. ["change", "input", "propertychange"],
  1223. (event) => {
  1224. utils.preventEvent(event);
  1225. cookieInfo.expirationDate = $dateTime.valueAsNumber;
  1226. }
  1227. );
  1228. return $li;
  1229. }
  1230. });
  1231. }
  1232. let $httpOnly = panelHandleContentUtils.createSectionContainerItem_select(
  1233. edit_ui_select(
  1234. "httpOnly",
  1235. [
  1236. {
  1237. text: "true",
  1238. value: true
  1239. },
  1240. {
  1241. text: "false",
  1242. value: false
  1243. }
  1244. ],
  1245. () => cookieInfo.httpOnly,
  1246. (value) => cookieInfo.httpOnly = value
  1247. )
  1248. );
  1249. let $secure = panelHandleContentUtils.createSectionContainerItem_select(
  1250. edit_ui_select(
  1251. "secure",
  1252. [
  1253. {
  1254. text: "true",
  1255. value: true
  1256. },
  1257. {
  1258. text: "false",
  1259. value: false
  1260. }
  1261. ],
  1262. () => cookieInfo.secure,
  1263. (value) => cookieInfo.secure = value
  1264. )
  1265. );
  1266. let sameSiteData = [
  1267. {
  1268. text: "no_restriction",
  1269. value: "no_restriction"
  1270. },
  1271. {
  1272. text: "lax",
  1273. value: "lax"
  1274. },
  1275. {
  1276. text: "strict",
  1277. value: "strict"
  1278. },
  1279. {
  1280. text: "unspecified",
  1281. value: "unspecified"
  1282. }
  1283. ];
  1284. if (CookieManager.cookieManagerApiName === "cookieStore") {
  1285. sameSiteData = [
  1286. {
  1287. text: "lax",
  1288. value: "lax"
  1289. },
  1290. {
  1291. text: "strict",
  1292. value: "strict"
  1293. },
  1294. {
  1295. text: "none",
  1296. value: "none"
  1297. }
  1298. ];
  1299. }
  1300. let $sameSite = panelHandleContentUtils.createSectionContainerItem_select(
  1301. edit_ui_select(
  1302. "sameSite",
  1303. sameSiteData,
  1304. () => cookieInfo.sameSite,
  1305. (value) => cookieInfo.sameSite = value
  1306. )
  1307. );
  1308. domUtils.append($editContent, [$name, $value]);
  1309. if (CookieManager.cookieManagerApiName === "GM_cookie") {
  1310. domUtils.append($editContent, [
  1311. $domain,
  1312. $path,
  1313. $expires,
  1314. $httpOnly,
  1315. $secure,
  1316. $sameSite
  1317. ]);
  1318. } else if (CookieManager.cookieManagerApiName === "cookieStore") {
  1319. domUtils.append($editContent, [$domain, $path, $expires, $sameSite]);
  1320. }
  1321. },
  1322. /**
  1323. * Cookie信息校验
  1324. */
  1325. validCookieInfo(cookieInfo) {
  1326. if (cookieInfo.name == null || cookieInfo.name == "") {
  1327. Qmsg.error("name不能为空");
  1328. return false;
  1329. }
  1330. if (cookieInfo.domain == null || cookieInfo.domain == "") {
  1331. Qmsg.error("domain不能为空");
  1332. return false;
  1333. }
  1334. if (cookieInfo.path == null || cookieInfo.path == "") {
  1335. Qmsg.error("path不能为空");
  1336. return false;
  1337. }
  1338. return true;
  1339. }
  1340. };
  1341. const CookieManagerView = {
  1342. init() {
  1343. this.registerMenu();
  1344. },
  1345. /**
  1346. * 显示视图
  1347. */
  1348. async showView() {
  1349. const $alert = __pops.alert({
  1350. title: {
  1351. text: "Cookie编辑器",
  1352. html: false,
  1353. position: "center"
  1354. },
  1355. content: {
  1356. text: (
  1357. /*html*/
  1358. `
  1359. <div class="cookie-wrapper">
  1360. <div class="cookie-search-wrapper">
  1361. <div class="cookie-search-inner">
  1362. <input type="text" placeholder="搜索Cookie名称">
  1363. </div>
  1364. <div class="cookie-search-setting">
  1365. <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4368" width="28" height="28">
  1366. <path fill="#2c2c2c" d="M439.264 208a16 16 0 0 0-16 16v67.968a239.744 239.744 0 0 0-46.496 26.896l-58.912-34a16 16 0 0 0-21.856 5.856l-80 138.56a16 16 0 0 0 5.856 21.856l58.896 34a242.624 242.624 0 0 0 0 53.728l-58.88 34a16 16 0 0 0-6.72 20.176l0.848 1.68 80 138.56a16 16 0 0 0 21.856 5.856l58.912-34a239.744 239.744 0 0 0 46.496 26.88V800a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16v-67.968a239.744 239.744 0 0 0 46.512-26.896l58.912 34a16 16 0 0 0 21.856-5.856l80-138.56a16 16 0 0 0-4.288-20.832l-1.568-1.024-58.896-34a242.624 242.624 0 0 0 0-53.728l58.88-34a16 16 0 0 0 6.72-20.176l-0.848-1.68-80-138.56a16 16 0 0 0-21.856-5.856l-58.912 34a239.744 239.744 0 0 0-46.496-26.88V224a16 16 0 0 0-16-16h-160z m32 48h96v67.376l28.8 12.576c13.152 5.76 25.632 12.976 37.184 21.52l25.28 18.688 58.448-33.728 48 83.136-58.368 33.68 3.472 31.2a194.624 194.624 0 0 1 0 43.104l-3.472 31.2 58.368 33.68-48 83.136-58.432-33.728-25.296 18.688c-11.552 8.544-24.032 15.76-37.184 21.52l-28.8 12.576V768h-96v-67.376l-28.784-12.576c-13.152-5.76-25.632-12.976-37.184-21.52l-25.28-18.688-58.448 33.728-48-83.136 58.368-33.68-3.472-31.2a194.624 194.624 0 0 1 0-43.104l3.472-31.2-58.368-33.68 48-83.136 58.432 33.728 25.296-18.688a191.744 191.744 0 0 1 37.184-21.52l28.8-12.576V256z m47.28 144a112 112 0 1 0 0 224 112 112 0 0 0 0-224z m0 48a64 64 0 1 1 0 128 64 64 0 0 1 0-128z"></path>
  1367. </svg>
  1368. </div>
  1369. </div>
  1370. <div class="cookie-control-wrapper">
  1371. <button class="cookie-control-refresh" type="default">刷新</button>
  1372. <button class="cookie-control-add" type="default">添加</button>
  1373. <button class="cookie-control-copy-all" type="default">复制全部</button>
  1374. <button class="cookie-control-clear-all" type="default">清除全部</button>
  1375. <div class="cookie-setting">
  1376. <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4368" width="28" height="28">
  1377. <path fill="#2c2c2c" d="M439.264 208a16 16 0 0 0-16 16v67.968a239.744 239.744 0 0 0-46.496 26.896l-58.912-34a16 16 0 0 0-21.856 5.856l-80 138.56a16 16 0 0 0 5.856 21.856l58.896 34a242.624 242.624 0 0 0 0 53.728l-58.88 34a16 16 0 0 0-6.72 20.176l0.848 1.68 80 138.56a16 16 0 0 0 21.856 5.856l58.912-34a239.744 239.744 0 0 0 46.496 26.88V800a16 16 0 0 0 16 16h160a16 16 0 0 0 16-16v-67.968a239.744 239.744 0 0 0 46.512-26.896l58.912 34a16 16 0 0 0 21.856-5.856l80-138.56a16 16 0 0 0-4.288-20.832l-1.568-1.024-58.896-34a242.624 242.624 0 0 0 0-53.728l58.88-34a16 16 0 0 0 6.72-20.176l-0.848-1.68-80-138.56a16 16 0 0 0-21.856-5.856l-58.912 34a239.744 239.744 0 0 0-46.496-26.88V224a16 16 0 0 0-16-16h-160z m32 48h96v67.376l28.8 12.576c13.152 5.76 25.632 12.976 37.184 21.52l25.28 18.688 58.448-33.728 48 83.136-58.368 33.68 3.472 31.2a194.624 194.624 0 0 1 0 43.104l-3.472 31.2 58.368 33.68-48 83.136-58.432-33.728-25.296 18.688c-11.552 8.544-24.032 15.76-37.184 21.52l-28.8 12.576V768h-96v-67.376l-28.784-12.576c-13.152-5.76-25.632-12.976-37.184-21.52l-25.28-18.688-58.448 33.728-48-83.136 58.368-33.68-3.472-31.2a194.624 194.624 0 0 1 0-43.104l3.472-31.2-58.368-33.68 48-83.136 58.432 33.728 25.296-18.688a191.744 191.744 0 0 1 37.184-21.52l28.8-12.576V256z m47.28 144a112 112 0 1 0 0 224 112 112 0 0 0 0-224z m0 48a64 64 0 1 1 0 128 64 64 0 0 1 0-128z"></path>
  1378. </svg>
  1379. </div>
  1380. </div>
  1381. <div class="cookie-list-wrapper">
  1382. </div>
  1383. </div>
  1384. `
  1385. ),
  1386. html: true
  1387. },
  1388. btn: {
  1389. ok: {
  1390. enable: false
  1391. }
  1392. },
  1393. mask: {
  1394. enable: true
  1395. },
  1396. drag: true,
  1397. width: PanelUISize.setting.width,
  1398. height: PanelUISize.setting.height,
  1399. style: (
  1400. /*css*/
  1401. `
  1402. ${__pops.config.cssText.panelCSS}
  1403. .cookie-wrapper{
  1404. display: flex;
  1405. flex-direction: column;
  1406. padding: 10px;
  1407. gap: 10px;
  1408. }
  1409. .cookie-control-wrapper{
  1410. display: flex;
  1411. flex-wrap: wrap;
  1412. padding: 0px 10px;
  1413. gap: 5px;
  1414. --button-margin-left: 0px;
  1415. }
  1416. .cookie-search-wrapper{
  1417. display: flex;
  1418. align-items: center;
  1419. }
  1420. .cookie-search-inner{
  1421. width: 100%;
  1422. padding: 0px 10px;
  1423. }
  1424. .cookie-search-inner input{
  1425. height: 30px;
  1426. padding: 5px;
  1427. width: 100%;
  1428. }
  1429. .cookie-search-inner input:focus-visible{
  1430. outline: none;
  1431. }
  1432. .cookie-setting,
  1433. .cookie-search-setting{
  1434. display: flex;
  1435. align-items: center;
  1436. }
  1437. .cookie-setting svg,
  1438. .cookie-search-setting svg{
  1439. cursor: pointer;
  1440. }
  1441. .cookie-list-wrapper{
  1442. display: flex;
  1443. flex-wrap: wrap;
  1444. gap: 10px;
  1445. }
  1446. .cookie-item{
  1447. display: flex;
  1448. flex-direction: column;
  1449. padding: 10px 10px;
  1450. margin: 0px 10px;
  1451. background: #f1efef;
  1452. border-radius: 10px;
  1453. gap: 5px;
  1454. box-sizing: border-box;
  1455. width: 100%;
  1456. }
  1457. .cookie-item-group{
  1458. display: flex;
  1459. align-items: center;
  1460. }
  1461. .cookie-item-group-left{
  1462. width: 100px;
  1463. min-width: 100px;
  1464. max-width: 100px;
  1465. text-transform: capitalize
  1466. }
  1467. .cookie-item-group-control .cookie-item-group-right{
  1468. display: flex;
  1469. align-items: center;
  1470. gap: 10px;
  1471. }
  1472. .cookie-item-group-control .cookie-item-group-control-copy,
  1473. .cookie-item-group-control .cookie-item-group-control-edit,
  1474. .cookie-item-group-control .cookie-item-group-control-delete{
  1475. display: flex;
  1476. align-items: center;
  1477. }
  1478. .cookie-item-group-control .cookie-item-group-control-delete svg{
  1479. width: 16px;
  1480. height: 16px;
  1481. }
  1482. .cookie-item-group-control svg{
  1483. cursor: pointer;
  1484. }
  1485. `
  1486. )
  1487. });
  1488. const $search = $alert.$shadowRoot.querySelector(
  1489. ".cookie-search-inner input"
  1490. );
  1491. const $searchSetting = $alert.$shadowRoot.querySelector(
  1492. ".cookie-search-setting"
  1493. );
  1494. const $refresh = $alert.$shadowRoot.querySelector(
  1495. ".cookie-control-refresh"
  1496. );
  1497. const $add = $alert.$shadowRoot.querySelector(
  1498. ".cookie-control-add"
  1499. );
  1500. const $copyAll = $alert.$shadowRoot.querySelector(
  1501. ".cookie-control-copy-all"
  1502. );
  1503. const $clearAll = $alert.$shadowRoot.querySelector(
  1504. ".cookie-control-clear-all"
  1505. );
  1506. const $setting = $alert.$shadowRoot.querySelector(".cookie-setting");
  1507. const $cookieListWrapper = $alert.$shadowRoot.querySelector(
  1508. ".cookie-list-wrapper"
  1509. );
  1510. let createCookieItemElement = (cookieInfo) => {
  1511. const $cookieItem = domUtils.createElement("div", {
  1512. className: "cookie-item",
  1513. innerHTML: (
  1514. /*html*/
  1515. `
  1516. `
  1517. )
  1518. });
  1519. const cookieProperty = [
  1520. {
  1521. leftText: "name",
  1522. rightText: cookieInfo.name
  1523. },
  1524. {
  1525. leftText: "value",
  1526. rightText: PopsPanel.getValue("decode-cookie-value") ? decodeURIComponent(cookieInfo.value) : encodeURIComponent(cookieInfo.value)
  1527. }
  1528. ];
  1529. if (CookieManager.cookieManagerApiName === "GM_cookie") {
  1530. cookieInfo = cookieInfo;
  1531. cookieProperty.push(
  1532. {
  1533. leftText: "domain",
  1534. rightText: cookieInfo.domain
  1535. },
  1536. {
  1537. leftText: "path",
  1538. rightText: cookieInfo.path
  1539. },
  1540. {
  1541. leftText: "session",
  1542. rightText: JSON.stringify(cookieInfo.session)
  1543. },
  1544. {
  1545. leftText: "expires",
  1546. rightText: cookieInfo.session ? "会话" : cookieInfo.expirationDate ? new Date(cookieInfo.expirationDate * 1e3).toISOString() : "未知"
  1547. },
  1548. {
  1549. leftText: "httpOnly",
  1550. rightText: JSON.stringify(cookieInfo.httpOnly)
  1551. },
  1552. {
  1553. leftText: "hostOnly",
  1554. rightText: JSON.stringify(cookieInfo.hostOnly)
  1555. },
  1556. {
  1557. leftText: "secure",
  1558. rightText: JSON.stringify(cookieInfo.secure)
  1559. },
  1560. {
  1561. leftText: "sameSite",
  1562. rightText: cookieInfo.sameSite
  1563. }
  1564. );
  1565. } else if (CookieManager.cookieManagerApiName === "cookieStore") {
  1566. cookieInfo = cookieInfo;
  1567. cookieProperty.push(
  1568. {
  1569. leftText: "domain",
  1570. rightText: cookieInfo.domain
  1571. },
  1572. {
  1573. leftText: "path",
  1574. rightText: cookieInfo.path
  1575. },
  1576. {
  1577. leftText: "expires",
  1578. rightText: cookieInfo.expires ? new Date(cookieInfo.expires).toISOString() : "未知"
  1579. },
  1580. {
  1581. leftText: "secure",
  1582. rightText: JSON.stringify(cookieInfo.secure)
  1583. },
  1584. {
  1585. leftText: "sameSite",
  1586. rightText: cookieInfo.sameSite
  1587. }
  1588. );
  1589. }
  1590. cookieProperty.forEach((it) => {
  1591. const $cookieItemGroup = domUtils.createElement("div", {
  1592. className: "cookie-item-group",
  1593. innerHTML: (
  1594. /*html*/
  1595. `
  1596. <div class="cookie-item-group-left">
  1597. <p>${it.leftText}</p>
  1598. </div>
  1599. <div class="cookie-item-group-right">
  1600. <p>${it.rightText}</p>
  1601. </div>
  1602. `
  1603. )
  1604. });
  1605. domUtils.append($cookieItem, $cookieItemGroup);
  1606. });
  1607. let $cookieItemGroupControl = domUtils.createElement("div", {
  1608. className: "cookie-item-group cookie-item-group-control",
  1609. innerHTML: (
  1610. /*html*/
  1611. `
  1612. <div class="cookie-item-group-left">操作</div>
  1613. <div class="cookie-item-group-right">
  1614. <div class="cookie-item-group-control-copy">
  1615. <svg t="1742795616339" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
  1616. <path d="M880 247.008l-162.016-166.016Q700.992 64 677.984 64h-316.992q-26.016 0-46.016 18.016-16.992 15.008-23.008 36.992H231.968q-43.008 0-73.504 31.008t-30.496 76v627.008q0 44 30.496 75.488T231.968 960h508q43.008 0 73.504-31.488t30.496-75.488v-63.008q23.008-6.016 37.504-25.504t14.496-44.512V287.008q0-24-16-40z m-168-160.992l-3.008-3.008z m98.016 177.984L744 196z m-126.016-116.992l108 110.016h-108V147.008zM676.992 128zM204.992 948q4 0.992 4.992 2.016-2.016-0.992-4.992-2.016z m27.008 4q-6.016 0-12-0.992 4.992 0.992 12 0.992z m543.008-99.008q0 15.008-10.016 25.504t-24.992 10.496H232q-14.016 0-24.512-10.496t-10.496-25.504V225.984q0-15.008 10.496-25.504t24.512-10.496h58.016v531.008q0 30.016 20.992 51.008t50.016 20.992H775.04v60z m52-132.992q0 2.016-2.016 2.016h-464q-2.016 0-2.016-2.016V136.992q0-2.016 2.016-2.016h251.008v156.992q0 15.008 10.016 24.992t24 10.016h180.992v392.992z m9.984 64q4-0.992 8.992-2.016-4.992 0.992-8.992 2.016z m-244-168.992h-107.008q-15.008 0-24.992 10.496t-10.016 24.992 10.016 24.992 24.992 10.496h107.008q14.016 0 24.512-10.496t10.496-24.992-10.496-24.992-24.512-10.496z m107.008-111.008h-214.016q-14.016 0-24.512 10.496t-10.496 24.992 10.496 24.992 24.512 10.496h214.016q14.016 0 24-10.496t10.016-24.992-10.016-24.992-24-10.496z m-240.992 36q0 4 0.992 8-0.992-4-0.992-8zM700 512z m12 52l4-2.016z m-260.992-135.488q0 14.496 10.496 24.992t24.512 10.496h214.016q14.016 0 24-10.496t10.016-24.992-10.016-24.992-24-10.496h-214.016q-14.016 0-24.512 10.496t-10.496 24.992z m8 1.504z"></path>
  1617. </svg>
  1618. </div>
  1619. <div class="cookie-item-group-control-edit">
  1620. <svg t="1742795710451" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
  1621. <path d="M800 960 224 960c-52.928 0-96-43.072-96-96L128 224c0-52.928 43.072-96 96-96l448 0c17.696 0 32 14.336 32 32s-14.304 32-32 32L224 192C206.368 192 192 206.368 192 224l0 640c0 17.664 14.368 32 32 32l576 0c17.664 0 32-14.336 32-32L832 352c0-17.664 14.304-32 32-32s32 14.336 32 32l0 512C896 916.928 852.928 960 800 960zM612 448c-8.192 0-16.384-3.136-22.624-9.376-12.512-12.512-12.512-32.736 0-45.248l318.016-318.016c12.512-12.512 32.736-12.512 45.248 0s12.512 32.736 0 45.248l-318.016 318.016C628.384 444.896 620.192 448 612 448zM480 448 288 448c-17.664 0-32-14.336-32-32s14.336-32 32-32l192 0c17.664 0 32 14.336 32 32S497.664 448 480 448zM672 640 288 640c-17.664 0-32-14.304-32-32s14.336-32 32-32l384 0c17.696 0 32 14.304 32 32S689.696 640 672 640z"></path>
  1622. </svg>
  1623. </div>
  1624. <div class="cookie-item-group-control-delete">
  1625. ${__pops.config.iconSVG.delete}
  1626. </div>
  1627. </div>
  1628. `
  1629. )
  1630. });
  1631. let $cookieItemCopy = $cookieItemGroupControl.querySelector(
  1632. ".cookie-item-group-control-copy"
  1633. );
  1634. let $cookieItemEdit = $cookieItemGroupControl.querySelector(
  1635. ".cookie-item-group-control-edit"
  1636. );
  1637. let $cookieItemDelete = $cookieItemGroupControl.querySelector(
  1638. ".cookie-item-group-control-delete"
  1639. );
  1640. domUtils.on($cookieItemCopy, "click", (event) => {
  1641. utils.preventEvent(event);
  1642. let cookieText = cookieInfo.value;
  1643. utils.setClip(cookieText).then((status) => {
  1644. if (status) {
  1645. Qmsg.success("复制成功");
  1646. } else {
  1647. Qmsg.error("复制失败");
  1648. }
  1649. });
  1650. });
  1651. domUtils.on($cookieItemEdit, "click", (event) => {
  1652. utils.preventEvent(event);
  1653. CookieManagerEditView.showView(cookieInfo, (__cookieInfo__) => {
  1654. var _a2;
  1655. let $newCookieItem = createCookieItemElement(__cookieInfo__);
  1656. domUtils.after($cookieItem, $newCookieItem);
  1657. (_a2 = $cookieItem.parentElement) == null ? void 0 : _a2.removeChild($cookieItem);
  1658. });
  1659. });
  1660. domUtils.on($cookieItemDelete, "click", (event) => {
  1661. utils.preventEvent(event);
  1662. let result = confirm("确定删除该Cookie?");
  1663. if (!result) {
  1664. return;
  1665. }
  1666. CookieManager.deleteCookie(cookieInfo).then((status) => {
  1667. var _a2;
  1668. if (!status) {
  1669. Qmsg.success("删除成功");
  1670. (_a2 = $cookieItem.parentElement) == null ? void 0 : _a2.removeChild($cookieItem);
  1671. } else {
  1672. log.error(status);
  1673. Qmsg.error("删除失败");
  1674. }
  1675. });
  1676. });
  1677. domUtils.append($cookieItem, [$cookieItemGroupControl]);
  1678. return $cookieItem;
  1679. };
  1680. let updateCookieListGroup = async (filterCallBack) => {
  1681. let cookieList = await CookieManager.queryAllCookie();
  1682. if (typeof filterCallBack === "function") {
  1683. cookieList = cookieList.filter(filterCallBack);
  1684. }
  1685. domUtils.empty($cookieListWrapper);
  1686. let $fragment = document.createDocumentFragment();
  1687. cookieList.forEach((cookieItem) => {
  1688. if (
  1689. // @ts-ignore
  1690. cookieItem.session && PopsPanel.getValue("exclude-session-cookie")
  1691. ) {
  1692. return;
  1693. }
  1694. const $cookieItem = createCookieItemElement(cookieItem);
  1695. domUtils.append($fragment, $cookieItem);
  1696. });
  1697. domUtils.append($cookieListWrapper, $fragment);
  1698. };
  1699. updateCookieListGroup();
  1700. domUtils.on(
  1701. $search,
  1702. ["input", "propertychange"],
  1703. utils.debounce((event) => {
  1704. updateCookieListGroup((cookieItem) => {
  1705. let searchText = domUtils.val($search);
  1706. let enableRegExp = PopsPanel.getValue(
  1707. "search-config-use-regexp"
  1708. );
  1709. return enableRegExp ? Boolean(cookieItem.name.match(new RegExp(searchText))) : cookieItem.name.includes(searchText);
  1710. });
  1711. })
  1712. );
  1713. domUtils.listenKeyboard(
  1714. $search,
  1715. "keypress",
  1716. (keyName, keyValue, otherCodeList) => {
  1717. if (keyName === "Enter" && otherCodeList.length === 0) {
  1718. utils.dispatchEvent($search, "input");
  1719. }
  1720. }
  1721. );
  1722. domUtils.on($searchSetting, "click", (event) => {
  1723. utils.preventEvent(event);
  1724. let $settingAlert = __pops.alert({
  1725. title: {
  1726. text: "搜索配置",
  1727. position: "center"
  1728. },
  1729. content: {
  1730. text: "",
  1731. html: true
  1732. },
  1733. btn: {
  1734. ok: {
  1735. enable: false
  1736. }
  1737. },
  1738. drag: true,
  1739. mask: {
  1740. clickEvent: {
  1741. toClose: true
  1742. }
  1743. },
  1744. width: PanelUISize.info.width,
  1745. height: PanelUISize.info.height,
  1746. style: (
  1747. /*css*/
  1748. `
  1749. ${__pops.config.cssText.panelCSS}
  1750.  
  1751. .pops-alert-content li{
  1752. display: flex;
  1753. justify-content: space-between;
  1754. align-items: center;
  1755. padding: 10px;
  1756. }
  1757. .pops-panel-item-left-desc-text{
  1758. line-height: normal;
  1759. margin-top: 6px;
  1760. font-size: 0.8em;
  1761. color: rgb(108, 108, 108);
  1762. }
  1763. `
  1764. )
  1765. });
  1766. let $content = $settingAlert.$shadowRoot.querySelector(
  1767. ".pops-alert-content"
  1768. );
  1769. let panelHandleContentUtils = __pops.config.panelHandleContentUtils();
  1770. let $useRegExp = panelHandleContentUtils.createSectionContainerItem_switch(
  1771. UISwitch(
  1772. "启用正则表达式",
  1773. "search-config-use-regexp",
  1774. false,
  1775. void 0,
  1776. "使用正则表达式搜索Cookie名称"
  1777. )
  1778. );
  1779. domUtils.append($content, $useRegExp);
  1780. });
  1781. domUtils.on($refresh, "click", (event) => {
  1782. utils.preventEvent(event);
  1783. let searchText = domUtils.val($search);
  1784. if (searchText == "") {
  1785. updateCookieListGroup();
  1786. } else {
  1787. utils.dispatchEvent($search, "input");
  1788. }
  1789. });
  1790. domUtils.on($add, "click", (event) => {
  1791. utils.preventEvent(event);
  1792. CookieManagerEditView.showView(void 0, (__cookieInfo__) => {
  1793. updateCookieListGroup();
  1794. });
  1795. });
  1796. domUtils.on($copyAll, "click", (event) => {
  1797. utils.preventEvent(event);
  1798. CookieManager.queryAllCookie().then((cookieList) => {
  1799. cookieList = cookieList.filter((it) => {
  1800. return !(it.session && PopsPanel.getValue("exclude-session-cookie"));
  1801. });
  1802. if (cookieList.length === 0) {
  1803. Qmsg.warning("没有Cookie可以复制");
  1804. return;
  1805. }
  1806. let cookieText = cookieList.map((it) => {
  1807. let cookieItemValueText = it.value;
  1808. return `${it.name}=${cookieItemValueText}; `;
  1809. }).join("");
  1810. utils.setClip(cookieText).then((status) => {
  1811. if (status) {
  1812. Qmsg.success("复制成功");
  1813. } else {
  1814. Qmsg.error("复制失败");
  1815. }
  1816. });
  1817. });
  1818. });
  1819. domUtils.on($clearAll, "click", (event) => {
  1820. utils.preventEvent(event);
  1821. let result = window.confirm("确定清除全部Cookie?");
  1822. if (!result) {
  1823. return;
  1824. }
  1825. CookieManager.deleteAllCookie().then((deleteInfo) => {
  1826. if (deleteInfo.error) {
  1827. Qmsg.warning(
  1828. `清除成功:${deleteInfo.success} 失败:${deleteInfo.error}`
  1829. );
  1830. } else {
  1831. Qmsg.success("清除成功");
  1832. }
  1833. updateCookieListGroup();
  1834. });
  1835. });
  1836. domUtils.on($setting, "click", (event) => {
  1837. utils.preventEvent(event);
  1838. let $settingAlert = __pops.alert({
  1839. title: {
  1840. text: "设置",
  1841. position: "center"
  1842. },
  1843. content: {
  1844. text: "",
  1845. html: true
  1846. },
  1847. btn: {
  1848. ok: {
  1849. enable: false
  1850. }
  1851. },
  1852. drag: true,
  1853. mask: {
  1854. clickEvent: {
  1855. toClose: true
  1856. }
  1857. },
  1858. width: PanelUISize.info.width,
  1859. height: PanelUISize.info.height,
  1860. style: (
  1861. /*css*/
  1862. `
  1863. ${__pops.config.cssText.panelCSS}
  1864.  
  1865. .pops-alert-content li{
  1866. display: flex;
  1867. justify-content: space-between;
  1868. align-items: center;
  1869. padding: 10px;
  1870. }
  1871. .pops-panel-item-left-desc-text{
  1872. line-height: normal;
  1873. margin-top: 6px;
  1874. font-size: 0.8em;
  1875. color: rgb(108, 108, 108);
  1876. }
  1877. `
  1878. )
  1879. });
  1880. let $content = $settingAlert.$shadowRoot.querySelector(
  1881. ".pops-alert-content"
  1882. );
  1883. let panelHandleContentUtils = __pops.config.panelHandleContentUtils();
  1884. let $useGM_cookie = panelHandleContentUtils.createSectionContainerItem_select(
  1885. UISelect(
  1886. "CookieManager Api",
  1887. "cookie-manager-api",
  1888. "document.cookie",
  1889. [
  1890. {
  1891. text: "document.cookie",
  1892. value: "document.cookie"
  1893. },
  1894. {
  1895. text: "cookieStore",
  1896. value: "cookieStore"
  1897. },
  1898. {
  1899. text: "GM_cookie",
  1900. value: "GM_cookie"
  1901. }
  1902. ],
  1903. () => {
  1904. updateCookieListGroup();
  1905. },
  1906. "操作Cookie的Api函数"
  1907. )
  1908. );
  1909. let $decodeValue = panelHandleContentUtils.createSectionContainerItem_switch(
  1910. UISwitch(
  1911. "解码Cookie值",
  1912. "decode-cookie-value",
  1913. false,
  1914. () => {
  1915. updateCookieListGroup();
  1916. },
  1917. "对Cookie值进行解码"
  1918. )
  1919. );
  1920. let $excludeSessionCookie = panelHandleContentUtils.createSectionContainerItem_switch(
  1921. UISwitch(
  1922. "排除Session Cookie",
  1923. "exclude-session-cookie",
  1924. false,
  1925. () => {
  1926. updateCookieListGroup();
  1927. },
  1928. "过滤掉浏览器会话Cookie"
  1929. )
  1930. );
  1931. domUtils.append($content, [
  1932. $useGM_cookie,
  1933. $decodeValue,
  1934. $excludeSessionCookie
  1935. ]);
  1936. });
  1937. },
  1938. /**
  1939. * 注册(不可用)脚本菜单
  1940. */
  1941. registerMenu() {
  1942. const that = this;
  1943. GM_Menu.add({
  1944. key: "cookie_manager_view",
  1945. text: "⚙ Cookie管理",
  1946. autoReload: false,
  1947. isStoreValue: false,
  1948. showText(text, enable) {
  1949. return text;
  1950. },
  1951. callback(data) {
  1952. that.showView();
  1953. }
  1954. });
  1955. }
  1956. };
  1957. PopsPanel.init();
  1958. CookieManagerView.init();
  1959.  
  1960. })(Qmsg, DOMUtils, Utils, pops);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址