From 7898213561ad17f944c75d86afda112343729689 Mon Sep 17 00:00:00 2001 From: Rafael Grigorian Date: Tue, 12 Nov 2024 22:22:33 -0600 Subject: [PATCH] Added option to ignore store id when importing/exporting cookies via json --- src/components/Options.jsx | 46 ++++++++++++++++++++++++--------- src/contexts/CookiesContext.jsx | 22 +++++++++++++++- src/data/defaults.js | 1 + src/data/locales/en.js | 11 +++++++- src/data/locales/ru.js | 11 +++++++- src/data/locales/zh.js | 11 +++++++- yarn.lock | 26 ++++++++++++++----- 7 files changed, 105 insertions(+), 23 deletions(-) diff --git a/src/components/Options.jsx b/src/components/Options.jsx index a53347e..f1328f7 100644 --- a/src/components/Options.jsx +++ b/src/components/Options.jsx @@ -15,6 +15,7 @@ import SearchIcon from "@material-ui/icons/Search" import SecurityIcon from "@material-ui/icons/Security" import BlockIcon from "@material-ui/icons/Block" import PaletteIcon from "@material-ui/icons/Palette" +import SettingsSuggestIcon from "@material-ui/icons/SettingsSuggest" import ExitToAppIcon from "@material-ui/icons/ExitToApp" import SpecialThanksIcon from "@material-ui/icons/Favorite" import Toolbar from "@material-ui/core/Toolbar" @@ -260,6 +261,10 @@ class Options extends React.Component { {} + window.location = "#functionality"} > + {} + + window.location = "#blocked-cookies"} > {} @@ -315,6 +320,34 @@ class Options extends React.Component { + {i18n.translate ("functionality")} + + {i18n.translate ("functionalityDescription")} + +
+ + + {i18n.translate ("updateProtectedCookiesValue")} + storage.set ( "updateProtectedValue", e.target.checked )} + /> + + + + + {i18n.translate ("ignoreStoreId")} + storage.set ( "ignoreStoreId", e.target.checked )} + /> + + +
{i18n.translate ("appearance")} {i18n.translate ("appearanceDescription")} @@ -384,17 +417,6 @@ class Options extends React.Component { /> - - - {i18n.translate ("updateProtectedCookiesValue")} - storage.set ( "updateProtectedValue", e.target.checked )} - /> - - {i18n.translate ("expirationTimeFormat")} @@ -436,7 +458,7 @@ class Options extends React.Component { - {i18n.translate ("")} + {i18n.translate ("blockedCookies")} {i18n.translate ("blockedCookiesDescription")} diff --git a/src/contexts/CookiesContext.jsx b/src/contexts/CookiesContext.jsx index 4c4b2e0..6003b9d 100644 --- a/src/contexts/CookiesContext.jsx +++ b/src/contexts/CookiesContext.jsx @@ -112,7 +112,22 @@ class CookiesProvider extends React.Component { getJson ( cookie ) { const { found } = this.state - return JSON.stringify ( cookie ? cookie : found, null, "\t" ) + const { storage } = this.props + const { ignoreStoreId } = storage.data + var data = cookie ? cookie : found + if ( ignoreStoreId ) { + if ( Array.isArray ( data ) ) { + data = data.map ( cookie => { + const { storeId, ...rest } = cookie + return rest + }) + } + else { + const { storeId, ...rest } = data + data = rest + } + } + return JSON.stringify ( data, null, "\t" ) } getNetscape ( cookie ) { @@ -178,6 +193,8 @@ class CookiesProvider extends React.Component { } import ( updateCount ) { + const { storage } = this.props + const { ignoreStoreId } = storage.data return new Promise ( ( resolve, reject ) => { const chooser = document.createElement ("input") chooser.type = "file" @@ -200,6 +217,9 @@ class CookiesProvider extends React.Component { failed: [], } return Promise.each ( data, cookie => { + if ( ignoreStoreId ) { + cookie.storeId = undefined + } return utils.set ( cookie ) .then ( () => { results.current++ diff --git a/src/data/defaults.js b/src/data/defaults.js index 0b7b23a..477b35f 100644 --- a/src/data/defaults.js +++ b/src/data/defaults.js @@ -11,6 +11,7 @@ module.exports = { expirationFormat: "humanized", sortType: "expirationDate", sortDirection: "ascending", + ignoreStoreId: false, // Lists protect: {}, block: {}, diff --git a/src/data/locales/en.js b/src/data/locales/en.js index 8dfe16a..094d16a 100644 --- a/src/data/locales/en.js +++ b/src/data/locales/en.js @@ -51,7 +51,7 @@ module.exports = { "message": "These settings are stored locally and are not synced across browsers. Case sensitivity applies to both regular and regexp search." }, "appearanceDescription": { - "message": "Unfortunately Chrome extensions cannot detect if your system is using a Dark theme. Thankfully, there is still a dark mode that you can set manually!" + "message": "Adjust visual settings to personalize your browsing experience, including theme and display options." }, "blockedCookiesDescription": { "message": "When a cookie is blocked, the name, domain, and path is saved and is used to block future cookies from being created. All three properties must match exactly for a cookie to be blocked." @@ -386,4 +386,13 @@ module.exports = { "exportCookie": { "message": "Export Cookie" }, + "functionality": { + "message": "Functionality" + }, + "functionalityDescription": { + "message": "Manage how cookies are processed and interacted with, offering precise control over cookie handling behaviors." + }, + "ignoreStoreId": { + "message": "Ignore Store ID" + }, } \ No newline at end of file diff --git a/src/data/locales/ru.js b/src/data/locales/ru.js index b553f4f..8e94249 100644 --- a/src/data/locales/ru.js +++ b/src/data/locales/ru.js @@ -51,7 +51,7 @@ module.exports = { "message": "Эти настройки хранятся локально и не синхронизируются между браузерами. Чувствительность к регистру применяется как к обычному поиску, так и к поиску по регулярному выражению." }, "appearanceDescription": { - "message": "К сожалению, расширения Chrome не могут определить, использует ли ваша система темную тему. К счастью, все еще есть темный режим, который вы можете установить вручную!" + "message": "Настройте визуальные параметры, чтобы персонализировать ваш опыт просмотра, включая темы и параметры отображения." }, "blockedCookiesDescription": { "message": "Когда файл Печенье заблокирован, имя, домен и путь сохраняются и используются для блокировки создания файлов Печенье в будущем. Все три свойства должны точно совпадать, чтобы файл Печенье был заблокирован." @@ -386,4 +386,13 @@ module.exports = { "exportCookie": { "message": "Экспортировать куки" }, + "functionality": { + "message": "Функциональность" + }, + "functionalityDescription": { + "message": "Управляйте тем, как обрабатываются и взаимодействуют с cookies, предлагая точный контроль над поведением обработки cookies." + }, + "ignoreStoreId": { + "message": "Игнорировать Store ID" + }, } \ No newline at end of file diff --git a/src/data/locales/zh.js b/src/data/locales/zh.js index 77cf3c2..d867cf8 100644 --- a/src/data/locales/zh.js +++ b/src/data/locales/zh.js @@ -51,7 +51,7 @@ module.exports = { "message": "这些设置存储在本地,不会在浏览器之间同步。区分大小写适用于常规搜索和正则表达式搜索。" }, "appearanceDescription": { - "message": "不幸的是,Chrome 扩展程序无法检测到您的系统是否使用深色主题。值得庆幸的是,您仍然可以手动设置深色模式!" + "message": "调整视觉设置以个性化您的浏览体验,包括主题和显示选项。" }, "blockedCookiesDescription": { "message": "cookie 被阻止后,其名称、域和路径将被保存,用于阻止今后创建的cookies。这三个属性必须完全匹配,cookie 才能被阻止。" @@ -386,4 +386,13 @@ module.exports = { "exportCookie": { "message": "导出Cookie" }, + "functionality": { + "message": "功能" + }, + "functionalityDescription": { + "message": "管理如何处理和交互 cookies,提供对 cookies 处理行为的精确控制。" + }, + "ignoreStoreId": { + "message": "忽略 Store ID" + }, } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 90f6478..b4f7b0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -76,13 +76,20 @@ dependencies: regenerator-runtime "^0.13.11" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.7": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.7": version "7.12.5" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.14.8", "@babel/runtime@^7.4.4": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1" + integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/types@^7.12.5": version "7.12.11" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.11.tgz#a86e4d71e30a9b6ee102590446c98662589283ce" @@ -605,11 +612,11 @@ react-transition-group "^4.4.0" "@material-ui/icons@^5.0.0-alpha.23": - version "5.0.0-alpha.23" - resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-alpha.23.tgz#b7d5141cfaa1df4a9697c60e50df2e5f2c6a0047" - integrity sha512-paML0ghK4qN+Z0oAd66lDfX1+Vt1LBPkMA9uSUEBmGga2yY8aGpo9tAVGM3UR7kTx0BEWT5e/4u2aDvwbdGZPQ== + version "5.0.0-beta.5" + resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-beta.5.tgz#54295b9aa120910c88900e3d08082b7acbeb73c0" + integrity sha512-C2KHSf8mvDn22rzsV0UfsJyBYI3Nt/LItcKPJBAG9kgqdBHAuLMH2lfKmdMuX55qd8O+NO5rM7aIHdYQRjfcMQ== dependencies: - "@babel/runtime" "^7.4.4" + "@babel/runtime" "^7.14.8" "@material-ui/styled-engine@5.0.0-alpha.19": version "5.0.0-alpha.19" @@ -5284,16 +5291,21 @@ real-require@^0.2.0: resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.2.0.tgz#209632dea1810be2ae063a6ac084fee7e33fba78" integrity sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg== -regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.7: +regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7: version "0.13.11" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== -regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4: +regenerator-runtime@^0.13.3: version "0.13.7" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + registry-auth-token@^5.0.1: version "5.0.2" resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-5.0.2.tgz#8b026cc507c8552ebbe06724136267e63302f756"